"Fabiano Sidler"
<[EMAIL PROTECTED]> wrote in
message news:[EMAIL PROTECTED]
> create trigger dbapp_delete instead of delete on dbapp begin
> delete from dbapp_tablefields where tablenameID=(
> select tablenameID from dbapp_tablenames
> where tablename=old.tablename
> and tablefield=old.tablefield);
>
> select case when ((
> select tablefield from dbapp_tablefields f
> join dbapp_tablenames t on (f.tablenameID=t.tablenameID)
> where tablefield=old.fields and tablname=old.tablename) is null)
> then (delete from dbapp_tablenames where tablename=old.tablename)
> end;
>
> end;
> ---
>
> But the trigger produces a syntax error at "delete" in the first line.

The problem is with the DELETE statement you are trying to nest into a 
select statement (the second statement in the trigger). You can't do 
that - DELETE can only appear at the top level. You need something like 
this:

delete from dbapp_tablenames
where tablename=old.tablename and not exists (
    select * from dbapp_tablefields f
    where f.tablenameID = dbapp_tablenames.tablenameID and
        tablefield=old.fields
);

Igor Tandetnik 



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

Reply via email to