MySQL Forums
Forum List  »  Stored Procedures

Simple cursor in Oracle
Posted by: Info question
Date: December 04, 2015 02:23PM

Hello MySQL Gurus,

In Oracle, a simple declare statement can written this way.

DECLARE
v_id temp.unid%TYPE;
v_item_number :=1;

CURSOR C1 IS
select id from temp
where item_number is null;

CURSOR C2 IS
select id from temp
where item_number is not null;

Begin
Open C1;
loop
fetch C1 INTO v_id;
If C1%isFOUND
Then
update Temp
set item_number =v_item_number;
where id= v_id;
END IF;
Open C2;
loop
fetch C1 INTO v_id;
If C1%isFOUND
Then
update Temp
set item_number = item_number +1;
where id= v_id;
END IF;
END LOOP;
COMMIT;
END;
/

What is equivalent in MySQL Language ? -- I appreciate your response.

Options: ReplyQuote


Subject
Views
Written By
Posted
Simple cursor in Oracle
2315
December 04, 2015 02:23PM
815
December 04, 2015 04:40PM
714
December 07, 2015 11:23PM


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.