On 08/30/2011 10:48 PM, Black, Michael (IS) wrote:
I found that if you used the default rowid it always gave -1 for the value.
That's why I put in it's own key.

I don't understand why this doesn't work...perhaps somebody can point out the 
error here...new.rowid contains -1.  I would think that rowid ought to be 
available after the insert.
This is using 3.7.4

create table temp_01(val float);
create table temp_02(val float);
create table total(val float);
create table row(row2 integer);
create trigger after insert on temp_01
begin
insert into total values((select new.val+temp_02.val from temp_02 where 
temp_02.rowid=new.rowid));
insert into row values(new.rowid);
end;

The error is that we are mistaking the above for an AFTER
trigger. It is not. It is a BEFORE trigger named "after".
And the value of new.rowid is not defined in a BEFORE
trigger.

Rewrite as:

  CREATE TRIGGER my_new_trigger AFTER INSERT ...

and it should work.

Dan.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to