Subject Re: [ib-support] Re: delete and join syntax
Author Dimitry Sibiryakov
On 23 Apr 2002 at 22:44, mmenaz wrote:

> DELETE FROM PROGRESSIVI_CONTABILI
> WHERE EXISTS (SELECT * FROM PROGRESSIVI_CONTABILI
> INNER JOIN UNITA_U_CLIENTI ON
[skipped]
>Is this the only, correct way of doing things with delete? Or is there
>a join syntax for that purpouse? Searching google I've found that
>syntax used, but I don't know if were good advices or not ;) Thanks

Because of "OLD.UICC_ID" I decided that this query is a part of a
trigger. If it is the case, you can turn the query inside out, using
FOR SELECT ... DO. For example:

FOR SELECT primary_key FROM PROGRESSIVI_CONTABILI JOIN ....
INTO :Some_variable DO
DELETE FROM PROGRESSIVI_CONTABILI WHERE primary_key=:Some_variable;

This should work faster than EXISTS(..).
I don't know if it is possible to use RDB$DB_KEY or a cursor and
"DELETE ... WHERE CURRENT OF" in this case because of joins.

By the way, is it possible to DECLARE VARIABLE for storing the
value of RDB$DB_KEY?

SY, Dimitry Sibiryakov.