问题
INFORMIX-SE 7.32:
I'm getting error 360 when I try to execute the following statement:
update transaction
set transaction.colx = (select tab1.cola from tab1)
where transaction.num = (select max(transaction.num) from transaction)
and transaction.colx IS NULL;
Any ideas?
回答1:
You're trying to UPDATE
the table transaction
and read from the same table using SELECT MAX
with the same query. You cannot do that.
Subquery restrictions
In general, you cannot modify a table and select from the same table in a subquery. For example, this limitation applies to statements of the following forms:
DELETE FROM t WHERE ... (SELECT ... FROM t ...);
UPDATE t ... WHERE col = (SELECT ... FROM t ...);
{INSERT|REPLACE} INTO t (SELECT ... FROM t ...);
来源:https://stackoverflow.com/questions/3083609/error-360-cannot-modify-table-or-view-used-in-subquery