The PL/SQL Block : Begin End Block « PL SQL « Oracle PL / SQL






The PL/SQL Block

  
SQL>
SQL> set serveroutput on
SQL> declare
  2    myNumber number := 1;
  3  begin
  4    myNumber := 1 + 1;
  5    dbms_output.put_line( '1 + 1 = ' || to_char( myNumber ) || '!' );
  6  exception
  7    when others then
  8      dbms_output.put_line( 'We encountered an exception!' );
  9  end;
 10  /
1 + 1 = 2!

PL/SQL procedure successfully completed.

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.Block Nesting
5.The executable section needs at least one line of code to be valid.
6.Five level nested statement
7.no executable code
8.Building Blocks of PL/SQL
9.A Nested Block Example
10.Block with name
11.Outer Block name and inner block name
12.This script demonstrates the structure of a block
13.Nested block
14.Plain SQL and PL/SQL program