Thanks for your reply Dr. Hipp.

I just ran those, and they do return 0.

But I am confused.  The documentation says:
"These routines return 1 if the input string appears to be a complete 
SQL statement. A statement is judged to be complete if it ends with a 
semicolon token and is not a prefix of a well-formed CREATE TRIGGER 
statement."
(http://www.hwaci.com/sw/sqlite/c3ref/complete.html)

I guess a statement is also judged to be complete if it is the empty 
string -- which does not end with a semicolon token.

Just as background info, I was attempting to figure out if there was 
more than one statement in a string by doing something like this:

sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, &tail);
if (sqlite3_complete(tail))
{
   // more statements
}

which is similar to what "The Definite Guide to SQLite" recommends (pg. 
218).  I had assumed that was the main reason for having this function, 
but it does not seem to work as I would have expected for that 
particular scenario.

Thanks,

Nicolas

> On 12/16/2009 4:14 PM, D. Richard Hipp wrote:
>
>
> On Dec 16, 2009, at 4:10 PM, Nicolas Rivera wrote:
>
>> Hi,
>>
>> I think I am missing something really simple (some macro or something),
>> because I cannot make sqlite3_complete() to return anything other 
>> than 1.
>>
>> Even when I pass it "" (an empty string), it still returns 1.  I even
>> tried to call sqlite3_initialize() before (although to my knowledge this
>> is not necessary),
>> and I still get 1 with an empty string.
>>
>
>
> sqlite3_complete("/* unterminated comment");
> sqlite3_complete("SELECT 'unterminated string;");
> sqlite3_complete("CREATE TRIGGER unfinished_trigger");
>
> D. Richard Hipp
> d...@hwaci.com
>
>
>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to