Plain SQL and PL/SQL program : Begin End Block « PL SQL « Oracle PL / SQL






Plain SQL and PL/SQL program

    

SQL>
SQL>
SQL> CREATE TABLE myTable(
  2      e INTEGER,
  3      f INTEGER
  4  );

Table created.

SQL>
SQL>
SQL>
SQL> DELETE FROM myTable;

0 rows deleted.

SQL> INSERT INTO myTable VALUES(1, 3);

1 row created.

SQL> INSERT INTO myTable VALUES(2, 4);

1 row created.

SQL>
SQL> /* Above is plain SQL; below is the PL/SQL program. */
SQL> DECLARE
  2      a NUMBER;
  3      b NUMBER;
  4  BEGIN
  5      SELECT e,f INTO a,b FROM myTable WHERE e > 1;
  6      INSERT INTO myTable VALUES(b,a);
  7  END;
  8  /

PL/SQL procedure successfully completed.

SQL> drop table myTable;

Table dropped.

SQL>

   
    
    
    
  








Related examples in the same category

1.Three sections - declarative, executable, and exception.
2.An example of an anonymous block
3.Block-Based Development
4.The PL/SQL Block
5.Block Nesting
6.The executable section needs at least one line of code to be valid.
7.Five level nested statement
8.no executable code
9.Building Blocks of PL/SQL
10.A Nested Block Example
11.Block with name
12.Outer Block name and inner block name
13.This script demonstrates the structure of a block
14.Nested block