ERROR: missing FROM-clause entry for table on postgresql 8.1 not on 7.4; deleting from a join

From: m laks <mlaks2000(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: ERROR: missing FROM-clause entry for table on postgresql 8.1 not on 7.4; deleting from a join
Date: 2008-06-17 06:25:19
Message-ID: 44818.48448.qm@web33609.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I am migrating to postgresql 8.1 from 7.4 with debian.

Now I notice that one of my perl DBI scripts is crashing with the error above, and worked fine before.

From google I learn that postgresql is&nbsp; getting tougher on us malfeasant coders who violate the SQL rules :(.

&nbsp;I have not slept in two days :(.

I am unable to do a delete from a table&nbsp; where the condition is that of a join.

I am ignorant on how to do it correctly.

the following worked before:

LTA_IDB=# delete&nbsp; from instancetable where ( (imagelevel.serparent= '1.2.840.113704.1.111.4640.1185891989.4') and (instancetable.imageuid= imagelevel.sopinsuid));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (at least in postgresql 7.4 using perl DBI).

It worked on postgresql 7.4 and now on postgresql 8.1 I get error:

ERROR:&nbsp; missing FROM-clause entry for table "imagelevel"

(Here we want to drop those entries in instancetable whose imageuid agrees with the imagelevel entries with serpatient 1.2.840.113704.1.111.4640.1185891989.4.
(these are CT scan and MRI DICOM medical images)).

Now this following select works:

select * from instancetable, imagelevel where ( (imagelevel.serparent= '1.2.840.113704.1.111.4640.1185891989.4') and (instancetable.imageuid= imagelevel.sopinsuid));

without error in psql.

Then how to drop them?

(Now I actually want to drop those corrsponding entries in both instancetable and imagelevel)&nbsp;

So I tried stuff like this: with failure: :(

LTA_IDB=# delete from select * from instancetable, imagelevel where ( (imagelevel.serparent= '1.2.840.113704.1.111.4640.1185891989.4') and (instancetable.imageuid= imagelevel.sopinsuid));
ERROR:&nbsp; syntax error at or near "select" at character 13
LINE 1: delete from select * from instancetable, imagelevel where ( ...

LTA_IDB=# delete from select * from instancetable, imagelevel where ( (imagelevel.serparent= '1.2.840.113704.1.111.4640.1185891989.4') and (instancetable.imageuid= imagelevel.sopinsuid));
ERROR:&nbsp; syntax error at or near "select" at character 13
LINE 1: delete from select * from instancetable, imagelevel where ( ...
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^
LTA_IDB=# delete from (select * from instancetable, imagelevel where ( (imagelevel.serparent= '1.2.840.113704.1.111.4640.1185891989.4') and (instancetable.imageuid= imagelevel.sopinsuid)));
ERROR:&nbsp; syntax error at or near "(" at character 13
LINE 1: delete from (select * from instancetable, imagelevel where (...
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^
LTA_IDB=# delete from instancetable&nbsp; (select * from instancetable, imagelevel where ( (imagelevel.serparent= '1.2.840.113704.1.111.4640.1185891989.4') and (instancetable.imageuid= imagelevel.sopinsuid)));
ERROR:&nbsp; syntax error at or near "(" at character 28
LINE 1: delete from instancetable&nbsp; (select * from instancetable, ima...
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^
LTA_IDB=# delete from instancetable&nbsp; select * from instancetable, imagelevel where ( (imagelevel.serparent= '1.2.840.113704.1.111.4640.1185891989.4') and (instancetable.imageuid= imagelevel.sopinsuid));
ERROR:&nbsp; syntax error at or near "select" at character 28
LINE 1: delete from instancetable&nbsp; select * from instancetable, imag...

I tried reading around... .. I thank you deeply!

Thanks,

Mitchell Laks

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jaime Casanova 2008-06-17 06:32:10 Re: ERROR: missing FROM-clause entry for table on postgresql 8.1 not on 7.4; deleting from a join
Previous Message Greg Smith 2008-06-17 06:06:55 Re: PostgreSQL and AMD?