Re: [sqlite] Trigger Logic!!!

2013-07-21 Thread Peter Aronson
If you write a function in C, and register it with sqlite3_create_function (or one of its variants), you can then have a trigger like so: CREATE TRIGGER Event_test1 AFTER INSERT ON test BEGIN SELECT my_notifier_function(); END; And since it's a C function, you can do pretty much anything

[sqlite] Trigger Logic!!!

2013-07-21 Thread techi eth
I want to create a trigger on INSERT & in trigger logic I want to notify other running executable in system. Can I do this using trigger operation? Example: Create table (); CREATE TABLE test ( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, ); CREATE TRIGGER Event_test1 AFTER INSERT

Re: [sqlite] Multiple return values from aggregate function

2013-07-21 Thread Igor Tandetnik
On 7/21/2013 7:13 PM, ss griffon wrote: Following up to my previous question of ordering data sent to an aggregate function. Can anyone out there think of (or know of) a good way to return multiple values from an aggregate function? Perhaps a virtual table could be pressed into service

Re: [sqlite] Multiple return values from aggregate function

2013-07-21 Thread ss griffon
Ah, I overlooked that. That will work great, something like ema_csv() to return a csv string of all values. Thanks for the suggestion On Sun, Jul 21, 2013 at 4:35 PM, Simon Slavin wrote: > > On 22 Jul 2013, at 12:13am, ss griffon wrote: > > >

Re: [sqlite] Multiple return values from aggregate function

2013-07-21 Thread Simon Slavin
On 22 Jul 2013, at 12:13am, ss griffon wrote: > Can anyone out there think of (or know of) a good way to return multiple > values from an aggregate function? I couldn't. I returned them in a pipe-separated string: 317|8432|23|1433 Simon.

Re: [sqlite] Order By clause in aggregate functions?

2013-07-21 Thread Simon Slavin
On 21 Jul 2013, at 11:47pm, Igor Tandetnik wrote: > On 7/21/2013 5:01 PM, Simon Slavin wrote: >> I had to fake it. The parameter I passed to my aggregate function was a >> string as follows: >> >> theOrder||':'||theValue >> >> My function extension had to split the

[sqlite] Multiple return values from aggregate function

2013-07-21 Thread ss griffon
Following up to my previous question of ordering data sent to an aggregate function. Can anyone out there think of (or know of) a good way to return multiple values from an aggregate function? For example, if I have an "exponential moving average" function, ema(), I would like to return all of

Re: [sqlite] Order By clause in aggregate functions?

2013-07-21 Thread Igor Tandetnik
On 7/21/2013 5:01 PM, Simon Slavin wrote: I had to fake it. The parameter I passed to my aggregate function was a string as follows: theOrder||':'||theValue My function extension had to split the values into two parts Couldn't you just pass two parameters, separately? -- Igor Tandetnik

Re: [sqlite] Order By clause in aggregate functions?

2013-07-21 Thread ss griffon
On Sun, Jul 21, 2013 at 1:29 PM, Petite Abeille wrote: > > On Jul 21, 2013, at 10:15 PM, ss griffon wrote: > > > I'm writing an extension to SQLite that adds some aggregate functions. > > Some of them, require that the rows passed to the

Re: [sqlite] Order By clause in aggregate functions?

2013-07-21 Thread Simon Slavin
On 21 Jul 2013, at 9:29pm, Petite Abeille wrote: > Short answer: no. Right. I had to fake it. The parameter I passed to my aggregate function was a string as follows: theOrder||':'||theValue My function extension had to split the values into two parts, then sort

Re: [sqlite] Order By clause in aggregate functions?

2013-07-21 Thread Petite Abeille
On Jul 21, 2013, at 10:15 PM, ss griffon wrote: > I'm writing an extension to SQLite that adds some aggregate functions. > Some of them, require that the rows passed to the aggregate function > be sorted. It seems as if lots of data bases (MySQL, PostgreSQL) > support

[sqlite] Order By clause in aggregate functions?

2013-07-21 Thread ss griffon
I'm writing an extension to SQLite that adds some aggregate functions. Some of them, require that the rows passed to the aggregate function be sorted. It seems as if lots of data bases (MySQL, PostgreSQL) support an ORDER BY clause in their aggregate functions. Does SQLite support anything like

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread E.Pasma
Op 21 jul 2013, om 18:06 heeft Simon Slavin het volgende geschreven: On 21 Jul 2013, at 4:41pm, E.Pasma wrote: Is a change in SQLite imaginable such that column expressions are not re-evaluated with each reference to the column alias? ... ... This is partly because

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread Petite Abeille
On Jul 21, 2013, at 7:47 PM, Igor Tandetnik wrote: > This query is in fact perfectly legal. It's OK to refer to column aliases in > ORDER BY clause. Perhaps in SQLite, yes. select 1 as a order by 1; select 1 as a order by a; select x as a from ( select 1 as x ) order by

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread Igor Tandetnik
On 7/21/2013 12:06 PM, Simon Slavin wrote: One of the problems with this is that it's not standard SQL. You're not meant to be able to refer to column aliases inside the SELECT that defines them. For instance SELECT yearJoined AS y, ageWhenJoined AS a, (y-a) AS yob FROM members is not

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread Luuk
On 21-07-2013 12:01, E.Pasma wrote: Op 21 jul 2013, om 11:27 heeft Mikael het volgende geschreven: Hi Igor, Ah I just noticed how you wrote your query and it delivers for it indeed. Here's an arbitrary example verifying its works. Neat - thanks! sqlite3 test.sqlite create table categories

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread Keith Medcalf
You can also use this form: select id, a, b, 1.0 * a / b as c from ( select id, (select sum(v) from ot as ot1 where ot1.v > categories.id) as a, (select sum(v) from ot as ot2 where ot2.v < categories.id) AS b from categories order by +id ) order by c; > -Original Message- > From:

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread Simon Slavin
On 21 Jul 2013, at 4:41pm, E.Pasma wrote: > Is a change in SQLite imaginable such that column expressions are not > re-evaluated with each reference to the column alias? > This could also improve queries that use aliases only in the order by clause, > like > select id,

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread E.Pasma
Op 21 jul 2013, om 15:43 heeft Clemens Ladisch het volgende geschreven: RSmith wrote: On 2013/07/21 12:01, E.Pasma wrote: Only the execution plan of this query is not optimal: 0|0|0|SCAN TABLE categories (~100 rows) 0|0|0|EXECUTE CORRELATED SCALAR SUBQUERY 1 1|0|0|SCAN TABLE ot AS ot1

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread Clemens Ladisch
RSmith wrote: > On 2013/07/21 12:01, E.Pasma wrote: >> Only the execution plan of this query is not optimal: >> 0|0|0|SCAN TABLE categories (~100 rows) >> 0|0|0|EXECUTE CORRELATED SCALAR SUBQUERY 1 >> 1|0|0|SCAN TABLE ot AS ot1 (~33 rows) >> 0|0|0|EXECUTE CORRELATED SCALAR SUBQUERY 2 >>

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread RSmith
Well yes, the plan does not read like one would expect an optimal plan to read like - but to the purpose of the original request there is no more-optimal a plan, is there?. The entire column used to sort by is made up on the spot and therefore temp BTrees are needed and all the other quirks, as

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread E.Pasma
Op 21 jul 2013, om 11:27 heeft Mikael het volgende geschreven: Hi Igor, Ah I just noticed how you wrote your query and it delivers for it indeed. Here's an arbitrary example verifying its works. Neat - thanks! sqlite3 test.sqlite create table categories (id number); insert into

Re: [sqlite] Anything like "select 7 as a, 8 as b, a / b as c; " possible whatsoever?

2013-07-21 Thread Mikael
Hi Igor, Ah I just noticed how you wrote your query and it delivers for it indeed. Here's an arbitrary example verifying its works. Neat - thanks! sqlite3 test.sqlite create table categories (id number); insert into categories (id) values (5),(10),(15); create table ot (v number); insert into

Re: [sqlite] Using in-memory DBs of the form: of 20) 2 of 20) "file:memdb1?mode=memory=shared" (via Perl, DBD::SQLite & DBI)

2013-07-21 Thread sqlite . 20 . browseruk
On Sat, 20 Jul 2013 18:03:43 +0100, Simon Slavin - slav...@bigfraud.org wrote: On 20 Jul 2013, at 3:11pm, sqlite.20.browse...@xoxy.net wrote: this in-memory database actually persists. Ie. Beyond the life of the program that

[sqlite] Mag Gam

2013-07-21 Thread Mag Gam
http://ams-safetyproducts.com/ngrk/nly.dujbdbtwuxeg Mag Gam 7/21/2013 7:27:40 AM ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users