stored procedures - MySQL user-defined variables losing value immediately? -
stored procedures - MySQL user-defined variables losing value immediately? -
so having issue mysql 5.5 drive me insane. have few nested stored procedures , 1 of them inserts info table , selects last_insert_id()
out-bound parameter. next stored procedure:
delimiter $$ create definer=`root`@`localhost` procedure `createnewsession`( in inputip varchar(15), in inputposttime bigint, in inputpostinterval bigint, in inputplatform varchar(45), out outsessionid int) begin insert mydb.session (ip, starttime, lastpost, platform) values (inputip, inputposttime - inputpostinterval, inputposttime, inputplatform); select last_insert_id() outsessionid; end;$$
now, if pass right parameters (ie: parameters have tested against insert statement , working) , phone call next right id back
call mydb.createnewsession('127.0.0.1', 1310062874228, 1310062894228, 'platform', @outvar); select last_insert_id();
however if phone call next returned blob
parameter ?
value.
call mydb.createnewsession('127.0.0.1', 1310062874228, 1310062894228, 'platform', @outvar); select @outvar;
why happening? stored procedure has been working month+ @ point , far know nil has changed db settings. why receiving other last_insert_id()
upon selecting outbound parameter stored procedure?
any help appreciated. going crazy on here...
edit
the error i'm getting when calling top-level stored procedure follows:
error code: 1264. out of range value adjusted column 'outsessionid' @ row 68
edit 2
here table structure
field type null key 'sessionid', 'int(11)', 'no', 'pri', null, 'auto_increment' 'ip', 'varchar(15)', 'no', '', null, '' 'starttime', 'bigint(20)', 'no', '', null, '' 'lastpost', 'bigint(20)', 'no', '', null, '' 'platform', 'varchar(45)', 'no', '', null, ''
edit 3
so after messing around more have found next queries when called select blob parameter value of '?'
set @tempvar = 25; select @tempvar;
shouldn't homecoming 25?
please try
set outsessionid := last_insert_id();
within proc instead of doing select.
mysql stored-procedures parameters
Comments
Post a Comment