A script-enabled browser is required for this page to function properly.

EXEC_SQL.OPEN_CURSOR built-in function

This function creates a new cursor on a specified connection and returns a cursor handle. When you no longer need the cursor, you must close it explicitly by using EXEC_SQL.CLOSE_CURSOR.

Syntax


FUNCTION EXEC_SQL.OPEN_CURSOR
[connid IN CONNTYPE]
RETURN EXEC_SQL.CURSTYPE;

Parameter

Description

connid

Is the handle to the connection you want to use. If you do not specify a connection, EXEC_SQL.Default_Connection retrieves the primary connection handle from the cache.

Returns

A handle to the new cursor.

Usage notes

You can use cursors to execute the same SQL statement repeatedly (without reparsing) or to execute a new SQL statement (with parsing). When you reuse a cursor for a new statement, the cursor contents are automatically reset when the new statement is parsed. This means you do not have to close and reopen a cursor before reusing it.

Example


PROCEDURE getData IS
--
-- a cursorID must be of type EXEC_SQL.CURSTYPE
--
  connection_id EXEC_SQL.CONNTYPE; 
  cursorID EXEC_SQL.CURSTYPE;

...
 BEGIN
  connection_id := EXEC_SQL.OPEN_CONNECTION('connect_str');

  ...

-->
-- this cursor is now associated with a particular connection
--
  cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
  ...
END;

See also

About the EXEC_SQL built-in package

EXEC_SQL built-in package