how can obtain the OID of the last insert ?
how can obtain the OID of the last insert ?
От:
Augusto Meza Lizardi <mezal74@yahoo.com>
Дата:
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
Re: how can obtain the OID of the last insert ?
От:
Simeó Reig <simeo@incofisa.com>
Дата:
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"
To:
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