Hello,

First of all I apologize for my poor english speaking.

I have some problems with SQLite triggers.

I have a table tab(UniqueID INTEGER PRIMARY KEY, champ1 TIMESTAMP). And
when a date ("YYYY-MM-DD") is inserted in champ1, I would like to convert
it to timestamp.
I would like to modify new.champ1 value in a "BEFORE" trigger, but
everything I tryed doesn't work :

**this trigger can't be created : error message 'SQL error : near "new" :
syntax error'
-------------------
CREATE TRIGGER trig_insert BEFORE INSERT ON tab FOR EACH ROW
WHEN (new.champ1 LIKE "%-%")
BEGIN
    new.champ1=(SELECT strftime("%s", new.champ1));
END;
-------------------

**This trigger is well created, but when it executes, I have this error
message : 'SQL error: no such table: main.new'
-------------------
CREATE TRIGGER trig_insert BEFORE INSERT ON tab FOR EACH ROW
WHEN (new.champ1 LIKE "%-%")
BEGIN
    UPDATE new SET champ1=(SELECT strftime("%s", new.champ1)) WHERE
UniqueID=new.UniqueID;
END;
-------------------



So do you know if it is possible to modify new columns ?
It is important to me to modify them in a "BEFORE" trigger, because if I
do it in an "AFTER" trigger, I would have to use an UPDATE query and it
would lead to a deadlock (I also have some triggers on the UPDATE
statement...).


Thank you for helping

Have a nice day

Charly CAULET

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to