I'm calling a stored procedure that inserts a new row, but if the unique name exists, just updates a numerator and SHOULD return the updated id.
CREATE PROCEDURE bear_crm.insert_subject(in_subject_name varchar(100), OUT out_subject_id int)
BEGIN
DECLARE t_update_id int;
set t_update_id := 0;
INSERT INTO t_subject (subject_name) VALUES (in_subject_name) ON DUPLICATE KEY
UPDATE pop_index = COALESCE(pop_index,0)+1, subject_id=LAST_INSERT_ID(subject_id);
set out_subject_id := LAST_INSERT_ID();
insert into testing(aa) values(out_subject_id); # just a test to see values
END//
The numerator is updated after the second attempt to insert the same value. the "testing" table get the expected updated subject id, yet my out parameter in the Python side is not effected:
v_id = -999
v_args = ['test subject', v_id]
mycursor.callproc('insert_subject', v_args)
print('id is:', v_args[1])
v_id
remains -999