The syntax for declaring cursors that release locks when the cursor closes is:
exec sql declare cursor_name [cursor sensitivity] [cursor scrollability] [release_locks_on_close] cursor for select_statement
[for {read only | update [ of column_name_list]}] ;
where:
cursor_name identifies the cursor. The name must be unique and have a maximum of 255 characters. The name must begin with a letter of the alphabet or with the symbols “#” or “_”.
cursor sensitivity – See “Declaring scrollable cursors”.
cursor scrollability – See “Declaring scrollable cursors”.
select_statement is a select statement that can return multiple rows of data. The syntax for select is the same as described in the Adaptive Server Enterprise Reference Manual, except that you cannot use into or compute clauses.
column_name_list identifies the list of columns to be affected.
You cannot use release_locks_on_close with an update clause except in this form:
exec sql declare cursor c1 release_locks_on_close cursor for select * from T for update of col_a
In this case, release_locks_on_close is ignored.
cpre cannot generate these ct_cursor() options:
CS_CUR_RELLOCKS_ONCLOSE | CS_READ_ONLY
CS_CUR_RELLOCKS_ONCLOSE | CS_FOR_UPDATE
ESQL/C sample code is available in example8.cp.