How to execute dynamic SQL statements in MySQL stored procedures
Drop PROCEDURE if exists my_procedure; create PROCEDURE my_procedure () BEGIN declare my_sqll varchar (500); set my_sqll = 'select * from aa_list '; set @ ms = my_sqll; PREPARE s1 from @ ms; EXECUTE s1; deallocate prepare s1; end;
In MySQL, how does one write SQL statements to call stored procedures?
Call sp_add ();
Is there a problem with the process you defined, and the returned results are not pointed out?
Like me:
Create procedure sp_add (a int, B int, out c int)
Begin
Set c = a + B;
End;
Call process:
Call sp_add (1, 2, @ );
Select @;
How can I write multiple dynamic SQL statements in the mysql stored procedure and call the value of the first dynamic statement for the Second Dynamic statement?
Declare @ d1 datetime
Set @ d1 = '2017-12-31'
Select dateadd (year,-1, @ d1) as date of the same day of the previous year