Skip navigation links

MySQL Forums :: Stored Procedures :: Undeclared variable using SELECT ... INTO in dynamic SQL


Advanced Search

Undeclared variable using SELECT ... INTO in dynamic SQL
Posted by: Carsten Klotz ()
Date: August 29, 2011 08:41AM

Hi,

I have the following procedure:

drop procedure if exists test;

delimiter $$

create procedure test ()
begin
	declare table_conflicts int default 0;
	set @sql = concat('select count(*) into table_conflicts from user where id = 1;');
	prepare stmt from @sql;
	execute stmt;
end;

$$

delimiter ;
    
CALL test();

The call statement brings "Undeclared variable: table_conflicts". SELECT ... INTO is not supported for functions but for procedures, so I'm a little bit confused about this error. Anybody can help me ?

Thanx in advance !

Options: ReplyQuote


Subject Views Written By Posted
Undeclared variable using SELECT ... INTO in dynamic SQL 4177 Carsten Klotz 08/29/2011 08:41AM
Re: Undeclared variable using SELECT ... INTO in dynamic SQL 1438 Peter Brawley 08/30/2011 08:02AM
Re: Undeclared variable using SELECT ... INTO in dynamic SQL 1155 Carsten Klotz 09/14/2011 02:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.