Define a cursor mode

You can specify one of the following cursor modes for the cursor with the control-flag bit mask.
Cursor mode Description SELECT statement
Update Enables you to read and modify the data within the cursor SELECT...FOR UPDATE
Read-only Enables you to read the data within the cursor; does not allow you to update or delete any row it fetches SELECT...FOR READ ONLY
When you execute a prepared SELECT statement with no FOR UPDATE or FOR READ ONLY clause, the cursor mode you need depends on whether your database is ANSI-compliant, as follows:
  • In a database that is not ANSI compliant, the SELECT statement specifies a read-only mode by default.

    You do not need to specify the FOR READ ONLY keywords in the SELECT statement. The only advantage of specifying the FOR READ ONLY keywords explicitly is for better program documentation. To specify an update mode, you must specify the FOR UPDATE keywords in the SELECT statement.

  • In an ANSI-compliant database, the SELECT statement specifies an update mode by default.

    You do not need to specify the FOR UPDATE keywords in the SELECT statement. The only advantage of specifying the FOR UPDATE keywords explicitly is for better program documentation. To specify a read-only mode, you must specify the FOR READ ONLY keywords in the SELECT statement.

By default, both the sequential and scroll cursor types have a cursor mode of update (also called read/write). The following table shows the cursor types and cursor modes, with the required bit-mask values for the control flag.
Table 1. Control-flag values for cursor type and mode
Cursor Control-flag value
Update sequential cursor None (default)
Read-only sequential cursor MI_SEND_READ
Update scroll cursor MI_SEND_SCROLL
Read-only scroll cursor MI_SEND_READ + MI_SEND_SCROLL