Idemsoft-Alfonso Zafón

Hi,


 $tStatement:="INSERT INTO invoices (name, amount) VALUES 
($tName,string($rAmount))
returning id"

    $rowset:=PgSQL Select ($lConnection;"";$lStatement)

    $lInvoiceID:=PgSQL Get Longint Column ($rowset;"id")

This work form me.

Saludos.
idem    
Alfonso Zafón

Tel:    +34 963 455 103
Email:  alfo...@idemsoft.com <mailto:alfo...@idemsoft.com>
Web:    www.idemsoft.com <http://www.idemsoft.com>

        
        
Idemsoft, S.L.
Pza. Tetuán, 11
46003Valencia- España

Gestión - Hoteles -Inmobiliarias - Abogados
WEB - Tienda Online - Enlace Web



El 21/09/2017 a las 18:28, Lee Hinde via 4D_Tech escribió:
I haven't used the Postgres plug-in, but the MySQL plugin has: *MySQL Get
Last Insert Row ID* just for that purpose. Is there an equivalent?

On Thu, Sep 21, 2017 at 7:37 AM, Jeffrey Kain via 4D_Tech <
4d_tech@lists.4d.com> wrote:

We're using the Pluggers PostgreSQL plug-in, and trying to capture the ID
of newly inserted rows. It seems like the best way to do this is to put the
insert into a Select. The following seems to work, but we've just never
done this before and it seems weird... :) Anything to worry about here?

     $tStatement:="INSERT INTO invoices (name, amount) VALUES (?,?)
returning id"

     $lStatement:=PgSQL New SQL Statement ($lConnection;$tStatement)
     PgSQL Set String In SQL ($lStatement;1;$tName)
     PgSQL Set Real In SQL ($lStatement;2;$rAmount)

     $rowset:=PgSQL Select ($lConnection;"";$lStatement)

     $lInvoiceID:=PgSQL Get Longint Column ($rowset;"id")

     PgSQL Delete Row Set ($rowset)
     PgSQL Delete SQL Statement ($lStatement)
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to