Re: declaration & subblocks -
12-21-2004
, 11:57 AM
I'm not sure if I understand your problems (you may try to explain it in Polish).
Example:
DECLARE
x NUMBER(38,0) := 1;
v NUMBER(38,0) := 2;
BEGIN
-- point one
dbms_output.put_line( 'outer x: ' || NVL( TO_CHAR( x ), 'NULL' ) );
dbms_output.put_line( 'outer v: ' || NVL( TO_CHAR( v ), 'NULL' ) );
DECLARE
x NUMBER(38,0);
z NUMBER(38,0) := 4;
BEGIN
-- point two
x := 3;
dbms_output.put_line( 'inner x: ' || NVL( TO_CHAR( x ), 'NULL' ) );
dbms_output.put_line( 'outer v: ' || NVL( TO_CHAR( v ), 'NULL' ) );
dbms_output.put_line( 'inner z: ' || NVL( TO_CHAR( z ), 'NULL' ) );
END;
-- point one
dbms_output.put_line( 'outer x: ' || NVL( TO_CHAR( x ), 'NULL' ) );
dbms_output.put_line( 'outer v: ' || NVL( TO_CHAR( v ), 'NULL' ) );
END;
The code above works OK with no errors and shows some details.
You can use variable "x" declared in outer declaration in point one and three
(it's hidden in point two by a variable with same name) and "v" in point one,
two and three. Variables declared in inner declaration: "x" (different variable
than in point one and three) and "z" can be used in point two.
You can't use "z" in point one or three cause it's not declared in this context.
Hilarion |