SQL>
SQL> CREATE TABLE MyTable (
2 num_col NUMBER,
3 char_col VARCHAR2(60)
4 );
Table created.
SQL>
SQL>
SQL> DECLARE
2 v_Num1 NUMBER := 1;
3 v_Num2 NUMBER := 2;
4 v_String1 VARCHAR2(50) := 'Hello World!';
5 v_String2 VARCHAR2(50) := '-- This message brought to you by PL/SQL!';
6 v_OutputStr VARCHAR2(50);
7 BEGIN
8 INSERT INTO MyTable (num_col, char_col) VALUES (v_Num1, v_String1);
9 INSERT INTO MyTable (num_col, char_col) VALUES (v_Num2, v_String2);
10
11 SELECT char_col INTO v_OutputStr FROM MyTable WHERE num_col = v_Num1;
12 DBMS_OUTPUT.PUT_LINE(v_OutputStr);
13
14 SELECT char_col INTO v_OutputStr FROM MyTable WHERE num_col = v_Num2;
15 DBMS_OUTPUT.PUT_LINE(v_OutputStr);
16 ROLLBACK;
17 END;
18 /
Hello World!
-- This message brought to you by PL/SQL!
PL/SQL procedure successfully completed.
SQL>
SQL> drop table MyTable;
Table dropped.
SQL>
|