Subject Re: [ib-support] Re: Not in query
Author Helen Borrie
At 06:56 PM 01-07-01 +0300, you wrote:
>Helen,
>
>Will this SQL statement replicate all records present in table1 but not in
>table2 ?
>INSERT into table2 SELECT * FROM table1 WHERE NOT EXISTS IN (SELECT * FROM
>table2)

No. There is no "EXISTS IN" predicate that I know of. If there were, I don't know how it could work. EXISTS returns true if a select returns one or more rows, otherwise false.

Have you tried this?

insert into table2 select * from table1 where (not (exists(select commonkey from table2 where commonkey = table1.commonkey)))


>Is the following statement the best way to retrieve a value from a table and
>make sure that the record selected exists, ie the variable contains a valid
>value?
>if ( not ( exists(SELECT number FROM table1 where (id=1) INTO :number ) ) )
>then exception norecord;

Did you try compiling a procedure containing the statement to check whether (a) the compiler lets you do it and (b) the :number variable gets the value if EXISTS() succeeds?

Cheers,
Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________