Examples of Cursors in Non-ANSI Compliant Databases

In a database that is not ANSI compliant, a cursor associated with a SELECT statement is a read-only cursor by default. The following example declares a read-only cursor in a non-ANSI compliant database:
EXEC SQL declare cust_curs cursor for
   select * from customer_notansi;
If you want to make it clear in the program code that this cursor is a read-only cursor, specify the FOR READ ONLY option as the following example shows:
EXEC SQL declare cust_curs cursor for
   select * from customer_notansi for read only;
If you want this cursor to be an update cursor, specify the FOR UPDATE option in your DECLARE statement. This example declares an update cursor:
EXEC SQL declare new_curs cursor for
   select * from customer_notansi for update;
If you want an update cursor to be able to modify only some columns in a table, you must specify those columns in the FOR UPDATE clause. The following example declares an update cursor that can update only the fname and lname columns in the customer_notansi table:
EXEC SQL declare name_curs cursor for
   select * from customer_notansi for update of fname, lname;