pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Currval not working
2+ messages / 2 participants
[nested] [flat]

* Currval not working
@ 2003-05-30 21:03 Patrick Hatcher <pathat@attbi.com>
  2003-06-02 16:35 ` Re: Currval not working Chris Gamache <cgg007@yahoo.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Patrick Hatcher @ 2003-05-30 21:03 UTC (permalink / raw)
  To: pgsql-odbc

PG: 7.3.3
Driver version: 7.03.01

I'm using VB as a front-end to end data into PG database.  When I try to pull the current value of my serial field using this code:
rs.open "select currval('public.hodiv_hodiv_id_seq');",CN
I get this error message:
ERROR: hodiv_hodiv_id_seq.currval is not yet defined in this session.
However, if use nextval it works fine.
rs.open "select nextval('public.hodiv_hodiv_id_seq');",CN

Any ideas?

TIA
Patrick

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Currval not working
  2003-05-30 21:03 Currval not working Patrick Hatcher <pathat@attbi.com>
@ 2003-06-02 16:35 ` Chris Gamache <cgg007@yahoo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Chris Gamache @ 2003-06-02 16:35 UTC (permalink / raw)
  To: Patrick Hatcher <pathat@attbi.com>; pgsql-odbc

Currval is defined if the sequence is incremented during the connection. If you
want the current value of the sequence regardless of whether our not it was
updated this session (PostgreSQL 7.2) :

SELECT last_value FROM hodiv_hodiv_id_seq;

Beware: This value has a completely different meaning than currval. Currval is
basicly the last (updated) value of the sequence for the connection. AFAIK,
last_value will return the value of the sequence at the moment of the query,
and is subject to be changed by concurrent connections.

Make sure you have SELECT permissions for the sequence.

HTH,

CG




--- Patrick Hatcher <pathat@attbi.com> wrote:
> PG: 7.3.3
> Driver version: 7.03.01
> 
> I'm using VB as a front-end to end data into PG database.  When I try to pull
> the current value of my serial field using this code:
> rs.open "select currval('public.hodiv_hodiv_id_seq');",CN
> I get this error message:
> ERROR: hodiv_hodiv_id_seq.currval is not yet defined in this session.
> However, if use nextval it works fine.
> rs.open "select nextval('public.hodiv_hodiv_id_seq');",CN
> 
> Any ideas?
> 
> TIA
> Patrick
> 
> 
> 


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-06-02 16:35 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-05-30 21:03 Currval not working Patrick Hatcher <pathat@attbi.com>
2003-06-02 16:35 ` Chris Gamache <cgg007@yahoo.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox