MySQL Forums
Forum List  »  Stored Procedures

Re: Stored procedure, dinamic query and handle
Posted by: Rodrigo GP
Date: May 30, 2012 05:18AM

Thanks Rick, but it’s not my error. I redefine my question, what is the best solution if my first query doesn’t have results; it will perform my second query which is less restrictive.

Please to forget the code it’s only an example. Querys works fine but the handle doesn’t work.

I’m trying with cursors, simple querys and execute.

It's an example simpler, which doesn’t work too.

BEGIN

DECLARE noResult INT DEFAULT 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET noResult = 1;


SELECT * from table1 where id = ''; /*No results*/
if noResult = 1 then /*execute first query but don't catch the exception*/
SELECT * from table1 where id = '1';
END IF;
END;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Stored procedure, dinamic query and handle
1088
May 30, 2012 05:18AM


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.