[gdal-dev] OGR: Get FID of last set feat in PG

Even Rouault even.rouault at mines-paris.org
Wed Sep 8 16:34:00 EDT 2010


Tom,

yes you need to call  ReleaseResultSet after every ExecuteSQL, otherwise 
you'll have memory leaks

Ideally you should have been able to call GetFID() after CreateFeature(), but 
this is currently not implemented in the postgresql driver.

I have a patch to solve the issue, but it raises some potential backward 
compatibility issue, so I'd like hearing from other people before applying.

Patch and potential issues discussed here : 
http://trac.osgeo.org/gdal/ticket/3744

Best regards,

Even

Le mercredi 08 septembre 2010 17:36:30, Tom van der Putte a écrit :
>  In reply to my own question, I've created something that works:
>  Layer tempLayer = ds2.ExecuteSQL("SELECT
> currval(pg_get_serial_sequence('wells', 'well_id')) as seqval;", null,
> null);
>  Feature seqFeat = tempLayer.GetNextFeature(); //always only 1 row in
> the resultset, so no *while*
>  tempFID = seqFeat.GetFieldAsInteger("seqval");
>  ds2.ReleaseResultSet(tempLayer);
>  Is it necessary to call ReleaseResultSet after every ExecuteSQL? Or
> only after the last one?
>  Cheers,
>  Tom
>  On Wed 08/09/10 16:03 , Tom van der Putte tom at vdputte.nl sent:
>   Hi All,
>  I'm adding several new features to a PostGIS table using OGR (in
> C#). After each CreateFeature I'd like to somehow get the FID of the
> created feature. Is there any possible way to do this? If not elegant,
> any hack is also welcome :D
>  Cheers,
>  Tom


More information about the gdal-dev mailing list