From: | <operationsengineer1(at)yahoo(dot)com> |
---|---|
To: | Kumar S <ps_postgres(at)yahoo(dot)com>, Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Foreign key error, please help. |
Date: | 2005-03-09 18:01:25 |
Message-ID: | 20050309180125.61161.qmail@web52402.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
--- Kumar S <ps_postgres(at)yahoo(dot)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/
From | Date | Subject | |
---|---|---|---|
Next Message | John DeSoi | 2005-03-09 18:39:05 | Re: VERY basic psql and schema question |
Previous Message | Sean | 2005-03-09 17:53:25 | Exporting Tables |