Re: Foreign key error, please help.

Поиск
Список
Период
Сортировка
От
Тема Re: Foreign key error, please help.
Дата
Msg-id 20050309180125.61161.qmail@web52402.mail.yahoo.com
обсуждение исходный текст
Ответ на Foreign key error, please help.  (Kumar S <ps_postgres@yahoo.com>)
Список pgsql-novice
--- Kumar S <ps_postgres@yahoo.com> wrote:
> Hi Stephan,
> Thank you very much, it was my stupid mistake.
>
> One more question. aplogies if this is also not so
> worthy question.
> In a transaction does currval work only if a
> previous
> statement defines it.  In my case I wanted to get FK
> from existing currval in sample table (sample_id).
> when I execute my statements in a transasction, I
> get
> the following error. Do I have to just use a SELECT
> statement here, because currval is not working? Or
> did
> i made a mistake instead?
>
> Thank you.

curval reports the most recent value of nextval
(serial datatype).  nextval automatically occurs on an
insert.  therefore, when you do an insert, you don't
need to specifically call nextval, it has already been
done by postgres.

yes, you need to SELECT the fk from the row in
question if you have not done and insert or if nextval
was never called.






__________________________________
Celebrate Yahoo!'s 10th Birthday!
Yahoo! Netrospective: 100 Moments of the Web
http://birthday.yahoo.com/netrospective/

В списке pgsql-novice по дате отправления:

Предыдущее
От: Sean
Дата:
Сообщение: Exporting Tables
Следующее
От: John DeSoi
Дата:
Сообщение: Re: VERY basic psql and schema question