![]() | ![]() | Programming Guide |
Declares a named cursor for a DBMS SQL statement
DBMS [ WITH CONNECTIONconnection] DECLAREcursorCURSOR
FORSQLstatement
WITH CONNECTIONconnection- Name of connection to associate with the cursor. If the clause is not used, Prolifics opens the cursor on the default connection.
cursor- Name of cursor to be created.
SQLstatementSQLstatement to be performed when the cursor is executed.
Use
DBMS DECLARE CURSORto create or redeclare a named cursor.If the application has not already declared cursor, Prolifics allocates a new cursor structure and adds its name to the list of declared cursors.
If a structure already exists for cursor and the connection is the same, Prolifics reinitializes the structure. Reinitialization clears any information on
SELECTcolumns and binding parameters. It does not clear any attributes assigned to the cursor with the statements:
DBMS ALIAS
Prolifics uses these settings if the cursor is redeclared with a
SELECTstatement. It ignores the attributes if the cursor is redeclared with anINSERT,UPDATE, orDELETEstatement. To redeclare the cursor with a new (empty) structure, close the cursor withDBMS CLOSE CURSORbefore executing the new declaration.If a cursor is redeclared on another connection, Prolifics automatically closes the cursor and declares a new structure.
The cursor remains open until it is explicitly closed with the
DBMS CLOSE CURSORcommand. Closing a connection also closes all cursors on the connection.There are few restrictions on valid cursor names. However, avoid using any DBMS, JDB, or Prolifics keywords as a cursor name. Prolifics is case sensitive regarding cursor names; for example, it interprets cursor c1 as distinct from cursor C1.
For information on the format of parameters in the SQL statement, refer to Chapter 30, "Writing Information to the Database," in Application Development Guide and refer to "Using Database Cursors" in Application Development Guide for information about declaring cursors.
// When the following statement is executed, it fetches// a list of actors in the specified video.proc s_entryDBMS WITH CONNECTION c1 DECLARE act_cursor CURSOR FOR \
SELECT actors.first_name, actors.last_name, roles.role \
FROM actors, roles \
WHERE actors.actor_id = roles.actor_id \
AND roles.title_id = ::film_codeproc exec1
DBMS WITH CURSOR t_cursor EXECUTE USING film_codereturn
DBMS CLOSE CURSOR, DBMS EXECUTE, DBMS WITH CURSOR, dm_is_cursor
![]()
![]()
![]()
![]()