A labeled block. : Label « PL SQL « Oracle PL / SQL

Home
Oracle PL / SQL
1.Aggregate Functions
2.Analytical Functions
3.Char Functions
4.Constraints
5.Conversion Functions
6.Cursor
7.Data Type
8.Date Timezone
9.Hierarchical Query
10.Index
11.Insert Delete Update
12.Large Objects
13.Numeric Math Functions
14.Object Oriented Database
15.PL SQL
16.Regular Expressions
17.Report Column Page
18.Result Set
19.Select Query
20.Sequence
21.SQL Plus
22.Stored Procedure Function
23.Subquery
24.System Packages
25.System Tables Views
26.Table
27.Table Joins
28.Trigger
29.User Previliege
30.View
31.XML
Oracle PL / SQL » PL SQL » Label 
A labeled block.
   
SQL>
SQL>
SQL> CREATE TABLE MyTable (
  2    num_col    NUMBER,
  3    char_col   VARCHAR2(60)
  4    );

Table created.

SQL>
SQL>
SQL> <<l_InsertIntoTemp>>
  2  DECLARE
  3    v_Num1      NUMBER := 1;
  4    v_Num2      NUMBER := 2;
  5    v_String1   VARCHAR2(50:= 'Hello World!';
  6    v_String2   VARCHAR2(50:= '-- This message brought to you by PL/SQL!';
  7    v_OutputStr VARCHAR2(50);
  8  BEGIN
  9    INSERT INTO MyTable (num_col, char_col)
 10      VALUES (v_Num1, v_String1);
 11    INSERT INTO MyTable (num_col, char_col)
 12      VALUES (v_Num2, v_String2);
 13
 14    SELECT char_col
 15      INTO v_OutputStr
 16     FROM MyTable
 17     WHERE num_col = v_Num1;
 18    DBMS_OUTPUT.PUT_LINE(v_OutputStr);
 19
 20    SELECT char_col
 21      INTO v_OutputStr
 22     FROM MyTable
 23     WHERE num_col = v_Num2;
 24    DBMS_OUTPUT.PUT_LINE(v_OutputStr);
 25
 26    ROLLBACK;
 27
 28  END l_InsertIntoTemp;
 29  /
Hello World!
-- This message brought to you by PL/SQL!

PL/SQL procedure successfully completed.

SQL>
SQL> drop table MyTable;

Table dropped.

SQL>

   
    
  
Related examples in the same category
1.Using labels with loops
2.Changing labeled loop execution with EXIT statements
3.Use label to mark outer loop and inner loop
4.Loop with a Label
5.Block with label
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.