Re: [sqlite] Select and deletion
On 2/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: DragonK <[EMAIL PROTECTED]> wrote: > > So, as I understand it, this is supported from version 3.3.8 upwards, right? > Correct. Thanks for straigthening out the issue! :) -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] - -- ...it's only a matter of time...
Re: [sqlite] Select and deletion
On 2/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Perhaps what Jay did occurred before [3355] (first released with 3.3.8) and what DragonK did occurred afterwards. http://www.sqlite.org/cvstrac/chngview?cn=3355 That explains it. You have a phenomenal memory for detail! -- The PixAddixImage Collector suite: http://groups-beta.google.com/group/pixaddix SqliteImporter and SqliteReplicator: Command line utilities for Sqlite http://www.reddawn.net/~jsprenkl/Sqlite Cthulhu Bucks! http://www.cthulhubucks.com
Re: [sqlite] Select and deletion
DragonK <[EMAIL PROTECTED]> wrote: > > So, as I understand it, this is supported from version 3.3.8 upwards, right? > Correct. -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Select and deletion
On 2/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: "Jay Sprenkle" <[EMAIL PROTECTED]> wrote: > On 2/7/07, DragonK <[EMAIL PROTECTED]> wrote: > > > > > > This seems to work... but I'm not sure if it should, that's why I'm > > asking. > > I hope the code will show more exactly what I intend to do. Sorry for the > > lack of proper error checking, it's just a test program. :) Also, I'm not > > using any transactions, just the PRAGMA synchronous= off; > > If it works that's great. I would double check that it did work correctly. > I'll have to poke around now and see why what I did, which was pretty > similar, didn't work. > Perhaps what Jay did occurred before [3355] (first released with 3.3.8) and what DragonK did occurred afterwards. http://www.sqlite.org/cvstrac/chngview?cn=3355 So, as I understand it, this is supported from version 3.3.8 upwards, right? -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] - -- ...it's only a matter of time...
Re: [sqlite] Select and deletion
"Jay Sprenkle" <[EMAIL PROTECTED]> wrote: > On 2/7/07, DragonK <[EMAIL PROTECTED]> wrote: > > > > > > This seems to work... but I'm not sure if it should, that's why I'm > > asking. > > I hope the code will show more exactly what I intend to do. Sorry for the > > lack of proper error checking, it's just a test program. :) Also, I'm not > > using any transactions, just the PRAGMA synchronous= off; > > If it works that's great. I would double check that it did work correctly. > I'll have to poke around now and see why what I did, which was pretty > similar, didn't work. > Perhaps what Jay did occurred before [3355] (first released with 3.3.8) and what DragonK did occurred afterwards. http://www.sqlite.org/cvstrac/chngview?cn=3355 -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Select and deletion
On 2/8/07, Jay Sprenkle <[EMAIL PROTECTED]> wrote: On 2/7/07, DragonK <[EMAIL PROTECTED]> wrote: > > > This seems to work... but I'm not sure if it should, that's why I'm > asking. > I hope the code will show more exactly what I intend to do. Sorry for the > lack of proper error checking, it's just a test program. :) Also, I'm not > using any transactions, just the PRAGMA synchronous= off; If it works that's great. I would double check that it did work correctly. I'll have to poke around now and see why what I did, which was pretty similar, didn't work. Please inform me if you find anything wrong with this scenario, because I want to use something similar in production code. Also, I'd appreciate any other opinions if some of you tried something similar and had good/bad results. I don't know the internals of SQLite or of databases in general, but in this case i think the database knows the next row to be selected and deleting the currently selected row would not interfere with the select operation i think :) Thanks! -- The PixAddixImage Collector suite: http://groups-beta.google.com/group/pixaddix SqliteImporter and SqliteReplicator: Command line utilities for Sqlite http://www.reddawn.net/~jsprenkl/Sqlite Cthulhu Bucks! http://www.cthulhubucks.com -- ...it's only a matter of time...
Re: [sqlite] Select and deletion
On 2/7/07, DragonK <[EMAIL PROTECTED]> wrote: This seems to work... but I'm not sure if it should, that's why I'm asking. I hope the code will show more exactly what I intend to do. Sorry for the lack of proper error checking, it's just a test program. :) Also, I'm not using any transactions, just the PRAGMA synchronous= off; If it works that's great. I would double check that it did work correctly. I'll have to poke around now and see why what I did, which was pretty similar, didn't work. -- The PixAddixImage Collector suite: http://groups-beta.google.com/group/pixaddix SqliteImporter and SqliteReplicator: Command line utilities for Sqlite http://www.reddawn.net/~jsprenkl/Sqlite Cthulhu Bucks! http://www.cthulhubucks.com
Re: [sqlite] Select and deletion
On 2/7/07, anis chaaba <[EMAIL PROTECTED]> wrote: with which language are you trying to do this? to execute the delete statement you can use transactions to ensure atomicity. regards, I'm using a C++ wrapper over sqlite. The code i'm running is the following: SQLiteWrapper w; w.Open("test.db"); w.DirectStatement("CREATE TABLE asd(ID INTEGER, A INTEGER, B TEXT);"); w.DirectStatement("PRAGMA synchronous = OFF;"); char buf[1024]; for (int i = 0 ; i < 1000; i++) { sprintf(buf,"INSERT INTO asd VALUES(%d, %d, 'asd')", i, rand() % 6 ); w.DirectStatement(buf); } // See how many rows with int == 2 we have SQLiteStatement* s = w.Statement("SELECT COUNT(*) FROM asd WHERE A=2;"); s->NextRow(); int cnt = s->ValueInt(0); fprintf(stdout,"\nCount=%d", cnt); delete s; int cnt_real = 0; s = w.Statement("SELECT ID FROM asd WHERE A=2;"); while (s->NextRow()) { int id = s->ValueInt(0); char buff[256]; sprintf(buff,"DELETE FROM asd WHERE ID=%d", id); if ( w.DirectStatement(buff) ) { cnt_real++; } else { fprintf(stderr,"\nError..."); } } delete s; fprintf(stdout,"\nDeleted count=%d\n", cnt_real); w.Close(); This seems to work... but I'm not sure if it should, that's why I'm asking. I hope the code will show more exactly what I intend to do. Sorry for the lack of proper error checking, it's just a test program. :) Also, I'm not using any transactions, just the PRAGMA synchronous= off; -- ...it's only a matter of time...
Re: [sqlite] Select and deletion
On 2/7/07, DragonK <[EMAIL PROTECTED]> wrote: Hello everybody, I'm wondering if the following scenario would work properly: Run a SELECT query on the database and in a loop retrieve each result; for each retrieved result, inside the same loop, execute a DELETE statement for the previously extracted row. I need this in order to retrieve a list of filenames from the database and delete each file from the hard disk and from the database also and I'm trying to avoid creating a temporary list for storing the file names. I think it won't. Try selecting the list into memory or a temp table, then using that to delete in a separate step. -- The PixAddixImage Collector suite: http://groups-beta.google.com/group/pixaddix SqliteImporter and SqliteReplicator: Command line utilities for Sqlite http://www.reddawn.net/~jsprenkl/Sqlite Cthulhu Bucks! http://www.cthulhubucks.com
Re: [sqlite] Select and deletion
with which language are you trying to do this? to execute the delete statement you can use transactions to ensure atomicity. regards,