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

EXEC_SQL.Open_Cursor

Description

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;

Parameters

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 Oracle Developer 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;