MySQL Forums
Forum List  »  Stored Procedures

Unable to declare a cursor in IF and ELSE block in MySQL. I am trying following.
Posted by: Vikas Kumawat
Date: May 10, 2016 12:45AM

CREATE PROCEDURE Test() BEGIN declare v_DEVICE_ID varchar(200); declare v_tmp int(2) default 1; IF v_tmp = 1 then DECLARE cur_GET_ASAP_SERVERS CURSOR FOR SELECT IP FROM CONFIG_EXTERNAL_SYSTEM WHERE SYSTEM_NAME = 'ASAP' AND ACTIVE = 'Y'; else DECLARE cur_GET_ASAP_SERVERS CURSOR FOR SELECT IP FROM CONFIG_EXTERNAL_SYSTEM WHERE SYSTEM_NAME = 'TestMDBJndiName'; end if; open cur_GET_ASAP_SERVERS; read_loop: loop fetch cur_GET_ASAP_SERVERS into v_DEVICE_ID; select v_DEVICE_ID; end loop; close cur_GET_ASAP_SERVERS; END

Options: ReplyQuote


Subject
Views
Written By
Posted
Unable to declare a cursor in IF and ELSE block in MySQL. I am trying following.
3433
May 10, 2016 12:45AM


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.