Consultor Eletrônico



Kbase P113866: 4GL/ABL: How to programmatically replace a schema trigger using 4GL?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   03/12/2008
Status: Verified

GOAL:

4GL/ABL: How to programmatically replace a schema trigger using 4GL?

GOAL:

How to change absolute path names to relative path names for field and table schema triggers?

GOAL:

How to programmatically change names and locations of table and field schema triggers?

FACT(s) (Environment):

All Supported Operating Systems
Progress 8.x
Progress 9.x
OpenEdge 10.x

FIX:

The following code will change the connected database field trigger names from absolute path names into simple relative file names. The code can be modified to similarly change the _File-Trig trigger names:
/* Define a temp table to store the current values in the trigger table */
DEFINE TEMP-TABLE y_Field-Trig
FIELD y_Field-Recid LIKE DICTDB._Field-Trig._Field-Recid
FIELD y_File-Recid LIKE DICTDB._Field-Trig._File-Recid
FIELD y_Field-Rpos LIKE DICTDB._Field-Trig._Field-Rpos
field y_Event LIKE DICTDB._Field-Trig._Event
field y_Proc-name LIKE DICTDB._Field-Trig._Proc-Name
field y_Override LIKE DICTDB._Field-Trig._Override
field y_Trig-Crc LIKE DICTDB._Field-Trig._Trig-Crc.
DEFINE VARIABLE cFieldTriggerName AS CHARACTER NO-UNDO.
FUNCTION getRelativeTriggerName RETURNS CHARACTER (INPUT ExistingAbsoluteTriggerName AS CHARACTER) FORWARD.
/* Populate the temp table with the current values from the trigger table */
FOR EACH DICTDB._Field-trig WHERE DICTDB._Field-Trig._Proc-Name <> ?:
CREATE y_Field-Trig.
ASSIGN
y_Field-Trig.y_Field-Recid = DICTDB._Field-Trig._Field-Recid
y_Field-Trig.y_File-Recid = DICTDB._Field-Trig._File-Recid
y_Field-Trig.y_Event = DICTDB._Field-Trig._Event
y_Field-Trig.y_Proc-Name = DICTDB._Field-Trig._Proc-Name
y_Field-Trig.y_Override = DICTDB._Field-Trig._Override
y_Field-Trig.y_Trig-TRONG>Crc = DICTDB._Field-Trig._Trig-Crc.
/* Delete existing record in the trigger table and */
DELETE DICTDB._Field-Trig.
END.
/* Rebuild trigger table records with the field name modification back Windows '\' changed to unix slash '/' */
FOR EACH y_Field-trig WHERE y_Field-Trig.y_Proc-Name <> ?:
CREATE DICTDB._Field-Trig.

cFieldTriggerName = getRelativeTriggerName(y_Field-Trig.y_Proc-Name).
ASSIGN
DICTDB._Field-Trig._Field-Recid = y_Field-Trig.y_Field-Recid
DICTDB._Field-Trig._File-Recid = y_Field-Trig.y_File-Recid
DICTDB._Field-Trig._Event = y_Field-Trig.y_Event
DICTDB._Field-Trig._Proc-name = cFieldTriggerName
DICTDB._Field-Trig._Override = y_Field-Trig.y_Override
DICTDB._Field-Trig._Trig-Crc = y_Field-Trig.y_Trig-Crc.
END.
/* Function to extract the simple relative trigger name from the path name in the data dictionary */
FUNCTION getRelativeTriggerName RETURNS CHARACTER (INPUT ExistingAbsoluteTriggerName AS CHARACTER):
DEFINE VARIABLE SlashCharacter AS CHARACTER NO-UNDO.
IF OPSYS = "UNIX" THEN
RETURN SUBSTRING(ExistingAbsoluteTriggerName, R-INDEX(ExistingAbsoluteTriggerName, "/") + 1 ).
ELSE
RETURN SUBSTRING(ExistingAbsoluteTriggerName, R-INDEX(ExistingAbsoluteTriggerName, "\") + 1 ).
END..