From: | "Poovendran Moodley" <poovenm(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | SQL INSERT/TRIGGER Help |
Date: | 2007-12-10 06:36:44 |
Message-ID: | b18bbf6f0712092236m48fa2e28s80b7bbb30c80dc22@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi all, I'm not sure how to phrase this question... I have a table that
requires a foreign key of another table - this foreign key is automatically
generated and the key field in the 'foreign' table. So I have the following
situation (kind of):
Table *Observation*
*Time_Stamp* - *primary key*
...
Observation_ID - *foreign key*
Table *Observation_Value*
*Observation_ID* - *primary key*
...
So obviously I need to insert into the table *Observation_Value* first
before I can insert into table *Observation*, but how to I get the
automatically generated foreign key?
I was thinking of using a trigger - when a value is inserted into *
Observation_Value* then add the primary key to a new table (probably a view)
and get that value for insertion into *Observation* then drop temporary
table. I wanted to know if there's an easier way to do this? I can't change
the table structure in any way either.... any help would be appreciated. I'm
not even sure what type of search query I should use to find help on this
topic either...
Regards,
Pooven
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2007-12-10 06:44:25 | Re: SQL INSERT/TRIGGER Help |
Previous Message | Shane Ambler | 2007-12-10 04:45:44 | Re: join on three tables is slow |