Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Can I use "GOTO" with variables in PL/SQL?
nothing is "wrong" - it works fine and I'm already implementing it . . . was
just looking for alternatives - I like to look at all the options available
bill
-----Original Message-----
Sent: Friday, December 06, 2002 1:59 PM
To: Multiple recipients of list ORACLE-L
The pl/sql block gets submitted for execution only after the variables get replaced with their values.
So for different values you are submitting different code.
What is wrong in moving the different actions to inside the if/then/else clause?
Waleed
-----Original Message-----
Sent: Friday, December 06, 2002 12:05 PM
To: Multiple recipients of list ORACLE-L
OK so I've opened an Enhancement Request on this . . . and in the meantime I discovered that I CAN use SQL*Plus substition variables!
The following DOES work:
accept i_label prompt 'Enter CR '
declare
v_cr number := &&i_label;
v_crlabel varchar2(30) := 'CR' || to_char(v_cr);
begin
dbms_output.put_line (v_crlabel);
if v_cr = 50 then
goto CR&&i_label;
else
goto endrun;
end if;
<<CR50>>
dbms_output.put_line('Successfully went to CR50');
<<ENDRUN>>
NULL;
dbms_output.put_line('Went to END');
end;
/
-----Original Message-----
Sent: Friday, December 06, 2002 11:42 AM
To: 'ORACLE-L_at_fatcity.com'
Cc: 'Bill.Magaliff_at_lendware.com'
Bill,
Sadly, I don't think this is possible. The PL/SQL compiler is just not that dynamic.
Pretty cooleo idea, though.
Tom Mercadante
Oracle Certified Professional
-----Original Message-----
Sent: Friday, December 06, 2002 11:19 AM
To: Multiple recipients of list ORACLE-L
Good day, all:
I'm writing a script where the user can specify at run-time if they want to run the entire script or just one numbered piece. One way I thought of implementing this is pasted below, but the line "goto v_crlabel" is not recognized - evidently the PL/SQL engine is not substituting in the value for the variable.
Does anyone know if this is possible? If not, I can just prefix each block by an if..then statement to test for the value in v_cr . . . but I thought it could be cool to try it this way.
Thanks
bill
accept i_cr prompt 'Enter CR to run: '
declare
v_cr number := &&i_cr;
v_crlabel varchar2(30) := 'CR' || to_char(v_cr);
begin
if v_cr is not null then
goto v_crlabel;
else
goto endrun;
end if;
<<CR5>>
dbms_output.put_line('Successfully went to CR5');
goto endrun;
<<CR6>>
dbms_output.put_line('Successfully went to CR6');
goto endrun;
<<CR7>>
dbms_output.put_line('Successfully went to CR7');
goto endrun;
<<ENDRUN>>
NULL;
dbms_output.put_line('Went to ENDRUN');
end;
/
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Magaliff, Bill
INET: Bill.Magaliff_at_lendware.com
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Dec 06 2002 - 14:39:21 CST