ALLBASE/SQL Reference Manual (36216-90216)

588 Chapter12
SQL Statements S - Z
UPDATE WHERE CURRENT
Description
This statement cannot be used interactively and should not be used in conjunction with
rows fetched using the BULK FETCH statement.
For constraint violations, the error handling behavior depends on the setting of the SET
CONSTRAINTS statement. Refer to the discussion of this statement in this chapter.
No error or warning condition is generated by ALLBASE/SQL when a character or
binary string is truncated during an UPDATE operation.
Using UPDATE WHERE CURRENT OF CURSOR requires that the cursor be based on
an updatable query. See "Updatability of Queries" in the "SQL Queries" chapter.
The target table of the UPDATE WHERE CURRENT is designated by
TableName
or is the
base table underlying the
ViewName
. The base table restrictions that govern updates
via a cursor were presented in the description of the DECLARE CURSOR statement.
A table on which a unique constraint is defined cannot contain duplicate rows.
For constraint violations, the error handling behavior depends on the setting of the SET
CONSTRAINTS statement. Refer to the discussion of this statement in this chapter.
An update of a primary key column in either a referential or unique constraint will fail
if any of the rows being updated are currently referred to by any table's foreign key row
or if any of the rows being updated ends up matching the value of another unique row.
In order to update such primary key rows, the foreign keys must be changed to refer to
other primary keys, changed to a value of NULL, or deleted. An update of a foreign key
column will fail if it leaves a non-NULL foreign key row without any matching primary
key row.
Rows being updated must not cause the search condition of the table check constraint to
be false and must cause the search condition of the view check constraint to be true
when error checking is done.
Rows being updated in the table through a view having a WITH CHECK OPTION must
still be visible through the query expression of the check constraint of the view and any
underlying views, in addition to satisfying any constraints of the table. Refer to the
"Check Constraints" section of Chapter 4 , “Constraints, Procedures, and Rules,” for a
further discussion on check constraints.
A rule defined with a
StatementType
of UPDATE will affect UPDATE WHERE CURRENT
statements performed on the rules' target tables. Rules defined with a
StatementType
of UPDATE including a list of column names will affect only those UPDATE WHERE
CURRENT statements performed on the rules' target tables that include at least one of
the columns in their SET clause. When the UPDATE WHERE CURRENT is performed,
ALLBASE/SQL considers all the rules defined for that table with the UPDATE
StatementType
and a matching column. If the rule has no condition, it will fire for the
current row and invoke its associated procedure with the specified parameters. If the
rule has a condition, it will evaluate the condition and fire if the condition evaluates to
TRUE, invoking the associated procedure with the specified parameters for the current
row. Invoking the procedure could cause other rules, and thus other procedures, to be
invoked if statements within the procedure trigger other rules.
If a DISABLE RULES statement is in effect, the UPDATE WHERE CURRENT statement