O'Reilly logo

Oracle SQL: the Essential Reference by David C. Kreines

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.4. Execution Section

The execution section of a PL/SQL block is the only required section. It contains the PL/SQL code that actually performs some action; the exception section also performs an action, but only after being triggered by an action in the execution section. The general syntax of the execution section is:

BEGIN
   {assignment_statement    |
     proc_call    |
     control_statement    |
     PL/SQL_block    |
     SQL
				
				};
   [{assignment_statement    |
     proc_call    |
     control_statement    |
     PL/SQL_block    |
     SQL
    }; . . . ]
END;

7.4.1. Assignment Statements

An assignment statement provides a value to a PL/SQL variable. The general syntax of a PL/SQL assignment statement is:

					variable := expression;

Keywords

variable

Any previously declared PL/SQL variable.

:=

The PL/SQL symbol for assignment. Note the difference between := and the typical = used in many other languages.

expression

Any valid PL/SQL expression.

7.4.2. Expressions

PL/SQL expressions consist of one or more PL/SQL variables optionally combined with one or more PL/SQL operators. In PL/SQL, an expression may appear in one of the following locations:

  • On the right side of an assignment statement

  • As part of a control statement

  • As part of a SQL statement

The PL/SQL operators that may be used in expressions, along with their relative precedence (where 1 is the highest) are listed in Table 7-4.

Table 7-4. PL/SQL Operators
Operator Description Type Precedence
|| Concatenate two character strings Character 4
+ Addition Numeric 4
+ Unary identity ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required