Oracle7 Server SQL Reference

Contents Index Home Previous Next

ALLOCATE (Embedded SQL)

Purpose

To allocate a cursor variable to be referenced in a PL/SQL block.

Prerequisites

You must define the cursor variable as a SQL_CURSOR pseudotype before allocating the cursor variable.

Syntax

Keywords and Parameters

cursor_variable

is the cursor variable to be allocated.

Usage Notes

Whereas a cursor is static, a cursor variable is dynamic because it is not tied to a specific query. You can open a cursor variable for any type-compatible query.

For more information on this command, see PL/SQL User's Guide and Reference and Programmer's Guide to the Oracle Precompilers.

Example

This partial example illustrates the use of the ALLOCATE command in a Pro*C embedded SQL program:

EXEC SQL BEGIN DECLARE SECTION; 
	SQL_CURSOR emp_cv; 
	struct{ ... } emp_rec; 
EXEC SQL END DECLARE SECTION; 
EXEC SQL ALLOCATE emp_cursor; 
EXEC SQL EXECUTE 
	BEGIN
 		OPEN :emp_cv FOR SELECT * FROM emp; 
	END; 
END-EXEC; 
for (;;) 
{EXEC SQL FETCH :emp_cv INTO emp_rec; }

Related Topics

CLOSE command [*] EXECUTE command [*] FETCH command [*]


Contents Index Home Previous Next