1-8. Referencing a Block of Code
Problem
You want to reference a block of code within a code segment later in your program.
Solution
Assign a label to the block of code that you want to reference. A PL/SQL label consists of a unique identifier surrounded by double angle brackets. For example, in the following code, you see that the block has been labeled dept_block
:
<<dept_block>>
DECLARE
dept_name varchar2(30);
BEGIN
SELECT department_name
INTO dept_name
FROM departments
WHERE department_id = 230;
DBMS_OUTPUT.PUT_LINE(dept_name);
END;
This code block can now be referenced by the label dept_block
. See Recipe 1-9 for one example of code block labels.
How It Works
Any block of code can be labeled with a unique identifier for readability ...
Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.