[sqlite] Re triving the database name from the sqlite pointer ....

2009-08-18 Thread Atul_Vaidya
Hi, I have a Sqlite3 pointer. Is there any way to get the filename of this pointer ? Regards, Atul -- View this message in context: http://www.nabble.com/Retriving-the-database-name-from-the-sqlite-pointer--tp25020127p25020127.html Sent from the SQLite mailing list archive at Nabble.com.

Re: [sqlite] Re triving the database name from the sqlite pointer ....

2009-08-18 Thread Simon Davies
2009/8/18 Atul_Vaidya : > > Hi, >   I have a Sqlite3 pointer. Is there any way to get the filename of this > pointer ? Execute "PRAGMA database_list;" See http://www.sqlite.org/pragma.html#pragma_database_list > Regards, > Atul Rgds, Simon

[sqlite] INSERT with multiple VALUES clause?

2009-08-18 Thread Terrence Brannon
Hello, when converting a .sql file containing MySQL INSERT clauses, one often runs into the problem that the MySQL INSERT can accept multiple VALUES arguments: INSERT INTO actor VALUES (1,'PENELOPE','GUINESS','2006-02-15 04:34:33'),(2,'NICK','WAHLBERG','2006-02-15

Re: [sqlite] INSERT with multiple VALUES clause?

2009-08-18 Thread Beau Wilkinson
To me that seems like an annoying deviation from standard practice. Do other databases support such an INSERT? Is it envisioned by standards? I suspect the answer is "no" in both cases, and this is a classic example of how "less" functionality is actually "more" useful. That said, if you're in

Re: [sqlite] INSERT with multiple VALUES clause?

2009-08-18 Thread Jay A. Kreibich
On Tue, Aug 18, 2009 at 08:28:13AM -0500, Beau Wilkinson scratched on the wall: > To me that seems like an annoying deviation from standard practice. > Do other databases support such an INSERT? Yes. MySQL, PostgreSQL, and SQLServer all support this syntax. Oracle supports a slightly

Re: [sqlite] INSERT with multiple VALUES clause?

2009-08-18 Thread Beau Wilkinson
>On Tue, Aug 18, 2009 at 08:28:13AM -0500, Beau Wilkinson scratched on the wall: >> To me that seems like an annoying deviation from standard practice. >> Do other databases support such an INSERT? > >Yes. MySQL, PostgreSQL, and SQLServer all support this syntax. > >Oracle supports a slightly

Re: [sqlite] INSERT with multiple VALUES clause?

2009-08-18 Thread John Machin
On 18/08/2009 11:28 PM, Beau Wilkinson wrote: > That said, if you're in posession of the source code, > you can certainly hack something up to support that. > A better option might be to pre-process the MySQL file > using C, Perl, XSLT (just kidding - don't use XSLT) > or whatever else you

Re: [sqlite] INSERT with multiple VALUES clause?

2009-08-18 Thread Jay A. Kreibich
On Tue, Aug 18, 2009 at 09:42:53AM -0500, Beau Wilkinson scratched on the wall: > >On Tue, Aug 18, 2009 at 08:28:13AM -0500, Beau Wilkinson scratched on the > >wall: > > It is also worth noting that every non-SQL Relational language (e.g. > > Tutorial-D) I've looked at supports some form of

[sqlite] Rows where people connected in the past 2 weeks?

2009-08-18 Thread Gilles Ganault
Hello I thought this query would work to read a date column that holds the DD-MM- date when the user last logged on, and check how many of them logged on in the past two weeks for the last time: SELECT COUNT(id) FROM members WHERE (julianday('now') - julianday(dateconnection)) < 15; This is

[sqlite] Increment a value if constraint violated

2009-08-18 Thread andrew fabbro
What is the most efficient way to code either a trigger or the app so that it increments a "count" field if the "id" field exists? For example, say you have a table with fields of "id" and "count". First row is an id of 3, so "count" is set to 1. Next row is an id of 4, so "count" is set to 1.

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Simon Slavin
On 18 Aug 2009, at 6:06pm, andrew fabbro wrote: > What is the most efficient way to code either a trigger or the app > so that > it increments a "count" field if the "id" field exists? > > For example, say you have a table with fields of "id" and "count". > > First row is an id of 3, so

Re: [sqlite] Rows where people connected in the past 2 weeks?

2009-08-18 Thread Pavel Ivanov
Just try these and you'll see why. sqlite> select julianday('18-08-2009'); sqlite> select julianday('now') - julianday('18-08-2009'); Pavel On Tue, Aug 18, 2009 at 12:58 PM, Gilles Ganault wrote: > Hello > > I thought this query would work to read a date column that

Re: [sqlite] Rows where people connected in the past 2 weeks?

2009-08-18 Thread Robert Citek
To expand on things to try: sqlite> select julianday('now'); sqlite> select julianday('2009-08-01'); sqlite> select julianday('now') - julianday('2009-08-01'); And maybe have a look here: http://sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions Regards, - Robert On Tue, Aug 18, 2009 at 1:25

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Pavel Ivanov
You can always do insert into table (id, count) values (?1, (select count(*) + 1 from table where id = ?1)) Though I'd be cautious about race condition that seems like possible here when after select returned some value and before insert was made another process made another insert with the same

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Dan Kennedy
On Aug 19, 2009, at 12:35 AM, Pavel Ivanov wrote: > You can always do > > insert into table (id, count) values (?1, (select count(*) + 1 from > table where id = ?1)) > > Though I'd be cautious about race condition that seems like possible > here when after select returned some value and before

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Dan Kennedy
On Aug 19, 2009, at 12:54 AM, Dan Kennedy wrote: > > On Aug 19, 2009, at 12:35 AM, Pavel Ivanov wrote: > >> You can always do >> >> insert into table (id, count) values (?1, (select count(*) + 1 from >> table where id = ?1)) >> >> Though I'd be cautious about race condition that seems like

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Pavel Ivanov
> Cannot happen. If not executed within an implicit transaction, each > SQL statement is effectively wrapped in a transaction all of its own. So executing the insert/update/delete statement places RESERVED lock right from the start before executing nested selects? Pavel On Tue, Aug 18, 2009 at

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Dan Kennedy
On Aug 19, 2009, at 1:01 AM, Pavel Ivanov wrote: >> Cannot happen. If not executed within an implicit transaction, each >> SQL statement is effectively wrapped in a transaction all of its own. > > So executing the insert/update/delete statement places RESERVED lock > right from the start before

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Pavel Ivanov
>> So executing the insert/update/delete statement places RESERVED lock >> right from the start before executing nested selects? > > Yes. Then I stand corrected. Thank you. Pavel On Tue, Aug 18, 2009 at 2:04 PM, Dan Kennedy wrote: > > On Aug 19, 2009, at 1:01 AM, Pavel

[sqlite] AIX test failures for 3.6.17

2009-08-18 Thread Ken
Running make test resulted in the following failures on aix 5.3 Note that the CFLAGS=-DSQLITE_DISABLE_DIRSYNC was set for the make. 14 errors out of 40926 tests Failures on these tests: backup2-10 io-4.1 io-4.2.3 nan-1.1.2 nan-1.1.3 nan-1.1.4 nan-1.1.5 nan-1.1.5 nan-4.7 nan-4.8 nan-4.14 nan-4.15

[sqlite] use of parentheses when not arithmetically or logically required

2009-08-18 Thread yaconsult
I have searched the list and understand the need for parentheses when required by logical or arithmetic operations or subselects. My question is if it makes a difference to use parentheses when not logically required, as in the following example where the only logical used is "and":

Re: [sqlite] use of parentheses when not arithmetically or logically required

2009-08-18 Thread Simon Slavin
On 18 Aug 2009, at 10:26pm, yaconsult wrote: > My question is if it makes a difference to use parentheses when not > logically required, as in the following example where the only > logical used > is "and": > >select * from log >where > (response >= 200 and

Re: [sqlite] use of parentheses when not arithmetically or logically required

2009-08-18 Thread yaconsult
Simon, Thank you for the optimization. I'll switch to using between. This particular database is used for generating some statistics and generating reports, so performance is not that big an issue. When you talk about "clever use of an index", are you referring to a combined index or merely

Re: [sqlite] use of parentheses when not arithmetically or logically required

2009-08-18 Thread D. Richard Hipp
On Aug 18, 2009, at 5:26 PM, yaconsult wrote: > > My question is if it makes a difference to use parentheses when not > logically required, as in the following example where the only > logical used > is "and": > >select * from log >where > (response >= 200

[sqlite] Clarification of string pointer lifetime

2009-08-18 Thread Shaun Seckman (Firaxis)
Hey everyone, The documentation for sqlite3_column_text() states that the string returned will always be NULL and that the pointers are valid until sqlite3_step(), sqlite3_reset() or sqlite3_finalize() is called. Is this ONLY when the same prepared statement is used in those

Re: [sqlite] use of parentheses when not arithmetically or logically required

2009-08-18 Thread Simon Slavin
On 19 Aug 2009, at 12:01am, yaconsult wrote: > Simon, > > Thank you for the optimization. I'll switch to using between. This > particular database is used for generating some statistics and > generating > reports, so performance is not that big an issue. DRH's post trumps mine, of course.

Re: [sqlite] INSERT with multiple VALUES clause?

2009-08-18 Thread Kit
2009/8/18 Terrence Brannon : > Hello, when converting a .sql file containing MySQL INSERT clauses, > one often runs into the problem that the MySQL INSERT can accept > multiple VALUES arguments: > >INSERT INTO actor VALUES (1,'PENELOPE','GUINESS','2006-02-15 >

Re: [sqlite] use of parentheses when not arithmetically or logically required

2009-08-18 Thread John Machin
On 19/08/2009 11:26 AM, Simon Slavin wrote: > DRH's post trumps mine, of course. I'm surprised to find that > brackets are optimised out of WHERE evaluations. Why? In the OP's example (all AND operators) the parentheses are redundant. In SQL, AND and OR are not guaranteed to be

Re: [sqlite] Increment a value if constraint violated

2009-08-18 Thread Igor Tandetnik
andrew fabbro wrote: > What is the most efficient way to code either a trigger or the app so > that it increments a "count" field if the "id" field exists? > > For example, say you have a table with fields of "id" and "count". > > First row is an id of 3, so "count" is set to 1. > Next row is an

Re: [sqlite] AIX test failures for 3.6.17

2009-08-18 Thread Shane Harrelson
On Tue, Aug 18, 2009 at 3:28 PM, Ken wrote: > Running make test resulted in the following failures on aix 5.3 > Note that the CFLAGS=-DSQLITE_DISABLE_DIRSYNC was set for the make. > > 14 errors out of 40926 tests > Failures on these tests: backup2-10 io-4.1 io-4.2.3