Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deal with the sql_mode problem in MySQL stored procedure

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to deal with the sql_mode problem in MySQL stored procedures, which is very detailed and has a certain reference value. Friends who are interested must read it!

Sql_mode='STRICT_TRANS_TABLES' is set in my.cnf

However, it is found that illegal data is still written. For example, the original value of the unsigned integer field is 0 and can be subtracted. Of course, the result is overflowed. After checking, it is found that the default sql_mode in the stored procedure does not use global's sql_mode. The test is as follows:

CREATE PROCEDURE p_test ()

BEGIN

Select @ @ session.sql_mode,@@global.sql_mode

END

Call p_test ()

+-+ +

| | @ @ session.sql_mode | @ @ global.sql_mode |

+-+ +

| | STRICT_TRANS_TABLES |

+-+ +

1 row in set (0.00 sec)

CREATE PROCEDURE p_test1 ()

BEGIN

Set sql_mode=@@global.sql_mode

Select @ @ session.sql_mode,@@global.sql_mode

END

Call p_test1 ()

+-+ +

| | @ @ session.sql_mode | @ @ global.sql_mode |

+-+ +

| | STRICT_TRANS_TABLES | STRICT_TRANS_TABLES |

+-+ +

1 row in set (0.00 sec)

These are all the contents of the article "how to deal with sql_mode problems in MySQL stored procedures". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report