简体   繁体   中英

MySQL - SELECT INTO within a Stored Procedure

We have a lot of stored procedures which have an OUT parameter which we are assigning a value to by using SELECT LAST_INSERTID() INTO p_AutoNumber .

After this, we need to perform another INSERT which also uses the value of this variable - however it doesn't appear to run correctly.

Does performing a SELECT INTO on an OUT parameter return from the procedure immedately? I am unable to find any information on this in the MySQL docs for SELECT INTO .

You can use the out-parameter within the procedure. Just check the syntax (and the function name):

Use syntax:

SELECT LAST_INSERT_ID() INTO p_AutoNumber;

Alternatively you can use syntax:

SET p_AutoNumber = LAST_INSERTID();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM