SQL/MX 2.x Reference Manual (G06.24+, H06.03+)
Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual—523725-004
3-3
ALLOCATE CURSOR Statement
ALLOCATE CURSOR Statement
Considerations for ALLOCATE CURSOR
C Examples of ALLOCATE CURSOR
COBOL Examples of ALLOCATE CURSOR
The ALLOCATE CURSOR statement is a dynamic SQL statement used to define an 
extended cursor based on a statement already prepared for the cursor specification. It 
allows applications to dynamically create an unlimited number of cursors.
Use ALLOCATE CURSOR only in embedded SQL programs in C or COBOL.
ext-cursor-name
is a value-specification—a host variable with character data type. When 
ALLOCATE CURSOR executes, the content of the host variable gives the name of 
the cursor. The maximum length of a cursor name is 128 characters.
WITH HOLD | WITHOUT HOLD
specifies whether an application keeps cursors open (WITH) across transaction 
boundaries. The default is WITHOUT HOLD. You can use the WITH HOLD clause 
only with Publish/Subscribe. 
GLOBAL | LOCAL
specifies scope. The default setting is LOCAL. The scope of a GLOBAL cursor or 
statement name is the SQL session. The scope of a LOCAL cursor or statement 
name is the module or compilation unit in which ALLOCATE CURSOR appears.
ext-statement-name
is a value-specification—a host variable with character data type. When 
ALLOCATE CURSOR executes, the content of the host variable must identify a 
statement previously prepared within the scope of ALLOCATE CURSOR. The 
prepared statement must be a cursor specification.
When host variables are used for the ext-cursor-name and the ext-
statement-name in the DECLARE CURSOR statement, the ALLOCATE 
ALLOCATE ext-cursor-name 
CURSOR [WITH HOLD | WITHOUT HOLD] 
 FOR ext-statement-name 
ext-cursor-name is:
 [GLOBAL | LOCAL] value-specification 
ext-statement-name is:
 [GLOBAL | LOCAL] value-specification 
C/COBOL
Pub/Sub
Pub/Sub










