Unix Technical Forum

Re: Obtain Serial Value

This is a discussion on Re: Obtain Serial Value within the pgsql Interfaces odbc forums, part of the PostgreSQL category; --> Try using SELECT currval('sequenc_name'); From the docs: Return the value most recently obtained by nextval for this sequence in ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces odbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 02:50 AM
Trewern, Ben
 
Posts: n/a
Default Re: Obtain Serial Value

Try using SELECT currval('sequenc_name');

From the docs:

Return the value most recently obtained by nextval for this sequence in
the current session. (An error is reported if nextval has never been
called for this sequence in this session.) Notice that because this is
returning a session-local value, it gives a predictable answer whether
or not other sessions have executed nextval since the current session
did.

This should be much faster than SELECT max(... and transaction safe.

Regards,

Ben

-----Original Message-----
From: pgsql-odbc-owner@postgresql.org
[mailtogsql-odbc-owner@postgresql.org] On Behalf Of Timothy Reed
Sent: 08 February 2006 14:32
To: Sistemas C.M.P.
Cc: pgsql-odbc@postgresql.org
Subject: Re: [ODBC] Obtain Serial Value


You should try SELECT MAX( <fieldname> ) FROM <tablename>; ??


On 2/8/06, Sistemas C.M.P. <sistemascmp@redynet4.com.ar > wrote:


I am using VB6+ADO+ODBC with pgSQL.
I need to obtain the value of a serial field
(autogenerated) inmediatly after I do a INSERT query. How can I do?




--
--------
Timothy Reed

tareed@gmail.com



-------------------------------------------------------------------
This email and any attachments transmitted with it are confidential (and potentially legally privileged) and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender and do not store, copy or disclose the content to any other person.
It is the responsibility of the recipient to ensure that opening this message and/or any of its attachments will not adversely affect its systems. No responsibility is accepted by the sender.
-------------------------------------------------------------------



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:14 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com