Re: [sqlite] Idea: defining table-valued functions directly in SQL

2018-07-07 Thread E.Pasma
> 4 jul. 2018, Andy Goth: > Revisiting this topic... > > On 06/10/18 08:04, sql...@zzo38computer.org wrote: >> * Perhaps move PARAMETERS before AS, which may make the syntax easier. > > Like so? > > CREATE VIEW double PARAMETERS (arg) AS SELECT arg * 2; > SELECT * FROM numbers, double(x); > >

Re: [sqlite] Fwd: ON CONFLICT parser bug?

2018-07-07 Thread Paul van Helden
> > > > A SELECT in an UPSERT should always contain a WHERE clause. Like this: > >INSERT INTO t1(a) SELECT a FROM t2 WHERE true ON CONFLICT(A) DO NOTHING; > > Without the WHERE clause, the ON keyword tricks the parser into > thinking it is processing an "ON" join constraint on the FROM

Re: [sqlite] Fwd: ON CONFLICT parser bug?

2018-07-07 Thread Richard Hipp
On 7/7/18, Paul van Helden wrote: > Hi, > > I've used the new UPSERT with success with a complex SELECT, then got to > scratch my head for a while on a much simpler query, so assuming this might > be a bug: > > CREATE TABLE T2 (A INTEGER PRIMARY KEY); > INSERT INTO T2 VALUES (1); > CREATE TABLE

Re: [sqlite] Fwd: ON CONFLICT parser bug?

2018-07-07 Thread Simon Slavin
On 7 Jul 2018, at 3:07pm, Paul van Helden wrote: > INSERT INTO T1 (A) SELECT A FROM T2 ON CONFLICT(A) DO NOTHING; It's possible that many people miss this construction because SQLite has INSERT OR IGNORE INTO T1 (A) SELECT A FROM T2; Simon. ___

[sqlite] Fwd: ON CONFLICT parser bug?

2018-07-07 Thread Paul van Helden
Hi, I've used the new UPSERT with success with a complex SELECT, then got to scratch my head for a while on a much simpler query, so assuming this might be a bug: CREATE TABLE T2 (A INTEGER PRIMARY KEY); INSERT INTO T2 VALUES (1); CREATE TABLE T1 (A INTEGER PRIMARY KEY); INSERT INTO T1 VALUES

Re: [sqlite] Automatic numbering

2018-07-07 Thread Cecil Westerhof
2018-07-07 14:57 GMT+02:00 Simon Slavin : > On 7 Jul 2018, at 12:04pm, Cecil Westerhof wrote: > > > ​I went for the following solution: > >UPDATE > ​​ > ​​ > selectRandom > >SETlastUsed= DATE('now', 'localtime') > >, lastUsedIdx = ( > >SELECT

Re: [sqlite] Automatic numbering

2018-07-07 Thread Simon Slavin
On 7 Jul 2018, at 12:04pm, Cecil Westerhof wrote: > ​I went for the following solution: >UPDATE selectRandom >SETlastUsed= DATE('now', 'localtime') >, lastUsedIdx = ( >SELECT IFNULL(MAX(lastUsedIdx), 0) >FROM selectRandom >WHERE lastUsed =

Re: [sqlite] Automatic numbering

2018-07-07 Thread Cecil Westerhof
2018-07-05 5:37 GMT+02:00 Simon Slavin : > On 5 Jul 2018, at 3:22am, Cecil Westerhof wrote: > > > I only want to store a date with a record. But it is possible that more > as > > one record will be inserted, so I want to use another field to use as an > > index. So that the first gets an one,