Re: currval = currval+1
От | Merlin Moncure |
---|---|
Тема | Re: currval = currval+1 |
Дата | |
Msg-id | BANLkTim19xJ9TS7Y=GJ7ad8A=Sgqctt17w@mail.gmail.com обсуждение исходный текст |
Ответ на | currval = currval+1 (salah jubeh <s_jubeh@yahoo.com>) |
Ответы |
Re: currval = currval+1
|
Список | pgsql-general |
On Wed, Jun 1, 2011 at 9:27 AM, salah jubeh <s_jubeh@yahoo.com> wrote: > I have the following SQL statements > > BEGIN; > -- account_id is a sequence > INSERT INTO account (name) VALUES ('test customer'||random()::text); > -- account_id is a foreign key > INSERT INTO account_detail (account_id,......) VALUES ((SELECT * from > currval('account_acccount_id_seq')), ........); > COMMIT; > > ERROR: insert or update on table "account_detail" violates foreign key > constraint ... > > > > I have executed the above without a transaction but in the same session, and > the issue was that the current value of the account points to the curval + 1 > > I have solved the above by subtracting 1 in the second insert statement. Why > I am having this problem, I have used current value many time and this is > the first time I have this behavior. works for me -- are you sure you don't have a trigger or something else going on behind the scenes? merlin
В списке pgsql-general по дате отправления: