MySQL Forums :: Stored Procedures :: Unable to declare a cursor in IF and ELSE block in MySQL. I am trying following.


Advanced Search

Re: Unable to declare a cursor in IF and ELSE block in MySQL. I am trying following.
Posted by: Peter Brawley ()
Date: May 10, 2016 11:11AM

You don't work with unformatted code like that, do you?

Then why not format it here for human readability?

A MySQL cursor must precede all non-declaratory code in its block. IF is code, therefore IF soandso THEN DECLARE ... is not supported.

You could get round this with IF soandso THEN BEGIN ..., but you would have to put a read loop inside the same IF block.

But the more interesting question is, why a cursor at all? why not just set @vttmp as desired then ...

select ip
from config_external_system
where system_name='TestMDBJndiName' or (@vtmp=1 and system_name = 'asap' and active = 'y') ;

Options: ReplyQuote


Subject Views Written By Posted
Unable to declare a cursor in IF and ELSE block in MySQL. I am trying following. 2166 Vikas Kumawat 05/10/2016 12:45AM
Re: Unable to declare a cursor in IF and ELSE block in MySQL. I am trying following. 386 Peter Brawley 05/10/2016 11:11AM


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.