Small. Fast. Reliable.
Choose any three.

SQLite C Interface

Determine If An SQL Statement Is Complete

int sqlite3_complete(const char *sql);
int sqlite3_complete16(const void *sql);

These routines are useful for command-line input to determine if the currently entered text seems to form complete a SQL statement or if additional input is needed before sending the text into SQLite for parsing. These routines return true if the input string appears to be a complete SQL statement. A statement is judged to be complete if it ends with a semicolon and is not a fragment of a CREATE TRIGGER statement. These routines do not parse the SQL and so will not detect syntactically incorrect SQL.

These functions return true if the given input string ends with a semicolon optionally followed by whitespace or comments. For sqlite3_complete(), the parameter must be a zero-terminated UTF-8 string. For sqlite3_complete16(), a zero-terminated machine byte order UTF-16 string is required. These routines return false if the terminal semicolon is within a comment, a string literal or a quoted identifier (in other words if the final semicolon is not really a separate token but part of a larger token) or if the final semicolon is in between the BEGIN and END keywords of a CREATE TRIGGER statement.

See also lists of Objects, Constants, and Functions.


This page last modified 2007/12/14 14:37:57 UTC