I'm trying to insert from a select statement but it is giving me an error
that I "Cannot modify table or view used in subquery." on my where clause.
Why?
INSERT INTO hospcontact
(hospital_id, name, sir_name, first_name, nick_name, use_nick_name, title,
street, street2,
city, state, zip, bl, bl_is_prim, stmt, stmt_is_prim, day, day_is_prim,
pcsr, pcsr_is_prim, special, special_is_prim,
ub92, ub92_is_prim, pl, pl_is_prim, agedbl, patient_acct_mgr,
last_modified, phone, fax, modified_by, email)
Select 500368, name, sir_name, first_name, nick_name, use_nick_name, title,
street, street2,
city, state, zip, bl, bl_is_prim, stmt, stmt_is_prim, day, day_is_prim,
pcsr, pcsr_is_prim, special, special_is_prim,
ub92, ub92_is_prim, pl, pl_is_prim, agedbl, patient_acct_mgr, last_modified,
phone, fax, modified_by, email
from hospcontact
where hospital_id=500349;
sending to informix-list
Jonathan Leffler - 29 Jul 2003 07:23 GMT
> I'm trying to insert from a select statement but it is giving me an error
> that I "Cannot modify table or view used in subquery." on my where clause.
> Why?
Because you have not upgraded to a sufficiently recent version of the
server. For a very long time, it was not possible to insert into
TableA if TableA was also mentioned in the SELECT statement.
Fortunately, that limitation has been removed in later versions.
> INSERT INTO hospcontact
> (hospital_id, name, sir_name, first_name, nick_name, use_nick_name, title,
[quoted text clipped - 12 lines]
> from hospcontact
> where hospital_id=500349;

Signature
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
Kristofer Andersson - 29 Jul 2003 15:03 GMT
> Because you have not upgraded to a sufficiently recent version of the
> server. For a very long time, it was not possible to insert into
> TableA if TableA was also mentioned in the SELECT statement.
> Fortunately, that limitation has been removed in later versions.
I have been getting error -360 on 9.3. In what version was it fixed?
John Carlson - 29 Jul 2003 15:34 GMT
>> Because you have not upgraded to a sufficiently recent version of the
>> server. For a very long time, it was not possible to insert into
>> TableA if TableA was also mentioned in the SELECT statement.
>> Fortunately, that limitation has been removed in later versions.
>
>I have been getting error -360 on 9.3. In what version was it fixed?
We're on 9.30.HC3 . . . no problems. Is this a table or a view??
Kristofer Andersson - 29 Jul 2003 22:04 GMT
> We're on 9.30.HC3 . . . no problems. Is this a table or a view??
Table. But looking back at it, it was not an insert but an update. So
maybe it has been fixed for insert but not for update...?
Jean Sagi - 30 Jul 2003 23:16 GMT
CREATE TEMP TABLE t(i INTEGER NOT NULL);
INSERT INTO t VALUES(10);
INSERT INTO t SELECT i + 10 FROM t;
-- Ok until here :
-- Trying to set all columns to 0
UPDATE t SET i = i - (SELECT i from t tx WHERE tx.i = t.i);
360: Cannot modify table or view used in subquery.
... So ...
it works for INSERTs but not forUPDATEs...
that's some advance,
Jean Sagi.
Kristofer Andersson wrote:
> John Carlson <john_carlson@whsmithusa.com> wrote in message news:<3e1divsi7b4vanoh7955bc7jcl4j72pmlv@4ax.com>...
>
>>We're on 9.30.HC3 . . . no problems. Is this a table or a view??
>
> Table. But looking back at it, it was not an insert but an update. So
> maybe it has been fixed for insert but not for update...?

Signature
Atte,
Jes?s Antonio Santos Giraldo
jeansagi@myrealbox.com
jeansagi@netscape.net
sending to informix-list