Skip site navigation (1) Skip section navigation (2)

trigger that needs a PK

From: johnf <jfabiani(at)yolo(dot)com>
To: "PostgreSQL List - Novice" <pgsql-novice(at)postgresql(dot)org>
Subject: trigger that needs a PK
Date: 2008-02-13 07:20:46
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
I'm sure this question has been ask before but I could not find anything on 
google.  I most likely did not enter the right text into the google search.

I have a parent table that requires that an insert into a child table happen.  
The problem is I can not determine what the parent pk is for the insert into 
the child because it hasn't happen yet - if I set the trigger to before 
insert.  So I guess I need something that works with after insert into the 
parent so the pkid can be created.

The parent has:
pkid serial
lot varchar 30

the child:
pkid serial
fk_parent int
other fields....

The question is how can I get the pk and insert it into the child.  Of course 
I'm new so if I missed something just provide the link or tutorial.  

Thanks in advance!

John Fabiani


pgsql-novice by date

Next:From: A. KretschmerDate: 2008-02-13 07:32:24
Subject: Re: trigger that needs a PK
Previous:From: Greg CocksDate: 2008-02-13 04:24:37
Subject: Seeking advice on how to build a pseudo-FK (?) relationship

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group