Subject Re: [ib-support] Mass deletion
Author Helen Borrie
At 01:03 AM 08-04-02 +0530, you wrote:


>Hi
>
>Is there a way to delete at one stretch the records in a gdb pertaining to
>say date '01-APR-2001'? Now i have to remove the constraints like foriegn
>key for each table and then delete using Sql statement.
>
>Then I datapump to the an empty gdb. Surely there ought to be an easier
>way?

For IB 4.x, IB 5.x, Dialect 1 IB 6.x or Firebird data:

DELETE FROM ATABLE
WHERE Mydate between '01-APR-2001' and '02-APR-2001' ;

If there are rows in another table that are dependent on these rows through
a foreign key, you will have to delete them first:

DELETE FROM BTABLE
WHERE For_Key in (SELECT Pri_Key from ATABLE
WHERE Mydate between '01-APR-2001' and '02-APR-2001') ;

...and commit this...

cheers,
Helen

All for Open and Open for All
Firebird Open SQL Database · http://firebirdsql.org ·
http://users.tpg.com.au/helebor/
_______________________________________________________