Oracle7 Server SQL Reference

Contents Index Home Previous Next

EXECUTE (Anonymous PL/SQL Blocks) (Embedded SQL)

Purpose

To embed an anonymous PL/SQL block into an Oracle Precompiler program.

Prerequisites

None.

Syntax

Keywords and Parameters

AT

identifies the database on which the PL/SQL block is executed. The database can be identified by either:

db_name is a database identifier declared in a previous DECLARE DATABASE statement.

:host_variable is a host variable whose value is a previously declared db_name.

If you omit this clause, the PL/SQL block is executed on your default database.

pl/sql_block

For information on PL/SQL, including how to write PL/SQL blocks, see PL/SQL User's Guide and Reference.

END-EXEC

must appear after the embedded PL/SQL block, regardless of which programming language your Oracle Precompiler program uses. Of course, the keyword END-EXEC must be followed by the embedded SQL statement terminator for the specific language.

Usage Notes

Since the Oracle Precompilers treat an embedded PL/SQL block like a single embedded SQL statement, you can embed a PL/SQL block anywhere in an Oracle Precompiler program that you can embed a SQL statement. For more information on embedding PL/SQL blocks in Oracle Precompiler programs, see Programmer's Guide to the Oracle Precompilers.

Example

Placing this EXECUTE statement in an Oracle Precompiler program embeds a PL/SQL block in the program:

EXEC SQL EXECUTE 
	BEGIN 
		SELECT ename, job, sal 
			INTO :emp_name:ind_name, :job_title, :salary 
			FROM emp 
			WHERE empno = :emp_number; 
		IF :emp_name:ind_name IS NULL 
		   THEN RAISE name_missing; 
		END IF; 
	END; 
END-EXEC 

Related Topics

EXECUTE command [*] EXECUTE IMMEDIATE embedded SQL command [*]


Contents Index Home Previous Next