Re: [sqlite] TRIGGER syntax

2013-11-01 Thread Simon Slavin
On 1 Nov 2013, at 4:59am, Igor Korot wrote: > I'm not sure I understand. > Are you saying that I don't have to populate the rank in the table on > insertion? Yes. >> Given your description above, why try to get all the ranks right every time >> you do an INSERT ? > >

Re: [sqlite] TRIGGER syntax

2013-10-31 Thread Igor Korot
Simon, On Thu, Oct 31, 2013 at 9:39 PM, Simon Slavin wrote: > > On 1 Nov 2013, at 4:15am, Igor Korot wrote: > >> I'm not trying to change an order of my rows. >> Look at it this way: >> I have a league with some teams. When the league is created the >>

Re: [sqlite] TRIGGER syntax

2013-10-31 Thread Simon Slavin
On 1 Nov 2013, at 4:15am, Igor Korot wrote: > I'm not trying to change an order of my rows. > Look at it this way: > I have a league with some teams. When the league is created the > players needs to be put in from the players pool. In order to assign > the rank inside the

Re: [sqlite] TRIGGER syntax

2013-10-31 Thread Igor Korot
Simon, On Thu, Oct 31, 2013 at 8:51 PM, Simon Slavin wrote: > > On 1 Nov 2013, at 2:15am, Igor Korot wrote: > >> When the record is inserted with the field1 as NULL, I want to have >> the field1 to have value max( field1 ) + 1. >> When the record

Re: [sqlite] TRIGGER syntax

2013-10-31 Thread Simon Slavin
On 1 Nov 2013, at 2:15am, Igor Korot wrote: > When the record is inserted with the field1 as NULL, I want to have > the field1 to have value max( field1 ) + 1. > When the record inserted have some value in field1, i.e. field1 == 5, > I want all records that have field1 > 5

Re: [sqlite] TRIGGER syntax

2013-10-31 Thread Keith Medcalf
ssus.com] >Sent: Thursday, 31 October, 2013 21:27 >To: 'General Discussion of SQLite Database' >Subject: RE: [sqlite] TRIGGER syntax > > >https://www.sqlite.org/lang_createtrigger.html > >CREATE TRIGGER foo AFTER INSERT ON table >BEGIN > UPDATE table >SET field1 =

Re: [sqlite] TRIGGER syntax

2013-10-31 Thread Igor Tandetnik
On 10/31/2013 11:26 PM, Keith Medcalf wrote: https://www.sqlite.org/lang_createtrigger.html CREATE TRIGGER foo AFTER INSERT ON table BEGIN UPDATE table SET field1 = field1 + 1 WHERE new.field1 IS NOT NULL AND field1 > new.field1; UPDATE table SET field1 = (SELECT

Re: [sqlite] TRIGGER syntax

2013-10-31 Thread Keith Medcalf
wid AND new.field1 IS NULL; END; >-Original Message- >From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- >boun...@sqlite.org] On Behalf Of Igor Korot >Sent: Thursday, 31 October, 2013 20:16 >To: General Discussion of SQLite Database >Subject: Re: [sqlite] TRIGGER syntax &g

Re: [sqlite] TRIGGER syntax

2013-10-31 Thread Igor Korot
Igor, On Thu, Oct 31, 2013 at 5:33 PM, Igor Tandetnik wrote: > On 10/31/2013 8:22 PM, Igor Korot wrote: >> >> Hi, ALL, >> In the CREATE TRIGGER can I use something like this: >> >> CREATE TRIGGER foo AFTER INSERT >> BEGIN >> IF foo.field1 IS NULL >> UPDATE

Re: [sqlite] TRIGGER syntax

2013-10-31 Thread Igor Tandetnik
On 10/31/2013 8:22 PM, Igor Korot wrote: Hi, ALL, In the CREATE TRIGGER can I use something like this: CREATE TRIGGER foo AFTER INSERT BEGIN IF foo.field1 IS NULL UPDATE foo SET field1 = ; ELSE UPDATE foo SET field1 = field1 + 1 WHERE field1 > new.; END;

[sqlite] TRIGGER syntax

2013-10-31 Thread Igor Korot
Hi, ALL, In the CREATE TRIGGER can I use something like this: CREATE TRIGGER foo AFTER INSERT BEGIN IF foo.field1 IS NULL UPDATE foo SET field1 = ; ELSE UPDATE foo SET field1 = field1 + 1 WHERE field1 > new.; END; My concern is if CREATE TRIGER will understand

Re: [sqlite] Trigger, syntax question

2012-06-04 Thread Wolfgang Meiners
Am 04.06.12 19:36, schrieb Igor Tandetnik: > > http://sqlite.org/lang.html > http://sqlite.org/syntaxdiagrams.html > I just found the case expression. I did not know it before. Thank you for pointing me to that direction! Wolfgang ___ sqlite-users

Re: [sqlite] Trigger, syntax question

2012-06-04 Thread Wolfgang Meiners
Am 04.06.12 19:31, schrieb Michael Schlenker: > Am 04.06.2012 19:25, schrieb Wolfgang Meiners: >> Am 04.06.12 18:59, schrieb Igor Tandetnik: >>> On 6/4/2012 12:33 PM, Wolfgang Meiners wrote: this trigger does work but i think it is not in accordance with the syntax diagram of TRIGGER on

Re: [sqlite] Trigger, syntax question

2012-06-04 Thread Igor Tandetnik
On 6/4/2012 1:25 PM, Wolfgang Meiners wrote: Am 04.06.12 18:59, schrieb Igor Tandetnik: On 6/4/2012 12:33 PM, Wolfgang Meiners wrote: this trigger does work but i think it is not in accordance with the syntax diagram of TRIGGER on http://sqlite.com/lang_createtrigger.html Which part do you

Re: [sqlite] Trigger, syntax question

2012-06-04 Thread Michael Schlenker
Am 04.06.2012 19:25, schrieb Wolfgang Meiners: > Am 04.06.12 18:59, schrieb Igor Tandetnik: >> On 6/4/2012 12:33 PM, Wolfgang Meiners wrote: >>> this trigger does work but i think it is not in accordance with the >>> syntax diagram of TRIGGER on >>> http://sqlite.com/lang_createtrigger.html >> >>

Re: [sqlite] Trigger, syntax question

2012-06-04 Thread Wolfgang Meiners
Am 04.06.12 18:59, schrieb Igor Tandetnik: > On 6/4/2012 12:33 PM, Wolfgang Meiners wrote: >> this trigger does work but i think it is not in accordance with the >> syntax diagram of TRIGGER on >> http://sqlite.com/lang_createtrigger.html > > Which part do you feel is in violation of the diagram?

Re: [sqlite] Trigger, syntax question

2012-06-04 Thread Igor Tandetnik
On 6/4/2012 12:33 PM, Wolfgang Meiners wrote: this trigger does work but i think it is not in accordance with the syntax diagram of TRIGGER on http://sqlite.com/lang_createtrigger.html Which part do you feel is in violation of the diagram? -- Igor Tandetnik

[sqlite] Trigger, syntax question

2012-06-04 Thread Wolfgang Meiners
Hi, I have written the following trigger with ideas from stackoverflow: (OSX 10.6.8, SQLite 3.6.12) This is for a book library. If i delete a bookexemplar from the library, this should not be possible if this bookexemplar is on loan, which means ausleihen.rueckgabe IS NULL. Otherwise every