Hello everyone! i have been using function select_statement to execute SQL statements as SELECT, CREATE, DROP, INSERT etc.. then i`ve replaced insert by bind function because you ve told me about various advantages it has over insert.
now i have realized that in official documentation is also said that its better to use prepared statements instead of execute function.. I wonder does it apply for all cases? here is select function that i`ve used: int select_stmt(const char* stmt) { char *errmsg; int ret; int nrecs = 0; first_row = 1; ret = sqlite3_exec(db, stmt, select_callback, &nrecs, &errmsg); if(ret!=SQLITE_OK) { printf("Error in select statement %s [%s].\n", stmt, errmsg); getchar (); } else { printf("\n %d records returned.\n", nrecs); } return 0; } and new function which uses prepared statements: bool create (char * command) { sqlite3_stmt * statement2; if ( sqlite3_prepare (db, command, -1, &statement2, 0) != SQLITE_OK ) { int err = sqlite3_prepare (db, command, -1, &statement2, 0); const char * pErr = sqlite3_errmsg (db); printf ("\nError %d occured! \n %s", err, pErr ); return 1; } int smth= sqlite3_step (statement2); printf ("\n result code = %d \n", smth); //sqlite3_reset (statement2); sqlite3_finalize (statement2); return 0; } main : create ("CREATE TABLE two (a,b,c)"); create ("INSERT INTO two (a,b) VALUES (3, 1)"); create ("INSERT INTO two (a,b,c) VALUES (2, 8, 9)"); create ("INSERT INTO two (a,c) VALUES (4, 1)"); create ("SELECT * FROM two"); The thing is that create function does not execute last instruction: create ("SELECT * FROM two"); it returns sqlite_row instead of sqlite_done which i would expect.. I would appreciate if someone could explain me this.. Thanky in advance.. T -- View this message in context: http://old.nabble.com/execute-or-prepare%2Bstep%2Bfinalize-tp26299247p26299247.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users