Using the FOR READ ONLY Option
Use the FOR READ ONLY keywords to define a cursor as a read-only cursor. A cursor declared to be read-only cannot be used to update (or delete) any row that it fetches.
The need for the FOR READ ONLY keywords depends on whether your database is ANSI compliant or not ANSI compliant.
In a database that is not ANSI compliant, the cursor that the DECLARE statement defines is a read-only cursor by default, so you do not need to specify the FOR READ ONLY keywords if you want the cursor to be a read-only cursor. The only advantage of specifying the FOR READ ONLY keywords explicitly is for better program documentation.
In an ANSI-compliant database, the cursor associated with a SELECT statement through the DECLARE statement is an update cursor by default, provided that the SELECT statement conforms to all of the restrictions for update cursors listed in Subset of SELECT statements associated with cursors. If you want a Select cursor to be read-only, you must use the FOR READ ONLY keywords when you declare the cursor.
The database server can use less stringent locking for a read-only cursor than for an update cursor.
EXEC SQL declare z_curs cursor for select * from customer_ansi for read only;