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

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-73
C Examples of OPEN
USING Clause
If the cursor specification uses dynamic input parameters, you must provide a USING
clause for either a list of arguments or an SQL descriptor area. This requirement is the
same as that for providing a USING clause for an EXECUTE statement that executes a
prepared statement with dynamic input parameters. See EXECUTE Statement on
page 2-131.
C Examples of OPEN
Declare and open a cursor, using FETCH to retrieve data, then closing the cursor:
EXEC SQL DECLARE cursor1 CURSOR FOR
SELECT COL1, COL2, COL3
FROM PARTS
WHERE COL1 >= :hostvar
ORDER BY COL1
READ UNCOMMITTED ACCESS;
...
EXEC SQL OPEN cursor1;
...
EXEC SQL FETCH cursor1
INTO :hostvar1, :hostvar2, :hostvar3;
...
EXEC SQL CLOSE cursor1;
This example uses extended cursor and statement names in the PREPARE,
ALLOCATE CURSOR, and OPEN statements:
...
scanf("%s", in_curspec);
...
EXEC SQL PREPARE :curspec FROM :in_curspec;
...
EXEC SQL ALLOCATE :extcur CURSOR FOR :curspec;
...
EXEC SQL OPEN :extcur;
...