Re: [sqlite] Problem with sqlite3_exec
Thank you Kees Nuyt It solves the problem. -- View this message in context: http://sqlite.1065341.n5.nabble.com/Problem-with-sqlite3-exec-tp74523p74579.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
Re: [sqlite] Problem with sqlite3_exec
On Fri, 14 Mar 2014 07:56:57 -0700 (PDT), khaloud1987 wrote: > the problem arises when I am trying to erase lines and I have a power failure > so that it deletes rows but sometimes I have a line that is deleted from the > first table and not from the second. > (yes i have a table with this name table2 and i can't read the return value > when it fails caused by the power failure) So, after a power failure, you want both deletes to have succeeded, or none at all. That behaviour is called atomicity (the A in ACID), and the way to obtain that is to wrap the statements in a transaction. BEGIN; DELETE FROM table1 WHERE ...; DELETE FROM table2 WHERE ...; COMMIT; -- Groet, Cordialement, Pozdrawiam, Regards, Kees Nuyt ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Problem with sqlite3_exec
the problem arises when I am trying to erase lines and I have a power failure so that it deletes rows but sometimes I have a line that is deleted from the first table and not from the second. (yes i have a table with this name table2 and i can't read the return value when it fails caused by the power failure) -- View this message in context: http://sqlite.1065341.n5.nabble.com/Problem-with-sqlite3-exec-tp74523p74556.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
Re: [sqlite] Problem with sqlite3_exec
On 3/13/2014 6:33 AM, khaloud1987 wrote: I have a problem with sqlite3_exec that the first delete execute suuccesfully but the second delete (table2) does not. My qustion is : sqlite_exec can return a value different with SQLITE_OK and it works ok What value does the second call return? What does sqlite3_errmsg return when sqlite3_exec fails? What does table2 macro expand to, and do you actually have a table with that name? -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Problem with sqlite3_exec
Hello, I have a problem with sqlite3_exec that the first delete execute suuccesfully but the second delete (table2) does not. My qustion is : sqlite_exec can return a value different with SQLITE_OK and it works ok this is my code: snprintf(query,q_size,"DELETE FROM " table1 " where record = %d", id); retval = sqlite3_exec(handle,query,0,0,0); if ( retval != SQLITE_OK ) { TRACE_ERROR("Error in sql query: %s", query); } else { snprintf(query,q_size,"DELETE FROM " table2 " where record_id = %d", id); retval = sqlite3_exec(handle,query,0,0,0); } -- View this message in context: http://sqlite.1065341.n5.nabble.com/Problem-with-sqlite3-exec-tp74519.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
Re: [sqlite] problem with sqlite3_exec() and select sql statemant
Use the correct SQL delimiter for a literal - single quotes, e.g. 'google.com'. Hari wrote: > Hi as i am new to sqlite. > I have problem when i am using sqlite3_exec() function with select > as i am using sqlite3_open() to opening database > then creating table and inserting some information using sqlite3_exec() > and 'create table' and 'insert into' > then again if i use sqlite3_exec() with select like > my sql statement is : select * from my_table where > Primarykey="google.com" > where google.com primary key and its related information is not already > in my table but it is returning > SQLITE_OK...even it must be return some error as that primary key is not > in my table. > .how should i get the error...when using select and if primary key will > not be there ..after creating table with using sqlite3_exec() function + > select sql statemant. > > Thanks in advance for any ideas > Harioum > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] problem with sqlite3_exec() and select sql statemant
Hello Hariom, - use single quotes around text constants: select * from my_table where Primarykey='google.com' - use sqlite3_prepare and sqlite3_step to select data. First call sqlite3_prepare for your statement and then sqlite3_step in al loop until it returns SQLITE_DONE - It is not an error if a select statement returns no rows because of a where clause. In this case, the first call to sqlite3_stepreturns SQLITE_DONE Martin Hari schrieb: > Hi as i am new to sqlite. > I have problem when i am using sqlite3_exec() function with select > as i am using sqlite3_open() to opening database > then creating table and inserting some information using sqlite3_exec() > and 'create table' and 'insert into' > then again if i use sqlite3_exec() with select like > my sql statement is : select * from my_table where > Primarykey="google.com" > where google.com primary key and its related information is not already > in my table but it is returning > SQLITE_OK...even it must be return some error as that primary key is not > in my table. > .how should i get the error...when using select and if primary key will > not be there ..after creating table with using sqlite3_exec() function + > select sql statemant. > > Thanks in advance for any ideas > Harioum > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- * Codeswift GmbH * Traunstr. 30 A-5026 Salzburg-Aigen Tel: +49 (0) 8662 / 494330 Mob: +49 (0) 171 / 4487687 Fax: +49 (0) 12120 / 204645 [EMAIL PROTECTED] www.codeswift.com / www.swiftcash.at Codeswift Professional IT Services GmbH Firmenbuch-Nr. FN 202820s UID-Nr. ATU 50576309 ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] problem with sqlite3_exec() and select sql statemant
Hi as i am new to sqlite. I have problem when i am using sqlite3_exec() function with select as i am using sqlite3_open() to opening database then creating table and inserting some information using sqlite3_exec() and 'create table' and 'insert into' then again if i use sqlite3_exec() with select like my sql statement is : select * from my_table where Primarykey="google.com" where google.com primary key and its related information is not already in my table but it is returning SQLITE_OK...even it must be return some error as that primary key is not in my table. .how should i get the error...when using select and if primary key will not be there ..after creating table with using sqlite3_exec() function + select sql statemant. Thanks in advance for any ideas Harioum ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] problem with sqlite3_exec method
Hello, I'm sorry but even after looking in the archives I haven't found any help on this subject : I'm testing a very simple C program that uses SQLite. The sqlite3_open method works fine and the database opens normaly, but then I get an error coming from the sqlite3_exec method : sqlite3_exec(db, "select * from tbl1" , callback, 0, &zErrMsg) The error is : SQL error: unsupported file format. The same SQL query works fine on the same database file with the command-line sqlite3 program. What am I missing here ? Thank you for your help...