Oracle® Database PL/SQL Language Reference 11g Release 2 (11.2) Part Number E10472-02 |
|
|
View PDF |
The block, which groups related declarations and statements, is the basic unit of a PL/SQL source program. It has an optional declarative part, a required executable part, and an optional exception-handling part. Declarations are local to the block and cease to exist when the block completes execution. Blocks can be nested.
An anonymous block is an executable statement.
Topics:
Syntax
plsql_block ::=
See body ::=.
declare_section ::=
See item_list_2 ::=.
item_list_1 ::=
See:
item_list_2 ::=
See:
type_definition ::=
See:
subtype_definition ::=
item_declaration ::=
See:
pragma ::=
See:
body ::=
statement ::=
See:
procedure_call ::=
sql_statement ::=
Semantics
assignment_statement
base_type
The base type of the subtype that you are defining. The base type can be either a predefined PL/SQL scalar data type (or subtype) or an existing user-defined subtype. For information about predefined scalar data types, see "Predefined PL/SQL Scalar Data Types and Subtypes". For information about user-defined subtypes, see "User-Defined PL/SQL Subtypes".
basic_loop_statement
BEGIN
Starts the executable part of the block, which contains executable statements.
case_statement
See "CASE Statement".
collection_method_call
A call to one of these collection methods, which are procedures:
DELETE
EXTEND
TRIM
For syntax, see "Collection Method Call".
continue_statement
See "CONTINUE Statement".
close_statement
See "CLOSE Statement".
commit_statement
SQL COMMIT
statement. For syntax, see Oracle Database SQL Language Reference.
constraint
The constraint on the base type of the subtype that you are defining.
Restriction on constraint Do not specify constraint
if the base type cannot specify either a maximum size or a precision and scale.
cursor_for_loop_statement
See "Cursor FOR LOOP Statement".
DECLARE
Starts the declarative part of the block, which contains local declarations. Local declarations exist only in the current block and its sub-blocks and are not visible to enclosing blocks.
delete_statement
SQL DELETE
statement. For syntax, see Oracle Database SQL Language Reference. See also "DELETE Statement Extension".
END
Ends the block.
EXCEPTION
Starts the exception-handling part of the block. When an exception is raised, normal execution of the block stops and control transfers to the appropriate exception_handler
. After the exception handler completes, execution resumes with the statement following the block. For more information about exception-handling, see Chapter 11, "PL/SQL Error Handling."
exception_handler
See "Exception Handler".
execute_immediate_statement
See "EXECUTE IMMEDIATE Statement".
exit_statement
See "EXIT Statement".
fetch_statement
See "FETCH Statement".
for_loop_statement
See "FOR LOOP Statement".
forall_statement
See "FORALL Statement".
goto_statement
See "GOTO Statement".
if_statement
See "IF Statement".
insert_statement
SQL INSERT
statement. For syntax, see Oracle Database SQL Language Reference. See also "INSERT Statement Extension".
label
An undeclared identifier. If a block or statement has multiple labels, they must be unique for that block or statement.
lock_table_statement
SQL LOCK
TABLE
statement. For syntax, see Oracle Database SQL Language Reference.
name
The name of the block to which END
applies—a label
, function_name
, procedure_name
, or package_name
.
null_statement
See "NULL Statement".
open_statement
See "OPEN Statement".
open_for_statement
See "OPEN FOR Statement".
( parameter [, parameter ]... )
List of actual parameters for the procedure being called. The data type of each actual parameter must be compatible with the data type of the corresponding formal parameter (see Table 3-10, "Possible Implicit PL/SQL Data Type Conversions"). If the procedure specifies an initial value for a parameter, you can omit that parameter from the parameter list.
If the procedure has no parameters, or specifies an initial value for every parameter, you can either omit the parameter list or specify an empty parameter list.
raise_statement
See "RAISE Statement".
return_statement
See "RETURN Statement".
rollback_statement
SQL ROLLBACK
statement. For syntax, see Oracle Database SQL Language Reference.
savepoint_statement
SQL SAVEPOINT
statement. For syntax, see Oracle Database SQL Language Reference.
select_into_statement
PL/SQL SELECT
INTO
statement. For syntax, see "SELECT INTO Statement".
set_transaction_statement
SQL SET
TRANSACTION
statement. For syntax, see Oracle Database SQL Language Reference.
subtype_name
The name of the user-defined subtype that you are defining. For information about user-defined subtypes, see "User-Defined PL/SQL Subtypes".
update_statement
SQL UPDATE
statement. For syntax, see Oracle Database SQL Language Reference. See also "UPDATE Statement Extensions".
while_loop_statement
Examples
Related Topics
In this chapter:
See links in "Semantics".
In other chapters: