"blackbox" <[EMAIL PROTECTED]> wrote in
message news:[EMAIL PROTECTED]
> I'm new to SQLite and triggers. Is it possible to set a trigger so it
> updates a field of a new record in a table to the same value as the
> Autoincrement field.
>
> i.e.
>
> Field1, Integer Autoincrement
> Field2, Integer
> Field3, Text
> Field4, Text
>
> When the user enters text in Field3 & Field4, Field1 is
> auto-populated. When the new record is saved, I would like the
> trigger to set Field2 to be the same as Field1. I have no idea how
> to set the syntax to do this.
create trigger triggerName after insert on tableName
begin
update tableName set Field2=new.Field1
where Field1 = new.Field1;
end;
> Also, is it possible to have an autoincrement field in SQLite that is
> not a primary key?
No. Why would you want to?
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users