Query

From: "Pedro Igor" <pedroigor(at)aip(dot)com(dot)br>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Query
Date: 2003-01-03 13:46:27
Message-ID: 000d01c2b32e$8529eca0$0b00010a@aip.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Regards .....

I hope someone can help me in this query.
Have a field in a table that needs to check if another table has the value that is being inserted.
Ex:
table A
- id int constraint pkey_id primary key,


table B
- id int constraint fkey_A_B references A,

Here comes my doubt:

table C
- id int constraint fkey_A_C references A check (if exists B.id = C.id)

How can i build this expression so, when I insert a tupple in table C the field will check in the table A(ok, because is a foreign key) and also in table B ....
I have tried : check (select count(b.id) from B b where b.id = id) <> 0) .... but doesn´t work ......
I can use trigger here, but i don´t know if is the best solution .....

Thanks,

Pedro Igor

Responses

  • Re: Query at 2003-01-03 15:57:45 from Stephan Szabo

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2003-01-03 15:57:45 Re: Query
Previous Message Manfred Koizar 2003-01-03 13:10:18 Re: NULLL comparison in multiple column unique index