Subject Dynamic SQL
Author gordion_cz
Hello all,

I apologise for these two simple questions but I'm not able to
find answers in both the NG archive and the FB doc:

1. Can I create dynamic SQL statements (SELECT, INSERT, UPDATE,
DELETE) inside the stored procedure or inside the trigger?
Say I pass some values to the SP
(say "table_name", "column_name", "col_value", "id_value") and inside
the SP I want to execute statement:

"UPDATE table_name SET column_name=col_value WHERE RowID=id_value"

I know about the EXECUTE STATEMENT in the FB 1.5 but at this moment I
have FB 1.0.3 only. Can I perform these DSQLs in the FB 1.0? (I use
IBExpert 2003.11.06 Personal Edition)

2. I want to create some stored procedures that do some functionality
and I want to call these procedures from triggers - like this:

CREATE TRIGGER TABLE1_BU0 FOR HLAVICKA1
ACTIVE BEFORE UPDATE POSITION 0
AS
begin
execute procedure sp_proc1( old, new );
execute procedure sp_proc2( old, new );
end

Can I pass the "old" and "new" values into the SP (and "new"
value "by reference" = as an output parameter (I need to change some
col vals))? Or is there another approach (I do not want to use the
hardcoded way - to pass "old.col1", "new.col1", ...)?

Thank you for your replies.

Best Regards

Ivo Dostal