Re: how can obtain the OID of the last insert ?

From: Simeó Reig <simeo(at)incofisa(dot)com>
To: "Augusto Meza Lizardi" <mezal74(at)yahoo(dot)com>
Cc: <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: how can obtain the OID of the last insert ?
Date: 2003-11-20 17:50:17
Message-ID: 006001c3af8e$c2a55da0$0500a8c0@incofisa.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Public Function retornaIdUltimaInserció(Secuencia As String) As Long

On Error GoTo errorsRetornaIdFinca

Dim rst As New ADODB.Recordset
Dim SQL As String
Dim idTrobat As Long

idTrobat = 0

SQL = "SELECT currval ('" & Secuencia & "');"

Set rst = conexioADO.Execute(SQL, , adCmdText)
idTrobat = rst.Fields.Item(0).Value
rst.Close
Set rst = Nothing

retornaIdUltimaInserció = idTrobat
Exit Function

errorsRetornaIdFinca:

MsgBox "Error a errorsRetornaCURRVAL " & Err.Number & " " &
Err.Description

End Function

----- Original Message -----
From: "Augusto Meza Lizardi" <mezal74(at)yahoo(dot)com>
To: <pgsql-odbc(at)postgresql(dot)org>
Sent: Sunday, November 16, 2003 9:52 PM
Subject: [ODBC] how can obtain the OID of the last insert ?

> Hi, i am using ODBC for Postgresql with Visual Basic
> 6, somebody know how can obtain the oid for the last
> row inserted ?
>
> I try with :LASTOID ,but when i send the instruction
> "SELECT :LASTOID" return a error parser in the ":",
> the same error pass with the select in a stored
> procredure, this work fine only in plsql.
>
> Any idea ?
>
> Thanks
> Augusto
>
> _________________________________________________________
> Do You Yahoo!?
> Información de Estados Unidos y América Latina, en Yahoo! Noticias.
> Visítanos en http://noticias.espanol.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend

In response to

Browse pgsql-odbc by date

  From Date Subject
Next Message Sunil Thomas 2003-11-21 04:20:09 pls help
Previous Message Markus Donath 2003-11-20 13:07:47 stable driver for multithreaded environment (IIS 5.X)