Subject table names as variables...
Author Peter Lee
Hello Everyone,

Just wondering how I would achieve this in firebird / ib? A record in
G_LEVEL has just been deleted (primary key is level_def_num), and I want to
delete the contents of another table which has entries linked by
level_def_num. The table name to have the entries deleted from is stored
in table G_TOPICS. Is it possible to embed the table name in such a way in
my delete statement?

====

CREATE TRIGGER TRG_G_LEVEL_DELETE FOR G_LEVEL ACTIVE
AFTER DELETE POSITION 0
AS
DECLARE VARIABLE TOPIC_TABLE VARCHAR(12);
BEGIN
/* Now delete the level data from the topic specific database */
SELECT DATABASE_NAME FROM G_TOPICS WHERE G_TOPICS.topic_num =
old.topic_num INTO :topic_table;
DELETE FROM :topic_table WHERE level_def_num = old.level_def_num;
END

====

Thanks,

Peter Lee


-
Peter Lee Mobile: +61 412 011 174 ptle@...
-----------------------------------------------------------------------
Rising Software Australia Pty. Ltd. http://www.risingsoftware.com/
Publishers of 'Auralia' - Ear Training and 'Musition' - Theory Training
Ph: +61 3 9481 3320 FAX: +61 3 9481 3380 USA Freecall: 1 888 667 7839