Re: [sqlite] binding an IN

2010-07-11 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/11/2010 10:36 PM, zeal wrote: > how about (tableId=? or tableId=? or tableId=? or tableId=?) > just convert IN to or. Jay already mentioned that approach. The downside is you have to know how big the list is in advance and construct SQL text wi

Re: [sqlite] binding an IN

2010-07-11 Thread zeal
how about (tableId=? or tableId=? or tableId=? or tableId=?) just convert IN to or. -- From: "Roger Binns" Sent: Monday, July 12, 2010 11:00 AM To: "General Discussion of SQLite Database" Subject: Re: [sqlite] binding an IN > -BEGIN PGP SIGNE

Re: [sqlite] database is locked(5) too often - what am i doing wrong?

2010-07-11 Thread Simon Slavin
On 12 Jul 2010, at 5:37am, raf wrote: > Each page hit results in several database writes each of which is currently > in a separate transaction. Is combining these into a single transaction likely > to help or make matters worse? Or is this just an inappropriate use of sqlite? It will probably m

Re: [sqlite] update trigger to require input

2010-07-11 Thread Jay A. Kreibich
On Sun, Jul 11, 2010 at 01:46:19PM -0400, Sam Carleton scratched on the wall: > I have some audit fields, one being updatedby, I would like to create an > update trigger that would prevent the row from being updated if this was not > set. Can I do that in sqlite? Define "not set." You can make

[sqlite] database is locked(5) too often - what am i doing wrong?

2010-07-11 Thread raf
Greetings, I've been using sqlite-3.4.2 for a customer-only website for a few years now and the number of users has recently grown to the point where I'm now seeing too many "database is locked(5)" (i.e. busy) errors. When my code gets a "database is locked(5)" error, it sleeps for a random perio

Re: [sqlite] restricting values allowed in a column

2010-07-11 Thread Jay A. Kreibich
On Sun, Jul 11, 2010 at 02:15:09PM -0400, Igor Tandetnik scratched on the wall: > Jay A. Kreibich wrote: > > You can't add a CHECK constraint to an existing table. > > You should be able to do it by directly updating sqlite_master table: > > http://old.nabble.com/Any-workarounds-suggestions-fo

Re: [sqlite] binding an IN

2010-07-11 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/11/2010 06:42 PM, Sam Carleton wrote: > Is there any way to bind to this query? > > SELECT * FROM table WHERE tableId IN ( ? ); > > Where ? should be 1,2,3,4 There is no C api that allows for binding a list so you'll have to pick an alternativ

Re: [sqlite] restricting values allowed in a column

2010-07-11 Thread Jay A. Kreibich
On Sun, Jul 11, 2010 at 07:51:18PM +, c...@comcast.net scratched on the wall: > Creating a new db with the added constraint is not  problem for me > at this time. > If I wanted to allows only values "yes" or "no" or "maybe" in the > recommendation column would I do it like this when I creat

Re: [sqlite] binding an IN

2010-07-11 Thread Simon Slavin
On 12 Jul 2010, at 2:42am, Sam Carleton wrote: > Is there any way to bind to this query? > > SELECT * FROM table WHERE tableId IN ( ? ); > > Where ? should be 1,2,3,4 I think the simplest way to do that would be to use GLOB. Not very elegant but it should work. http://www.sqlite.org/lang_ex

Re: [sqlite] binding an IN

2010-07-11 Thread Jay A. Kreibich
On Sun, Jul 11, 2010 at 09:42:41PM -0400, Sam Carleton scratched on the wall: > Is there any way to bind to this query? > > SELECT * FROM table WHERE tableId IN ( ? ); > > Where ? should be 1,2,3,4 You can do IN ( ?, ?, ?, ? ), but I'm guessing that's not the answer you're looking for. Th

[sqlite] binding an IN

2010-07-11 Thread Sam Carleton
Is there any way to bind to this query? SELECT * FROM table WHERE tableId IN ( ? ); Where ? should be 1,2,3,4 ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] restricting values allowed in a column

2010-07-11 Thread ca44
Hi Jay, Creating a new db with the added constraint is not  problem for me at this time. If I wanted to allows only values "yes" or "no" or "maybe" in the recommendation column would I do it like this when I created the table -    recommendation varchar(4) CHECK(recommendation='yes' |

Re: [sqlite] restricting values allowed in a column

2010-07-11 Thread Igor Tandetnik
Jay A. Kreibich wrote: > You can't add a CHECK constraint to an existing table. You should be able to do it by directly updating sqlite_master table: http://old.nabble.com/Any-workarounds-suggestions-for-dropping-a-not-null-constraint--td27439289.html It would probably be prudent to first mak

Re: [sqlite] update trigger to require input

2010-07-11 Thread Simon Slavin
On 11 Jul 2010, at 6:46pm, Sam Carleton wrote: > I have some audit fields, one being updatedby, I would like to create an > update trigger that would prevent the row from being updated if this was not > set. Can I do that in sqlite? Use a TRIGGER on BEFORE UPDATE. In the TRIGGER check that new

[sqlite] update trigger to require input

2010-07-11 Thread Sam Carleton
I have some audit fields, one being updatedby, I would like to create an update trigger that would prevent the row from being updated if this was not set. Can I do that in sqlite? ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:80

Re: [sqlite] restricting values allowed in a column

2010-07-11 Thread Jay A. Kreibich
On Sun, Jul 11, 2010 at 09:12:09AM -0500, Jay A. Kreibich scratched on the wall: > On Sun, Jul 11, 2010 at 01:45:50PM +, c...@comcast.net scratched on the > wall: > > > I would like to restrict the values that are entered into > > the "recommendation" column. > > > > How would I state that

Re: [sqlite] restricting values allowed in a column

2010-07-11 Thread Jay A. Kreibich
On Sun, Jul 11, 2010 at 01:45:50PM +, c...@comcast.net scratched on the wall: > I would like to restrict the values that are entered into > the "recommendation" column. > > How would I state that at the time I create the column in that table? Using a CHECK constraint. > Since that tabl

[sqlite] restricting values allowed in a column

2010-07-11 Thread ca44
I have a table schema that looks like this: _ID integer primary key autoincrement name varchar(40) category varchar(40) recommendation varchar(40) I would like to restrict the values that are entered into the "recommendation" column. How would I state that at the time I create the

Re: [sqlite] EXTERNAL:Re: EXTERNAL: why is this table locked?

2010-07-11 Thread Black, Michael (IS)
Oops -- sorry guys...I got a little click-happy...not enough caffeine yet... Michael D. Black Senior Scientist Northrop Grumman Mission Systems ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sq

Re: [sqlite] EXTERNAL: why is this table locked?

2010-07-11 Thread Black, Michael (IS)
Version 1.44 checked in. I also added a setDatabaseFile(char *) and getDatabaseFile() just now complete the file name set. cluster = new Cluster(); cluster->setDatabaseFile("cluster.db"); cluster->dbDelete(); cluster->setHistoFile("histo.csv"); cluster->setHistoSortedFile("