Hello,
I am in the process of writing a script and I'm having some difficulty with using 'GOTO' label. Once I hit return it just sits there. Here is the generic code:
set serveroutput on
DECLARE
var_num1 number(25) NOT NULL := 0;
sql_stmt varchar2(30);
BEGIN
<<BLOCK_CHECK>>
IF var_num1 > 3 THEN
dbms_output.put_line('STOPPROG');
ELSE
var_num1 := var_num1 + 1;
dbms_output.put_line(var_num1);
sql_stmt := 'BLOCK_' || var_num1;
dbms_output.put_line(sql_stmt);
END IF;
GOTO BLOCK_1; -- The idea here is that this will be replaced with running variable sql_stmt which will goto the current count of the block.
<<BLOCK_1>>
dbms_output.put_line('THIS IS BLOCK 1');
GOTO COMMON_BLOCK;
<<BLOCK_2>>
dbms_output.put_line('THIS IS BLOCK 2');
GOTO COMMON_BLOCK;
<<BLOCK_3>>
dbms_output.put_line('THIS IS BLOCK 2');
GOTO COMMON_BLOCK;
<<COMMON_BLOCK>>
dbms_output.put_line('THIS IS THE COMMON ACTION');
GOTO BLOCK_CHECK;
END;
/
Also, by no means am I great at plsql , so if their is a more logical way to accomplish what I am doing and it's not overly complicated, please feel free to share.
Thanks.
I am in the process of writing a script and I'm having some difficulty with using 'GOTO' label. Once I hit return it just sits there. Here is the generic code:
set serveroutput on
DECLARE
var_num1 number(25) NOT NULL := 0;
sql_stmt varchar2(30);
BEGIN
<<BLOCK_CHECK>>
IF var_num1 > 3 THEN
dbms_output.put_line('STOPPROG');
ELSE
var_num1 := var_num1 + 1;
dbms_output.put_line(var_num1);
sql_stmt := 'BLOCK_' || var_num1;
dbms_output.put_line(sql_stmt);
END IF;
GOTO BLOCK_1; -- The idea here is that this will be replaced with running variable sql_stmt which will goto the current count of the block.
<<BLOCK_1>>
dbms_output.put_line('THIS IS BLOCK 1');
GOTO COMMON_BLOCK;
<<BLOCK_2>>
dbms_output.put_line('THIS IS BLOCK 2');
GOTO COMMON_BLOCK;
<<BLOCK_3>>
dbms_output.put_line('THIS IS BLOCK 2');
GOTO COMMON_BLOCK;
<<COMMON_BLOCK>>
dbms_output.put_line('THIS IS THE COMMON ACTION');
GOTO BLOCK_CHECK;
END;
/
Also, by no means am I great at plsql , so if their is a more logical way to accomplish what I am doing and it's not overly complicated, please feel free to share.
Thanks.