Hello!
This function doesn't work:
sqlite> select userkey_uninstall();
SQL error: database table is locked
static void userkey_uninstallFunc(sqlite3_context *context, int argc,
sqlite3_value **argv){
sqlite3 *db;
int rc; /* Result code */
const char zSql[] = "DROP TABLE userkeys"; /* An SQL statement */
db = (sqlite3*) sqlite3_context_db_handle(context);
rc = sqlite3_exec(db, zSql, NULL, NULL, NULL);
if( rc != SQLITE_OK ){
sqlite3_result_error(context, sqlite3_errmsg(db), -1);
return;
}
// return null value
sqlite3_result_null(context);
}
But this work fine:
sqlite> select userkey_install();
#define SCHEMA_USERKEY \
"CREATE TABLE userkeys ( -- persistent parameters storage (same as my AOL
Server module ns_userkey)\n" \
" id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n"
\
" save_date REAL NOT NULL DEFAULT (julianday('now'))
check(cast(save_date as real)=save_date),\n" \
" update_date REAL NOT NULL DEFAULT (julianday('now'))
check(cast(update_date as real)=update_date),\n" \
" delete_date REAL NOT NULL DEFAULT '' check(cast(delete_date as
real)=delete_date or delete_date = ''),\n" \
" unit text not null,\n"
\
" param text not null,\n"
\
" value text not null,\n"
\
" UNIQUE (unit,param) on conflict replace\n"
\
");"
static void userkey_installFunc(sqlite3_context *context, int argc,
sqlite3_value **argv){
sqlite3 *db;
int rc; /* Result code */
db = (sqlite3*) sqlite3_context_db_handle(context);
rc = sqlite3_exec(db, SCHEMA_USERKEY, NULL, NULL, NULL);
if( rc != SQLITE_OK ){
sqlite3_result_error(context, sqlite3_errmsg(db), -1);
return;
}
// return null value
sqlite3_result_null(context);
}
Best regards, Alexey Pechnikov.
http://pechnikov.tel/
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users