pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Eric E <whalesuit@bonbon.net>
To: pgsql-odbc@postgresql.org
Subject: Re: calling nextval function
Date: Mon, 06 Dec 2004 10:33:54 -0500
Message-ID: <41B47BE2.1050501@bonbon.net> (raw)
In-Reply-To: <7F332A8009EE5D4CB62C87717A3498A10A3A2D9F@exchange-be1.lancs.ac.uk>
References: <7F332A8009EE5D4CB62C87717A3498A10A3A2D9F@exchange-be1.lancs.ac.uk>

Hi Oliver,
I think the problem with your approach might be in using the nextval 
function as a parameter.
I get sequence values by opening a recordset on the sequence, like this:

Dim cnPGODBC as ADODB.Connection
Dim rsSeqVal as ADODB.Recordset
Dim sSeqValSQL as String
Dim iSeqVal as Integer 'The value returned

sSeqValSQL = "SELECT nextval(bed_id_seq);"
cnPGODBC.Open ("Your ODBC connection string")
Set rsSeqVal = cnPGODBC.Execute(sSeqValSQL)

iSeqVal = rsSeqVal.Fields(0)

Set rsSeqVal = Nothing
Set cnPGODBC = Nothing

Hope this helps,

Eric



Gosling, Oliver wrote:

> Does anybody know how to get the next value of a sequence?
>
> I’m presuming that nextval is an SQL procedure in postgres which can 
> be called by passing the name of the sequence as a parameter. The code 
> below shows what I’ve done in VB. This does not work however - JET 
> throws up an error saying that ‘nextval’ table or query cannot be found.
>
> Dim objCmd As New ADODB.Command
>
> Dim objPrm As ADODB.Parameter
>
> objCmd.ActiveConnection = CurrentProject.Connection
>
> objCmd.CommandType = adCmdStoredProc
>
> objCmd.CommandText = "nextval"
>
> Set objPrm = objCmd.CreateParameter("@name", adBSTR, adParamInput, , 
> "bed_id_seq")
>
> objCmd.parameters.Append objPrm
>
> Set sequenceNumber = objCmd.Execute
>
> seqNum = sequenceNumber!nextval
>
> Can anbody help me with this?
>
> Regards,
>
> Oliver Gosling
>




view thread (3+ messages)  latest in thread

Message-ID: <41B47BE2.1050501@bonbon.net>
Permalink:  ../41B47BE2.1050501@bonbon.net/
Also on:    postgresql.org/message-id/41B47BE2.1050501@bonbon.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: whalesuit@bonbon.net
  Subject: Re: calling nextval function
  In-Reply-To: <41B47BE2.1050501@bonbon.net>
  References: <7F332A8009EE5D4CB62C87717A3498A10A3A2D9F@exchange-be1.lancs.ac.uk> <41B47BE2.1050501@bonbon.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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