X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 300BA3A55D6 for ; Mon, 6 Dec 2004 15:33:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68911-03 for ; Mon, 6 Dec 2004 15:33:38 +0000 (GMT) Received: from mail5.speakeasy.net (mail5.speakeasy.net [216.254.0.205]) by svr1.postgresql.org (Postfix) with ESMTP id 802A33A5F17 for ; Mon, 6 Dec 2004 15:33:40 +0000 (GMT) Received: (qmail 12189 invoked from network); 6 Dec 2004 15:33:40 -0000 Received: from static-151-201-137-153.pitt.east.verizon.net (HELO [192.168.1.201]) (eeric@[151.201.137.153]) (envelope-sender ) by mail5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 6 Dec 2004 15:33:40 -0000 Message-ID: <41B47BE2.1050501@bonbon.net> Date: Mon, 06 Dec 2004 10:33:54 -0500 From: Eric E User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-odbc@postgresql.org Subject: Re: calling nextval function References: <7F332A8009EE5D4CB62C87717A3498A10A3A2D9F@exchange-be1.lancs.ac.uk> In-Reply-To: <7F332A8009EE5D4CB62C87717A3498A10A3A2D9F@exchange-be1.lancs.ac.uk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200412/20 X-Sequence-Number: 4754 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 >