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
**********************************************************************

Reply via email to