On Tue, Oct 25, 2011 at 7:54 PM, Frank Warmerdam <[email protected]> wrote: > On 11-10-25 04:50 PM, Dan Homerick wrote: >> The ExecuteSQL method returns NULL when an error occurs, or if the >> statement result is just empty... > > The normal approach to distinguishing would be to call CPLErrorReset() > before calling ExecuteSQL(). Then if you get a NULL back interogate > CPLGetLastErrorType(). If it is ERRTYP_FAILURE then an error occurred.
Thanks, that's just what I needed! It's CE_Failure, by the way. > Note that the "ogr sql" implementation appears to return a layer even if > the results is empty it just has no features. Ideally other implementations > of ExecuteSQL() would do the same. Feel free to file a ticket if this is > not the case. The OGRDataSource documentation (http://www.gdal.org/ogr/classOGRDataSource.html#a6acc228db6513784a56ce12334a8c33) states that NULL is returned for statements "that have no results set", which is subtly different than what I initially claimed, "if the statement result is just empty" -- in practice, I think that a result set with no columns comes back as NULL (e.g. from an INSERT statement), but I think one that has no rows will come back as an empty OGRLayer. I think I'd mildly prefer something like an INSERT to return an empty OGRLayer, but the current implementation doesn't appear to be a bug. I should probably mention that I don't have much experience with databases, so I don't have any sense of what's standard as far as results from non-query statements. Should I still open a ticket? Cheers, - Dan _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
