Subject | More about triggers |
---|---|
Author | TechVale - Gustavo |
Post date | 2006-07-12T20:19:34Z |
Hi All
I need, in a trigger, goes throught all "old" and "new" fields values for a table.
I have the following :
1. View who return tables names and fields names
CREATE VIEW VIEWDBTABLES(
TBTBNAME,
TBFIELDNAME,
TBFIELDID,
TBFIELDTYPE,
TBFIELDLEN,
TBFIELDDEC)
AS
SELECT
a.RDB$RELATION_NAME as TBTBNAME,
b.RDB$FIELD_NAME as TBFIELDNAME,
b.RDB$FIELD_ID as TBFIELDID,
d.RDB$TYPE_NAME as TBFIELDTYPE,
c.RDB$FIELD_LENGTH as TBFIELDLEN,
c.RDB$FIELD_SCALE as TBFIELDDEC
FROM
RDB$RELATIONS a
INNER JOIN
RDB$RELATION_FIELDS b
ON
a.RDB$RELATION_NAME = b.RDB$RELATION_NAME
INNER JOIN
RDB$FIELDS c
ON
b.RDB$FIELD_SOURCE = c.RDB$FIELD_NAME
INNER JOIN
RDB$TYPES d
ON
c.RDB$FIELD_TYPE = d.RDB$TYPE
WHERE
a.RDB$SYSTEM_FLAG = 0
AND
d.RDB$FIELD_NAME = 'RDB$FIELD_TYPE'
;
2. In a trigger. I want to do something like
FOR
SELECT VIEWDBTABLES.TBFIELDNAME FROM VIEWDBTABLES WHERE (VIEWDBTABLES.TBTBNAME = 'BANCOS')
INTO
:TMPFIELDNAME DO
BEGIN
/*here starts my doubt*/
/* i need to retrieve all old and new values for all fields in the record */
IF "OLD.TBNAME" <> "NEW.TBNAME" THEN ...
Thanks in advanced,
Gustavo.
[Non-text portions of this message have been removed]
I need, in a trigger, goes throught all "old" and "new" fields values for a table.
I have the following :
1. View who return tables names and fields names
CREATE VIEW VIEWDBTABLES(
TBTBNAME,
TBFIELDNAME,
TBFIELDID,
TBFIELDTYPE,
TBFIELDLEN,
TBFIELDDEC)
AS
SELECT
a.RDB$RELATION_NAME as TBTBNAME,
b.RDB$FIELD_NAME as TBFIELDNAME,
b.RDB$FIELD_ID as TBFIELDID,
d.RDB$TYPE_NAME as TBFIELDTYPE,
c.RDB$FIELD_LENGTH as TBFIELDLEN,
c.RDB$FIELD_SCALE as TBFIELDDEC
FROM
RDB$RELATIONS a
INNER JOIN
RDB$RELATION_FIELDS b
ON
a.RDB$RELATION_NAME = b.RDB$RELATION_NAME
INNER JOIN
RDB$FIELDS c
ON
b.RDB$FIELD_SOURCE = c.RDB$FIELD_NAME
INNER JOIN
RDB$TYPES d
ON
c.RDB$FIELD_TYPE = d.RDB$TYPE
WHERE
a.RDB$SYSTEM_FLAG = 0
AND
d.RDB$FIELD_NAME = 'RDB$FIELD_TYPE'
;
2. In a trigger. I want to do something like
FOR
SELECT VIEWDBTABLES.TBFIELDNAME FROM VIEWDBTABLES WHERE (VIEWDBTABLES.TBTBNAME = 'BANCOS')
INTO
:TMPFIELDNAME DO
BEGIN
/*here starts my doubt*/
/* i need to retrieve all old and new values for all fields in the record */
IF "OLD.TBNAME" <> "NEW.TBNAME" THEN ...
Thanks in advanced,
Gustavo.
[Non-text portions of this message have been removed]