Hi Stephan Ben and all,

by the way: checking the column count only applies to SQLite. Other 
databases (Postgres, Oracle) support the insert into .... returning or 
update ... returning syntax, resulting in statements that change the 
database and have columns at the same time.
This is a feature I missed in SQLite occasionally, but I guess it isn't 
SQL standard.

Martin

Am 06.08.2015 um 18:57 schrieb Ben Newberg:
> Excellent. This is exactly what I was looking for.
>
> Thanks.
>
> On Thu, Aug 6, 2015 at 11:50 AM, Stephan Beal <sgbeal at googlemail.com> 
> wrote:
>
>> On Thu, Aug 6, 2015 at 6:46 PM, Ben Newberg <ben.newberg at gmail.com> wrote:
>>
>>> Is there a good way to determine if a sql query is either attempting to
>>> modify a database, or simply querying it?
>>>
>> Check the column count of the prepared statement: it will be >0 for a
>> select or select-like pragma. Anything else is an update, delete, drop,
>> create table/view, non-select-like pragma, or similar.
>>
>> --
>> ----- stephan beal
>> http://wanderinghorse.net/home/stephan/
>> http://gplus.to/sgbeal
>> "Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
>> those who insist on a perfect world, freedom will have to do." -- Bigby
>> Wolf
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to