Philip Markwalder <[EMAIL PROTECTED]> wrote: > > I have a few questions concerning stored procedures: > > 1. If I create a stored procedure (like the one below), why does the > returned values not change, though in the stored prcoedure the id has > been generated? > 2. Is there any better way to hand over multiple values and how can I > unset global varaibles? > > thx > > Philip > > > > delimiter | > drop procedure if exists create_obj | > > CREATE PROCEDURE `create_obj` ( > out success int(2), > out success_msg varchar(255), > out obj_id int(10), > inout obj_hostname varchar(255), > inout obj_type varchar(25) > ) LANGUAGE SQL not deterministic > begin > declare done int default 0; > DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; > insert into idsdb.obj values (NULL,obj_hostname,obj_type); > if ! done then > select LAST_INSERT_ID() into obj_id; > set success = 1; > set success_msg = concat("added host with object id: ", obj_id); > else > set success = -1; > set success_msg="Could not insert new object"; > end if; > end | > > call create_obj(@a,@b,@id,'test1','ddd')| > select @a,@b,@id | >
LAST_INSERT_ID() returns wrong result inside stored procedure. I entered simple test case to the bug database: http://bugs.mysql.com/bug.php?id=3117 Thanks! -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Victoria Reznichenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]