MySQL Forums
Forum List  »  Stored Procedures

Re: Retrieving results from a select in a procedure
Posted by: Eric Walker
Date: October 12, 2005 11:50PM

I finally found the way out of it :

DELIMITER $$

DROP PROCEDURE IF EXISTS `waldataservers`.`StockQuots`$$
CREATE PROCEDURE waldataservers.StockQuots (aWalident integer)
BEGIN
DECLARE a integer;
DECLARE GzStr char(40);
select GeoZone into a from Dbstocks where (WalIdent=aWalident);
select Name into GzStr from DbstocksCat where (Ident=a);
set GzStr =Concat('select * from qticks_',GzStr,' where (DateIdx>=200510121600000000)');
set @a = GzStr;
PREPARE test from @a;
execute Test;
deallocate prepare test;
END$$

DELIMITER ;

comments :

For the prepare statement I had to use a "global variable" @a, I couldn't get it to work with a "local" variable :
"Prepare Test from GzStr"; will allways return a syntax error ?

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Retrieving results from a select in a procedure
1845
October 12, 2005 11:50PM


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.