Subject Re: [firebird-support] Running a query to find table constraints
Author Alexandre Benson Smith
tractaylor wrote:

>Hello All:
>
>I am wondering if there is a way to query the database to find out the
>order I need to insert records into the database. In other words, I
>have a master detail relationship. I would like to run a query to get
>a list showing me that I need to insert into the Master table then the
>detail.
>
>Some like an Orders and Order_Detail table. I could run a query and it
>would somehow tell me there is a foreign key on Order_Detail that
>points to Orders.....
>
>Does this make since? And is this possible?
>
>Thanks
>Trac
>
>
I don't know how to write a query in SQL, maybe with a SP, If I need to
implement this, I would make it on the client app, to make a recursive
call to search for dependencies, and when I found a table without
dependencies insert data on it, or if all the tables that another tables
depends on are already populated. But you will find a problem with self
referencing tables.

What about another aproach ?
Disable all the foreign key constraints and triggers then populate it in
any order and after all data are in place, turn on the FK's and triggers
again.

You could look at IBDataPump or IBPump never remember the correct name,
it is used to pump data between databases.

see you !

see you !

--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.12/77 - Release Date: 18/08/2005