CREATE TRIGGER IF NOT EXISTS throws error

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

CREATE TRIGGER IF NOT EXISTS throws error

stephan nies-2
Hello,
when i build a test table with:

CREATE TABLE test(a text);

and try to implement a trigger using:

CREATE TRIGGER IF NOT EXISTS trig_name
BEFORE INSERT ON test
FOR EACH ROW BEGIN
SELECT RAISE(ROLLBACK, 'blabla')
WHERE NEW.a = 'pong';
END;

I get this error message:
SQL error: near "NOT": syntax error


if i omit the "IF NOT EXISTS" everything woks fine.
According to the Documentation at
http://www.sqlite.org/lang_createtrigger.html
SQLite should understand this syntax.
So what am i doing wrong here?

Thanks,
Stephan
Reply | Threaded
Open this post in threaded view
|

RE: CREATE TRIGGER IF NOT EXISTS throws error

Eric Pankoke
What version of SQLite are you using?  I'm not sure the IF EXISTS option
was present until a certain version of 3.x (though I'm not sure which
version).

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
 

-----Original Message-----
From: stephan nies [mailto:[hidden email]]
Sent: Sunday, March 25, 2007 1:47 PM
To: [hidden email]
Subject: [sqlite] CREATE TRIGGER IF NOT EXISTS throws error

Hello,
when i build a test table with:

CREATE TABLE test(a text);

and try to implement a trigger using:

CREATE TRIGGER IF NOT EXISTS trig_name
BEFORE INSERT ON test
FOR EACH ROW BEGIN
SELECT RAISE(ROLLBACK, 'blabla')
WHERE NEW.a = 'pong';
END;

I get this error message:
SQL error: near "NOT": syntax error


if i omit the "IF NOT EXISTS" everything woks fine.
According to the Documentation at
http://www.sqlite.org/lang_createtrigger.html
SQLite should understand this syntax.
So what am i doing wrong here?

Thanks,
Stephan



-----------------------------------------------------------------------------
To unsubscribe, send email to [hidden email]
-----------------------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: CREATE TRIGGER IF NOT EXISTS throws error

stephan nies-2
I am using sqlite 3.3.5 .

On 3/25/07, Eric Pankoke <[hidden email]> wrote:

>
> What version of SQLite are you using?  I'm not sure the IF EXISTS option
> was present until a certain version of 3.x (though I'm not sure which
> version).
>
> Eric Pankoke
> Founder
> Point Of Light Software
> http://www.polsoftware.com/
>
>
> -----Original Message-----
> From: stephan nies [mailto:[hidden email]]
> Sent: Sunday, March 25, 2007 1:47 PM
> To: [hidden email]
> Subject: [sqlite] CREATE TRIGGER IF NOT EXISTS throws error
>
> Hello,
> when i build a test table with:
>
> CREATE TABLE test(a text);
>
> and try to implement a trigger using:
>
> CREATE TRIGGER IF NOT EXISTS trig_name
> BEFORE INSERT ON test
> FOR EACH ROW BEGIN
> SELECT RAISE(ROLLBACK, 'blabla')
> WHERE NEW.a = 'pong';
> END;
>
> I get this error message:
> SQL error: near "NOT": syntax error
>
>
> if i omit the "IF NOT EXISTS" everything woks fine.
> According to the Documentation at
> http://www.sqlite.org/lang_createtrigger.html
> SQLite should understand this syntax.
> So what am i doing wrong here?
>
> Thanks,
> Stephan
>
>
>
>
> -----------------------------------------------------------------------------
> To unsubscribe, send email to [hidden email]
>
> -----------------------------------------------------------------------------
>
>
Reply | Threaded
Open this post in threaded view
|

Re: CREATE TRIGGER IF NOT EXISTS throws error

Dan Kennedy-4
I think you need 3.3.8 or greater.


On Mon, 2007-03-26 at 07:39 +0200, stephan nies wrote:

> I am using sqlite 3.3.5 .
>
> On 3/25/07, Eric Pankoke <[hidden email]> wrote:
> >
> > What version of SQLite are you using?  I'm not sure the IF EXISTS option
> > was present until a certain version of 3.x (though I'm not sure which
> > version).
> >
> > Eric Pankoke
> > Founder
> > Point Of Light Software
> > http://www.polsoftware.com/
> >
> >
> > -----Original Message-----
> > From: stephan nies [mailto:[hidden email]]
> > Sent: Sunday, March 25, 2007 1:47 PM
> > To: [hidden email]
> > Subject: [sqlite] CREATE TRIGGER IF NOT EXISTS throws error
> >
> > Hello,
> > when i build a test table with:
> >
> > CREATE TABLE test(a text);
> >
> > and try to implement a trigger using:
> >
> > CREATE TRIGGER IF NOT EXISTS trig_name
> > BEFORE INSERT ON test
> > FOR EACH ROW BEGIN
> > SELECT RAISE(ROLLBACK, 'blabla')
> > WHERE NEW.a = 'pong';
> > END;
> >
> > I get this error message:
> > SQL error: near "NOT": syntax error
> >
> >
> > if i omit the "IF NOT EXISTS" everything woks fine.
> > According to the Documentation at
> > http://www.sqlite.org/lang_createtrigger.html
> > SQLite should understand this syntax.
> > So what am i doing wrong here?
> >
> > Thanks,
> > Stephan
> >
> >
> >
> >
> > -----------------------------------------------------------------------------
> > To unsubscribe, send email to [hidden email]
> >
> > -----------------------------------------------------------------------------
> >
> >


-----------------------------------------------------------------------------
To unsubscribe, send email to [hidden email]
-----------------------------------------------------------------------------