Home » SQL & PL/SQL » SQL & PL/SQL » Bind Variable Name to Cursor
Bind Variable Name to Cursor [message #293713] Mon, 14 January 2008 13:43 Go to next message
bmandrews81
Messages: 4
Registered: January 2008
Junior Member
I want to assign a variable name to be used as a cursor for use in a CASE or SWITCH or IF-THEN-ELSE statement.

My statement would look like:

CASE

WHEN ( a condition exists) THEN
variable_name := (SELECT ID FROM TABLE WHERE VALUE_1 = VALUE_2)

WHEN ( another condition exists) THEN
variable_name := (SELECT ID FROM TABLE2 WHERE VALUE_A = VALUE_Z)

END CASE;

-- Then use the variable name as a cursor in a FOR LOOP.
FOR rst IN variable_name LOOP
htp.prn(rst.ID);
END LOOP;

Can this be done?
Re: Bind Variable Name to Cursor [message #293715 is a reply to message #293713] Mon, 14 January 2008 14:06 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
when open variable_name for ...
when ...

Regards
Michel
Re: Bind Variable Name to Cursor [message #293717 is a reply to message #293715] Mon, 14 January 2008 14:31 Go to previous messageGo to next message
bmandrews81
Messages: 4
Registered: January 2008
Junior Member
Just to clarify so my example would look like
WHEN ( a condition exists) THEN
OPEN variable_name FOR (SELECT ID FROM TABLE WHERE VALUE_1 = VALUE_2)

Is that correct?
Re: Bind Variable Name to Cursor [message #293722 is a reply to message #293717] Mon, 14 January 2008 14:43 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes (assuming variable_name is of correct type and loop is modified as appropriate).

Regards
Michel

[Updated on: Mon, 14 January 2008 14:44]

Report message to a moderator

Re: Bind Variable Name to Cursor [message #293891 is a reply to message #293722] Tue, 15 January 2008 08:48 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
How many "No Message Body" will you post?
I already deleted 4.
If you have nothing to post don't post.

Regards
Michel
Re: Bind Variable Name to Cursor [message #294216 is a reply to message #293713] Wed, 16 January 2008 20:45 Go to previous message
bmandrews81
Messages: 4
Registered: January 2008
Junior Member
seems there was a server glich. Everytime I tried to post I got "page could not be displayed"

I did not realize it was actually posting a blank message.
Previous Topic: Looking for a proper search term
Next Topic: Date Range disection - Can it be Done???
Goto Forum:
  


Current Time: Sat Dec 10 20:52:19 CST 2016

Total time taken to generate the page: 0.09995 seconds