0

Working with MySql 8.0.32, I've created this stored procedure:

CREATE DEFINER=`root`@`%` PROCEDURE `spTimersCreate`(IN paction bigint, IN preseller bigint, IN pinterval bigint)
BEGIN

    INSERT INTO timers 
        (action, reseller, `interval`, isactive, isdeleted) 
    VALUES (paction, preseller, pinterval, 0, 0);

    SELECT * 
    FROM timers t 
    WHERE t.id = LAST_INSERT_ID();

END

I execute this procedure with the following query:

SET @paction = 1;
SET @preseller = 1;
SET @pinterval = 1;
CALL spTimersCreate(@paction, @preseller, @pinterval);

On the first attempt I get the newly insert record from table timers returned correctly. However, on any subsequent attempts I get no record returned. Nevertheless, a new record is create correctly in table timers.

For debegugging I changed the stored procedure to show the LAST_INSERT_ID():

PROCEDURE spTimersCreate2 (IN paction bigint, IN preseller bigint, IN pinterval bigint)
BEGIN

    INSERT INTO timers (action, reseller, `interval`, isactive, isdeleted)
      VALUES (paction, preseller, pinterval, 0, 0);

    SELECT LAST_INSERT_ID();

END

Executing this version of the procedure, I get a correct LAST_INSERT_ID() each and every time.

I'm guessing I'm missing something obvious. Can anybody help? Thanks!

PdxRene
  • 1
  • 1

0 Answers0