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