Re: Using a serial primary key as a foreign key in a second table
В списке pgsql-novice по дате отправления:
| От | Bruno Wolff III |
|---|---|
| Тема | Re: Using a serial primary key as a foreign key in a second table |
| Дата | |
| Msg-id | 20061221174613.GA19545@wolff.to обсуждение исходный текст |
| Ответ на | Using a serial primary key as a foreign key in a second table (Nathaniel <naptrel@yahoo.co.uk>) |
| Ответы |
Re: Using a serial primary key as a foreign key in a second
|
| Список | pgsql-novice |
On Thu, Dec 21, 2006 at 12:07:35 +0000, Nathaniel <naptrel@yahoo.co.uk> wrote: > > So, I want to add the company "Looney Tunes" (which is auto-assigned > a company_id value), and then extract that id value so that I can use > it in the company_id foreign key field of Bugs Bunny's person record. The historical way to do this was with nextval and currval. In 8.2 you also have the option of using the RETURNING clause. Looking at the documentation, it appears you can't directly use the output of the RETURNING clause in a subselect. You would need to save the returned value in your app or define a set returning function to do the company update.
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера