Home >Database >Mysql Tutorial >Does MySQL preserve the environment in which stored procedures are created?
Actually, MySQL retains the environment in which the stored procedure was created. This can be understood through the following example where we use two bars to concatenate strings. This is only legal when the SQL mode is ansi. However, if we change the SQL mode to non-ansi, the process still works as if the original setting was still true.
mysql> Set sql_mode = 'ansi'// Query OK, 0 rows affected, 1 warning (0.14 sec) mysql> Create Procedure Con_string() -> SELECT 'a'||'b'// Query OK, 0 rows affected (0.12 sec) mysql> Call Con_string (); +----------+ | 'a'||'b' | +----------+ | ab | +----------+ 1 row in set (0.05 sec) Query OK, 0 rows affected (0.05 sec) mysql> Set sql_mode = ''; Query OK, 0 rows affected (0.00 sec) mysql> Call Con_string(); +----------+ | 'a'||'b' | +----------+ | ab | +----------+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.00 sec)
The above result set shows that even after changing the SQL mode to non-ansi, the procedure Con_string() still generates the same as if the SQL mode is still ansi the result of. But the new program will not accept both bars because we have changed the SQL mode to non-ansi.
mysql> create procedure Con_string1() -> Select 'a'||'b'// Query OK, 0 rows affected (0.02 sec) mysql> Call Con_string1()// +----------+ | 'a'||'b' | +----------+ | 0 | +----------+ 1 row in set (0.00 sec) Query OK, 0 rows affected, 2 warnings (0.00 sec)
The above is the detailed content of Does MySQL preserve the environment in which stored procedures are created?. For more information, please follow other related articles on the PHP Chinese website!