database - MySql 5.5.40 stored procedure @@Identity -
i've problem in stored procedure when try ovverriding variable value of @@identity of last operation. i'll write example:
declare out_result bigint(20); set out_result = -1; update tablename set name = "pippo" id = 12; select @@identity out_result; -- here works great , out_result value 12 if out_result > 0 update othetablename set address = "route 666" id = 37; select @@identity out_result; end if;
i expect if first operation successfull, variable out_result greater 0 , code second update , it's so. after second update (but may delete example) expect out_result variable take value of second update (in example out_result = 37) it's not so. here out_result still equal 12. idea appreciated. thanks.
first of there no @@identity
in mysql
. must have mistaken , talking sql server
. coming case, if still getting out_result = 12
believe corresponding update
statement (as pointed below) didn't processed row because the condition where id = 37
didn't matched (or) have returned false
. can check , verify same using @@rowcount
system global variable.
update othetablename set address = "route 666" id = 37;
Comments
Post a Comment