OdbcClose Function

Action

Closes a cursor.

Include file

ODBC.bdh

Syntax

OdbcClose( in cCursor    : cursor,
           in nOperation : number optional ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
cCursor Cursor associated with a database connection.
nOperation

Specifies which operation to perform. This parameter must be set to one of the following values:

  • SQL_CLOSE (default). Use this option to Close the cursor when the cursor is re-used later.

  • SQL_DROP. Destroys the cursor and frees all memory allocated for the cursor ( use this option (at the end of the transaction) when the cursor is not re-used anymore).

  • SQL_UNBIND. Disposes the result data columns.

  • SQL_RESET_PARAMS. Disposes the bound parameters.

Example

var
  hEnv, hDbc : number;
  cCursor : cursor;

dcltrans
  transaction TMain
  begin
    OdbcAlloc(SQL_HANDLE_ENV, hEnv);
    OdbcAlloc(SQL_HANDLE_DBC, hDbc, hEnv);
    OdbcConnect(hDbc, "DSN=database;UID=user;PWD=pass;");
    OdbcOpen(cCursor, hDbc);
    OdbcPrepare(cCursor, sqlInsert);
    OdbcBind(cCursor, ":1", SQL_C_CHAR, 32);
    OdbcBind(cCursor, ":2", SQL_C_LONG);
    OdbcSetString(cCursor, ":1", "Bob", 1);
    OdbcSetInt(cCursor, ":2", 25, 1);
    OdbcSetString(cCursor, ":1", "Marcy", 2);
    OdbcSetInt(cCursor, ":2", 33, 2);
    OdbcExecute(cCursor);
    OdbcClose(cCursor, SQL_DROP);
    OdbcCommit(hDbc);
    OdbcDisconnect(hDbc);
    OdbcFree(hDbc);
    OdbcFree(hEnv);
  end TMain;

dclsql
  sqlInsert:
    INSERT INTO persons (name, age) VALUES (?, ?);