SQL INSERT/TRIGGER Help
От | Poovendran Moodley |
---|---|
Тема | SQL INSERT/TRIGGER Help |
Дата | |
Msg-id | b18bbf6f0712092236m48fa2e28s80b7bbb30c80dc22@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: SQL INSERT/TRIGGER Help
|
Список | 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 foreignkey is automatically generated and the key field in the 'foreign' table. So I have the following situation (kind of):<br/><br /> Table <u>Observation</u><blockquote><b>Time_Stamp</b> - <i>primary key</i></blockquote><blockquote>...</blockquote><blockquote>Observation_ID- <i>foreign key</i></blockquote> Table <u>Observation_Value</u><blockquote><b>Observation_ID</b>- <i>primary key</i></blockquote><blockquote>...</blockquote> Soobviously I need to insert into the table <i>Observation_Value</i> first before I can insert into table <i>Observation</i>,but how to I get the automatically generated foreign key?<br /><br /> I was thinking of using a trigger- when a value is inserted into <i>Observation_Value</i> then add the primary key to a new table (probably a view)and get that value for insertion into <i>Observation</i> then drop temporary table. I wanted to know if there's an easierway to do this? I can't change the table structure in any way either.... any help would be appreciated. I'm not evensure what type of search query I should use to find help on this topic either...<br /><br />Regards,<br />Pooven<br />
В списке pgsql-sql по дате отправления: