[sqlite] New default table on DB initialization
Hi, Need a default table to be created on database initialization. i was able to achieve that by executing one create statement query at the end of the function openDatabase. however the problem is that on opening the same DB for the second time, the query fails with error table already exist. findtable function doesnt work since the database is opened but not initialized (via the function sqliteinit3 and find table fails because of that). Need a place where findtable should work in both the cases (new as well as existing database) if the table already exist, skip else run the create statement the default table should be created before any user query runs the table name will be hardcoded and create statement as well. just need the right place to write the below code: if (sqlite3FindTable(db, "emp", 0) ==0 ) { //Table not found, create the table rc = sqlite3_exec(db, "create table emp..;",0, 0, 0); } ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] insert statement using temp variable
hi, need help with very basic question.. More of C than SQLite. have a very simple C program using sqlite DB. .. int i=0; rc = sqlite3_exec(db, "create table emp (empid num);", callback, 0, ); rc = sqlite3_exec(db, "insert into emp values(i);", 0, 0, ); --- the insert query fails with the message stating no such column i. the aim is very simple to insert the value of i into empid column but not sure how to achieve it. pls note that value of i is dynamic and wont be hardcoded. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] block alter table command / table Constraints
Hi Team, Need ur expertise with below 2 problems 1) how to make a table read only, such that any user can only insert but can't update (table schema) or drop the table alter table / drop table arent allowed on sqlite_master, need similar restrictions on my custom table. by setting the tabFlags to TF_Readonly, i m able to prevent the user from dropping the table but alter table is still allowed (can add or drop columns) 2) How to apply constraints similar to given below as part of create table statement, if not possible can it be done after create statement? table sales(cost price, sale price) i need a constraint cost price < sale price so that i dont have to do code level checks during insert statements thanks and regards Rakesh Hemrajani ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Return failure from User Defined Function
Hello Experts, How to return failure from a user defined function such that it halts the main query? for example: assuming i have simple user defined function checkLessThanTen(arg 1) While calling this function in my query (say select checkIsNumber('11') from employee) how to return failure from this user defined function so that the main query is aborted just like in case of any error . H
[sqlite] Query within user defined funtion / UDF in sqlite
Hello Experts, How can i execute a query from user defined function. the user defined function is defined inside sqlite itself (in shell.c opendb function, there is user defined function shellstatic but it doenst query the DB) for example: an user defined function is intended to get the rowcount of the input table. user can type the below command select rowcount('employee') from sqlite_master; the user defined function should replace rowcount('employee') with the actual rowcount of the employee table. pls note that the function should be defined within sqlite only and should be usable from sqlite command line interface as described above. actual code: it fails since m unable to get call back reference from context variable and bcoz of that application terminates while printing the value to the o/p interface (user screen) static void rowcount( sqlite3_context *context, int argc, sqlite3_value **argv ){ struct callback_data *p; char *rowcounttest; rowcounttest = "SELECT 10 from sqlite_master"; char *zErrMsg = 0; sqlite3 *db = sqlite3_context_db_handle(context); shell_exec(db, rowcounttest, shell_callback, context, ); }
[sqlite] Implementing sequence nextval in sqlite
Hello experts I am newbie to sqlite, have started understanding the code, at the moment m stuck and not able to understand how to generate byte code Probleme statement is : I want to implement nextval keyword in sqlite E.g Select seq.nextval from employee so o/p should be next available employee id. How can we implement this parser, any inputs will be appreciated a lot Thanks all