You can define them as literals or read them from a file. As a literal:
char *sql_statement = "SELECT * FROM mytable";
If you read all your SQL from a file you can use the Sqlite capability
of having it in one big string delimited with semi-colons and preparing
it is a loop where each instatnce of sqlite3_prepare passes back a
pointer to the start of the next SQL statement.
That would work by opening the file, reading it into a buffer or memory
mapping it, closing the file and then compiling all the SQL in a loop
and then unmapping the file if you mmap'd it. You now have all your SQL
compiled ready to bind and execute.
The file method has the advantage that you can use it to test the SQL
using the command line tool, sqlite3.
To use sqlite3_prepare:
sqlite3_prepare(<DB handle>,<pointer to SQL statement>,-1,<ptr to
sqlite3_stmt>,<pointer to pointer to start of next SQL statement>);
nishit sharma wrote:
can anybody tell me that without using argc and argv in my main() program
how
can i pass sqlite3 statements in my C source code.
more precise is that this time i m opening the database using argc and argv
in my main and
in sqlite3_open() call. similarly in sqlite3_exec().
but how can i make queries in C source code to open, exec and other things
to my database without using these argc and argv.
waiting for the reply
regards
Nishit
On 8/31/07, John Stanton <[EMAIL PROTECTED]> wrote:
nishit sharma wrote:
hi all,
i have made a sampe which is opening a database file but i m
unable to compile that source code and getting error that
undefined reference to sqlite3_open().
i m compiling as
gcc test.c
can anybody tell that these is the command to compile
sqlite3 application or we have any other command
waiting for reply
regards
Nishit
You need to link with the sqlite3 library.
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------