Subject Re: [Firebird-general] possible to CREATE a TRIGGER from a INSIDE?
Author Martijn Tonies
Hi,

> I'm trying to create a new trigger from INSIDE the database, trhough a
> procedure using the EXECUTE STATEMENT
>
> I create a string with all the syntax (really only a command)
>
> trg=
> 'SET TERM ^ ; '||

Don't do that. SET TERM is only needed by client applications,
not by Firebird.

> 'CREATE TRIGGER '||new.table||' for '||NEW.table||' '||
> 'AFTER '||CASE new.accion when 'A' then 'INSERT'
> when 'M' then 'UPDATE'
> when 'B' then 'DELETE' end||' '||
> 'POSITION 100 '||
> 'AS BEGIN '||
> 'EXECUTE PROCEDURE MY_PROCEDURE; '
> 'END ^ '||

Remove the "^".

> 'SET TERM ; ^ '

Remove this.

> but when I try
>
> EXECUTE STATEMENT trg
>
> i got some kind of error

Oh? Well, luckily, we have some kind of solution... That is, care to let us
know
to which error we can apply the solution?

> I try whithout "set term" comamnd but same result...
>
> anyone know the way to DO it?

With regards,

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com