Collections:
Scope of Local Variables in Oracle
What Is the Scope of a Local Variable in Oracle?
✍: FYIcenter.com
The scope of a variable can be described with these rules:
Here is a sample script to show you those rules:
SQL> CREATE OR REPLACE PROCEDURE PARENT AS
2 X CHAR(10) := 'FYI';
3 Y NUMBER := 999999.00;
4 PROCEDURE CHILD AS
5 Y CHAR(10) := 'CENTER';
6 Z NUMBER := -1;
7 BEGIN
8 DBMS_OUTPUT.PUT_LINE('X = ' || X); -- X from PARENT
9 DBMS_OUTPUT.PUT_LINE('Y = ' || Y); -- Y from CHILD
10 DBMS_OUTPUT.PUT_LINE('Z = ' || TO_CHAR(Z));
11 END;
12 BEGIN
13 DBMS_OUTPUT.PUT_LINE('X = ' || X); -- X from PARENT
14 DBMS_OUTPUT.PUT_LINE('Y = ' || TO_CHAR(Y));
15 -- DBMS_OUTPUT.PUT_LINE('Z = ' || TO_CHAR(Z));
16 CHILD;
17 END;
18 /
SQL> EXECUTE PARENT;
X = FYI
Y = 999999
X = FYI
Y = CENTER
Z = -1
⇒ Working with Database Objects in Oracle PL/SQL
⇐ What Are Named Parameters in Oracle
2018-10-13, 2954🔥, 0💬
Popular Posts:
Where to find answers to frequently asked questions I am new to Oracle database. Here is a list of f...
How To View Data Files in the Current Database in Oracle? If you want to get a list of all tablespac...
How to check if two JSON values have overlaps using the JSON_OVERLAPS() function? JSON_OVERLAPS(json...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To End a Stored Procedure Properly in SQL Server Transact-SQL? Where the end of the "CREATE PROC...