ANSI_UPDATE_CONSTRAINTS option

Function

Controls the range of updates that are permitted.

Allowed values

OFF, CURSORS, STRICT

Default

CURSORS in new databases.

OFF in databases created before version 12.4.3.

Description

Sybase IQ provides several extensions that allow updates which are not permitted by the ANSI SQL standard. These extensions provide powerful, efficient mechanisms for performing updates. However, in some cases, they cause behavior that is not intuitive. This behavior can produce anomalies such as lost updates if the user application is not designed to expect the behavior of these extensions.

The ANSI_UPDATE_CONSTRAINTS option controls whether updates are restricted to those permitted by the SQL/92 standard.

If the option is set to STRICT, the following updates are prevented:

If the option is set to CURSORS, these same restrictions are in place, but only for cursors. If a cursor is not opened with FOR UPDATE or FOR READ ONLY, the database server determines whether updates are permitted based on the SQL/92 standard. If the ANSI_UPDATE_CONSTRAINTS option is CURSORS or STRICT, cursors containing an ORDER BY clause default to FOR READ ONLY; otherwise, they continue to default to FOR UPDATE.

Example

The following code has a different effect, depending on the setting of ANSI_UPDATE_CONSTRAINTS.

create table mmg (a char(3));
create table mmg1 (b char(3));
insert into mmg values ('001');
insert into mmg values ('002');
insert into mmg values ('003')
insert into mmg1 values ('003');
select * from mmg;
select * from mmg1;

Option 1: Set ANSI_UPDATE_CONSTRAINTS to 'STRICT':

set option public.Ansi_update_constraints = 'strict';
DELETE MMG FROM MMG1 WHERE A=B;

This results in an error indicating that the attempted update operation is not allowed.

Option 2: Set ANSI_UPDATE_CONSTRAINTS to 'CURSORS' or 'OFF'

set option public.Ansi_update_constraints = 'CURSORS';  // or 'OFF'
DELETE MMG FROM MMG1 WHERE A=B;

In this case, the deletion should complete without the error.

See also

UPDATE statement