Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DECLARE Cursor myCursor IS ... Problem

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Using 8i... My stor proc requires alternative Cursor declarations based on the value of a variable e.g.
'
'
if inp_var = 1 then
DECLARE CURSOR myCur IS
Select....From TableA Where ...;
elsif inp_var = 2 then
DECLARE CURSOR myCur IS
Select....From TableB Where ...;
elsif inp_var = 3 then
DECLARE CURSOR myCur IS
Select....From TableC Where ...;
End if;
'
'

I am having problems embedding a DECLARE CURSOR
in an IF...ELSIF statement. Any ideas, anyone?

 
You can't do it the way you are trying to. The only way to do this is with a REF CURSOR e.g.

declare
type t_cursor is ref cursor;
v_curs t_cursor;
begin
if ...
open v_curs for 'select 1 from dual';
elsif
open v_curs for 'select 2 from dual';
else
open v_curs for 'select 3 from dual';
end if;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top