Unix Technical Forum

Cannot use sub queries in not exists..

This is a discussion on Cannot use sub queries in not exists.. within the Informix forums, part of the Database Server Software category; --> i try to do the following: insert into table select * from temp_table where name='BoB' and not exists (select ...


Go Back   Unix Technical Forum > Database Server Software > Informix

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 08:21 AM
pookguy88@gmail.com
 
Posts: n/a
Default Cannot use sub queries in not exists..

i try to do the following:
insert into table select * from temp_table where name='BoB' and not
exists (select * from table where name='BoB');

this always gives me back the error:
SQL Error (-360): Cannot modify table or view used in subquery..

what do i do??
all I want is a condition so that i won't insert the same row that is
already there..

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 08:21 AM
June C. Hunt
 
Posts: n/a
Default Re: Cannot use sub queries in not exists..

<pookguy88@gmail.com> wrote:
> i try to do the following:
> insert into table select * from temp_table where name='BoB' and not
> exists (select * from table where name='BoB');
>
> this always gives me back the error:
> SQL Error (-360): Cannot modify table or view used in subquery..
>
> what do i do??
> all I want is a condition so that i won't insert the same row that is
> already there..



Would this get you what you want?

INSERT INTO tab1
SELECT * FROM tab2 WHERE name NOT IN (SELECT name FROM tab1);

--
June Hunt


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2008, 08:21 AM
Bernhard Berlin
 
Posts: n/a
Default Re: Cannot use sub queries in not exists.. Help with temp-table

If it does not help.

make two steps:
1. First make a temporary table
2. Insert from this table


pookguy88@gmail.com schrieb:
> i try to do the following:
> insert into table select * from temp_table where name='BoB' and not
> exists (select * from table where name='BoB');
>
> this always gives me back the error:
> SQL Error (-360): Cannot modify table or view used in subquery..
>
> what do i do??
> all I want is a condition so that i won't insert the same row that is
> already there..
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:33 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com