what's wrong with this trigger

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

what's wrong with this trigger

Rael Bauer-3
Hi,

CREATE TABLE [notebooks] (
   [id] INTEGER,
   [last_edit] DATETIME);

CREATE TABLE [notes](
   [id] INTEGER,
   [caption] VARCHAR,
   [notebook_id] INTEGER);

When a new note is added, I want to update the "last_edit" field for the
notebook that this note belongs to.

CREATE TRIGGER notes_ai AFTER INSERT ON notes
BEGIN
   update notebooks set notebooks.last_edit = datetime('now')
   where notebooks.id = new.notebook_id;
END;

SQLite Expert reports a near ".": syntax error. Is there something wrong
with the trigger syntax here, or is it some other problem?

Thanks

Rael

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: what's wrong with this trigger

Simon Slavin-3
On 10 Sep 2019, at 2:09am, Rael Bauer <[hidden email]> wrote:

> CREATE TRIGGER notes_ai AFTER INSERT ON notes
> BEGIN
>   update notebooks set notebooks.last_edit = datetime('now')
>   where notebooks.id = new.notebook_id;
> END;
>
> SQLite Expert reports a near ".": syntax error. Is there something wrong with the trigger syntax here, or is it some other problem?

Some of the dots aren't needed.  So try

CREATE TRIGGER notes_ai AFTER INSERT ON notes
BEGIN
  update notebooks set last_edit = datetime('now')
      where id = new.notebook_id;
END;
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: what's wrong with this trigger

Rael Bauer-3
In reply to this post by Rael Bauer-3
Thanks, that works.

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: what's wrong with this trigger

Doug
What works, please? I saw no answer.
Doug

> -----Original Message-----
> From: sqlite-users <[hidden email]>
> On Behalf Of Rael Bauer
> Sent: Monday, September 09, 2019 7:01 PM
> To: [hidden email]
> Subject: Re: [sqlite] what's wrong with this trigger
>
> Thanks, that works.
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
> users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: what's wrong with this trigger

Igor Korot
Hi,

On Mon, Sep 9, 2019 at 9:43 PM Doug <[hidden email]> wrote:
>
> What works, please? I saw no answer.

There is an answer down below.

Thank you.

> Doug
>
> > -----Original Message-----
> > From: sqlite-users <[hidden email]>
> > On Behalf Of Rael Bauer
> > Sent: Monday, September 09, 2019 7:01 PM
> > To: [hidden email]
> > Subject: Re: [sqlite] what's wrong with this trigger
> >
> > Thanks, that works.
> >
> > _______________________________________________
> > sqlite-users mailing list
> > [hidden email]
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
> > users
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: what's wrong with this trigger

Mateusz Wajchęprzełóż
In reply to this post by Doug
wt., 10 wrz 2019 o 04:43 Doug <[hidden email]> napisał(a):

> What works, please? I saw no answer.
> Doug
>

This:
wt., 10 wrz 2019 o 03:12 Simon Slavin <[hidden email]> napisał(a):

> On 10 Sep 2019, at 2:09am, Rael Bauer <[hidden email]> wrote:
>
> > CREATE TRIGGER notes_ai AFTER INSERT ON notes
> > BEGIN
> >   update notebooks set notebooks.last_edit = datetime('now')
> >   where notebooks.id = new.notebook_id;
> > END;
> >
> > SQLite Expert reports a near ".": syntax error. Is there something wrong
> with the trigger syntax here, or is it some other problem?
>
> Some of the dots aren't needed.  So try
>
> CREATE TRIGGER notes_ai AFTER INSERT ON notes
> BEGIN
>   update notebooks set last_edit = datetime('now')
>       where id = new.notebook_id;
> END;
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>




wt., 10 wrz 2019 o 04:43 Doug <[hidden email]> napisał(a):

> What works, please? I saw no answer.
> Doug
>
> > -----Original Message-----
> > From: sqlite-users <[hidden email]>
> > On Behalf Of Rael Bauer
> > Sent: Monday, September 09, 2019 7:01 PM
> > To: [hidden email]
> > Subject: Re: [sqlite] what's wrong with this trigger
> >
> > Thanks, that works.
> >
> > _______________________________________________
> > sqlite-users mailing list
> > [hidden email]
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
> > users
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users