MySQL Forums
Forum List  »  Stored Procedures

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
6949
August 29, 2011 08:41AM


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.