[sqlite] single gdbconn object with multiple threads.

2012-07-22 Thread Durga D
Hi all, I developed sample application with below logic: 1. in main(), got the valide gdbconn (type sqlite3*) after sqlite3_open and sqlite3_prepare_v2. 2. wal mode. 3. created 4 threads and passed gdbconn as a argument to threads. 4. Three are reader_threads. each reader

Re: [sqlite] how to write this sql command?

2012-07-22 Thread Rick Maddy
INSERT INTO myTable (Rd, en, ue) SELECT 'aa', 'bb', ue FROM othertable; Rick On Jul 22, 2012, at 7:41 PM, YAN HONG YE wrote: > INSERT INTO myTable (Rd, en, ue) VALUES ("aa","bb",select ue from othertable); ___ sqlite-users mailing list

[sqlite] how to write this sql command?

2012-07-22 Thread YAN HONG YE
INSERT INTO myTable (Rd, en, ue) VALUES ("aa","bb",select ue from othertable); ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Keith Medcalf
That will work. If you run the query in the CLI prefixed with explain (after having given the .explain command), you will see the actual code that the query engine executes. You will note that where it accesses strftime('%s', 'now') it is surrounded by a ONCE instruction, conditionally

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Kevin Martin
For now I've decided to play safe and I've added a added an 'ok' column to tell me if I'm within 5s of an update. > CREATE VIEW near_update as select count(*) as n from aliases where > abs(strftime('%s', 'now') - validFrom) < 5; > CREATE VIEW alias_info as select a.name, s.url, s.type, nu.n ==

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Keith Medcalf
Pavel, > No SQL format can guarantee anything. And changing SQL format won't change > its execution plan - SQL optimizer will decide that for you. Agreed. > And I don't know where did you take your information from but I can guarantee > you that with your query SQLite will execute strftime

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Pavel Ivanov
Keith, No SQL format can guarantee anything. And changing SQL format won't change its execution plan - SQL optimizer will decide that for you. And I don't know where did you take your information from but I can guarantee you that with your query SQLite will execute strftime many times and OP's

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Keith Medcalf
select a.name, a.assignedTo, a.validFrom from aliases a, (select name, max(validfrom) as mvf from aliases, (select strftime('%s', 'now') as now) as c where validFrom <= now group by name) as b where a.name=b.name and a.validfrom=b.mvf; should

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Simon Slavin
On 22 Jul 2012, at 6:48pm, Kevin Martin wrote: > Is the behaviour it will only run once guaranteed by any standard, or likely > to change in future/previous versions of sqlite? It's not predictable, even in the current version. SQLite can choose to re-prepare a prepared

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Kevin Martin
On 22 Jul 2012, at 18:35, Keith Medcalf wrote: Thanks for that. I can't say I understand much of that output at the moment. I'm just reading http://www.sqlite.org/eqp.html to try and figure it out. Is the behaviour it will only run once guaranteed by any standard, or likely to change in

Re: [sqlite] sql statement CREATE TABLE

2012-07-22 Thread Kevin Martin
On 22 Jul 2012, at 16:15, Arbol One wrote: > I am getting a run time error that reads > Library routine out of sequence http://sqlite.org/cvstrac/wiki?p=LibraryRoutineCalledOutOfSequence My guess is #1. What's the return value from the function you're calling to open the db? Thanks, Kevin

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Keith Medcalf
> > (select name, max(validfrom) as mvf from aliases where validFrom <= (select > > strftime('%s', 'now')) group by name) > I don't think that solves the problem because each time the group by query is > executed, your subquery will be executed again. Not possible. WHERE conditions are

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Kevin Martin
On 22 Jul 2012, at 16:37, Pavel Ivanov wrote: > You can execute "select strftime('%s', 'now')" first and then put its > result into your query. It seems as though the opinion is that it may execute multiple times. > But that won't work with view, of course. I'd rather keep the alias_info

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Kevin Martin
On 22 Jul 2012, at 17:06, Keith Medcalf wrote: > (select name, max(validfrom) as mvf from aliases where validFrom <= (select > strftime('%s', 'now')) group by name) I don't think that solves the problem because each time the group by query is executed, your subquery will be executed again.

Re: [sqlite] link error on dlopen dlerror reference undefined

2012-07-22 Thread Stephan Beal
On Sun, Jul 22, 2012 at 6:26 PM, Kf Lee wrote: > I copy the "sqlite with c in 5 minutes" example from official site and link > with -pthread -ldl option. The error persists. All web search seem to > suggest using -ldl would solve the problem but it did'nt. Therefore I >

[sqlite] link error on dlopen dlerror reference undefined

2012-07-22 Thread Kf Lee
I copy the "sqlite with c in 5 minutes" example from official site and link with -pthread -ldl option. The error persists. All web search seem to suggest using -ldl would solve the problem but it did'nt. Therefore I start to think maybe the os missed something . Do I need to install

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Keith Medcalf
If you want to make sure the strftime function is only called once why not say: CREATE VIEW latest_aliases as select a.name, a.assignedTo, a.validFrom from aliases as a join (select name, max(validfrom) as mvf from aliases where validFrom <= (select strftime('%s', 'now')) group by name) as b

Re: [sqlite] Current Time in WHEN clause.

2012-07-22 Thread Pavel Ivanov
> I'm trying to convince myself that the subquery in latest_aliases only > executes once, and also that alias_info only runs latest_aliases once. > However, I'm not doing very well at convincing myself. Can someone confirm > this is true, or suggest a nice solution to get the current time

[sqlite] sql statement CREATE TABLE

2012-07-22 Thread Arbol One
I am getting a run time error that reads = Error 1 Library routine out of sequence = The only things, since I am new on it, that could be causing a problem would be the sql statement CREATE TABLE, maybe the parameters are not right? The code nip - sql_param_tblName =

[sqlite] Current Time in WHEN clause.

2012-07-22 Thread Kevin Martin
Hi, I have the following schema: > CREATE TABLE aliases (name text not null, assignedTo text, validFrom integer > not null); > CREATE TABLE services (name text primary key, url text not null, type text > not null); > CREATE VIEW latest_aliases as select a.name, a.assignedTo, a.validFrom from