Sqlite3_complete does no syntax checking other than to see if the SQL
statement is terminated with a semi-colon. It is used to split multiple
SQL statements in the same string, not verify syntax.
Why not use the Sqlite SQL syntax checker by running sqlite3_prepare on
your statement?
You can get the column names by reading the schema in the SQLITE_MASTER
table in the database. That will give you the SELECT * ... columns.
For an insight into optimization you can use the explain capability and
look at the VDBE byte codes generated when Sqlite compiles the SQL
statement.
Unit 5 wrote:
Hello,
I started with Sqlite just a few days ago and gievn
how simple its api is, I think I am ready to do some
more complex things with it. I am primarily using it
from the tcl api so far.
I have a few questions:
1) If I have a statement that includes "WHERE 0 = 1",
does sqlite optimize the query and return right away
or would it execute the query anyway?
2) Is there a way to get column names form a statement
without (or before) executing the statement? For
example, when a user enters a statement like "select *
from ...".
3) I would like to test the validity of sql statements
before executing them. So I thought I could use "db
complete" command. But now I am not sure what "db
complete" command does. In my tests, it returns 0
(false) regardless of the sql statement. In fact the
only times I have gotton true is if the statement is
empty. The statements are (all are valid and return
data):
% db complete "select 2 * 2 "
% db complete "select a from tab1"
% db complete "select a from tab1 where a < 10"
% db complete "select a from tab1 where a < 10
order by a"
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com