| От | Bruno Wolff III |
|---|---|
| Тема | Re: PLSQL Question regarding multiple inserts |
| Дата | |
| Msg-id | 20040229182853.GA8972@wolff.to обсуждение исходный текст |
| Ответ на | PLSQL Question regarding multiple inserts ("Humble Geek" <humblegeek@rogers.com>) |
| Список | pgsql-general |
On Wed, Feb 25, 2004 at 04:11:37 +0000,
Humble Geek <humblegeek@rogers.com> wrote:
> Hi all. Quick and perhaps silly question, but...
>
> I am using Pg 7.3. I am writing a function using pgplsql. This function will
> perform multiple inserts. Let's say two of the inserts are as follows:
>
> -- id is primary key
> insert into users (id, username) values (nextval('someSeq'),'somename');
>
> -- id is also a PK
> insert into log (id, uid, message) values (nextval('someOtherSeq'),XXX,'New
> Account');
>
> Assume XXX is the id from the first insert. How do I get that number? Not
> currval('someSeq') - 'cause someone else may have performed an insert - but
> the id for that specific insert.
currval is per backend, so it is safe to use in the second insert.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера