SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-4
Considerations for ALLOCATE CURSOR
CURSOR statement is functionally equivalent to the DECLARE CURSOR
statement.
Considerations for ALLOCATE CURSOR
Cursor Names
You cannot have more than one cursor allocated with the same name within the same
scope. For example, this sequence from a C program is not valid:
strcpy(extcur1,"CURSOR1");
EXEC SQL ALLOCATE :extcur1 CURSOR FOR :stmt;
strcpy(extcur2,"CURSOR1");
EXEC SQL ALLOCATE :extcur2 CURSOR FOR :stmt;
The second ALLOCATE CURSOR fails because CURSOR1 has already been
allocated.
Using Extended Dynamic Cursors
The name of an extended dynamic cursor is not known until run time. Therefore, you
can allocate new cursors as you need them.
However, you must have prepared a cursor specification and stored the name of the
prepared cursor specification in a host variable before ALLOCATE CURSOR executes.
WITH HOLD
You can use holdable cursors only for SELECT statements that use the
Publish/Subscribe stream access mode or an embedded UPDATE or embedded
DELETE.
C Examples of ALLOCATE CURSOR
This example uses extended cursor and statement names in the PREPARE and
ALLOCATE CURSOR statements:
...
scanf("%s", in_curspec);
...
EXEC SQL PREPARE :curspec FROM :in_curspec;
...
EXEC SQL ALLOCATE :extcur CURSOR FOR :curspec;
...
Pub/Sub