Using Statements

    To use a statement
  1. Call SQLAllocStmt to allocate a statement handle.
  2. Optionally, call SQLSetStmtOption to set statement options or SQLGetStmtOption to get statement options.

    To use server cursors, you must set cursor options to values other than their defaults. For more information, see Setting Cursor Options.

  3. Execute a statement directly. For more information, see Executing Statements Directly .

    Or

    Prepare a statement once, then execute it multiple times. For more information, see Preparing and Executing Statements.

    Or

    Call a catalog function, which returns results.

  4. Process the results of a statement one row at a time. For more information, see Processing Results.

    Or

    Process the results of a statement using a scrollable cursor. For more information, see Using Scrollable Cursors.

    Or

    Call SQLRowCount to determine the number of rows affected by an insert, update, or delete statement.

  5. If results are returned, call SQLFreeStmt with an fOption of SQL_CLOSE to clear any pending results and make the statement handle available for a new cursor.

    To reuse the statement handle, go to step 2.

  6. Call SQLFreeStmt with an fOption of SQL_DROP to free the statement handle.