1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
6 Purpose
: Create a schema df from rules in the replication
7 triggers table to apply to the current database
9 Syntax
: mkreptrg.p
( <df-file-name
> )
13 Author
(s
) : Donald Christie
16 ------------------------------------------------------------------------*/
17 /* This .W file was created with the Progress UIB.
*/
18 /*----------------------------------------------------------------------*/
20 /* *************************** Definitions
************************** */
22 DEF INPUT PARAMETER file-name
AS CHAR NO-UNDO.
23 IF file-name
= ?
THEN file-name
= "rplctn\reptrig.df".
25 DEF VAR rep_yn
AS LOGICAL NO-UNDO.
31 /* _UIB-CODE-BLOCK-END
*/
35 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
37 /* ******************** Preprocessor Definitions
******************** */
39 &Scoped-define PROCEDURE-TYPE Procedure
43 /* _UIB-PREPROCESSOR-BLOCK-END
*/
48 /* *********************** Procedure Settings
************************ */
50 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
51 /* Settings for
THIS-PROCEDURE
55 Add Fields to
: Neither
56 Other Settings
: CODE-ONLY
COMPILE
58 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
60 /* ************************* Create Window
************************** */
62 &ANALYZE-SUSPEND _CREATE-WINDOW
63 /* DESIGN Window definition
(used by the UIB
)
64 CREATE WINDOW Procedure
ASSIGN
67 /* END WINDOW DEFINITION
*/
74 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
77 /* *************************** Main Block
*************************** */
79 RUN rplctn\delreptg.p
( file-name
).
81 /* create the trigger directories
*/
82 OS-CREATE-DIR rplctn
/create.
83 OS-CREATE-DIR rplctn
/delete.
84 OS-CREATE-DIR rplctn
/write.
86 OUTPUT STREAM df-file
TO VALUE ( file-name
) APPEND.
88 FOR EACH ReplTrigger
NO-LOCK:
91 WHERE _file._file-name
= ReplTrigger.TableToRepl
94 IF NOT AVAILABLE _file
THEN DO:
95 MESSAGE "The table '" ReplTrigger.TableToRepl
"' does not exist" VIEW-AS ALERT-BOX ERROR
96 TITLE "Replication Trigger Error".
98 END.
/* if not available
*/
100 /* write and create use the same replication trigger
*/
101 IF INDEX (ReplTrigger.Activity
, "C") <> 0 THEN
102 RUN create-replication-trigger
("create").
103 IF INDEX (ReplTrigger.Activity
, "M") <> 0 THEN
104 RUN create-replication-trigger
("write").
105 IF INDEX (ReplTrigger.Activity
, "D") <> 0 THEN
106 RUN create-replication-trigger
("delete").
110 PUT STREAM df-file
UNFORMATTED "." SKIP "PSC" SKIP "codepage=iso8859-1" SKIP ".".
112 OUTPUT STREAM df-file
CLOSE.
114 /* _UIB-CODE-BLOCK-END
*/
118 /* ********************** Internal Procedures
*********************** */
120 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-replication-trigger Procedure
121 PROCEDURE create-replication-trigger
:
122 /*------------------------------------------------------------------------------
124 ------------------------------------------------------------------------------*/
126 DEF INPUT PARAMETER rep_action
AS CHAR NO-UNDO.
128 DEF VAR RepFile_Name
AS CHAR FORMAT "X(80)" NO-UNDO.
130 PUT STREAM df-file
UNFORMATTED
131 "UPDATE TABLE """ _File._File-name
"""" skip.
133 /* trigger-definitions
*/
134 PUT STREAM df-file
UNFORMATTED
135 " TABLE-TRIGGER ""REPLICATION-" CAPS (rep_action
)
136 """ OVERRIDE PROCEDURE ""rplctn/"
137 rep_action
"/" _File._Dump-name
".p"" CRC ""?""" SKIP (1).
140 OUTPUT STREAM trg-file
TO
141 VALUE("rplctn/" + rep_action
+ "/" + _File._Dump-name
+ ".p").
143 PUT STREAM trg-file
UNFORMATTED
144 "/* replication trigger for "
147 _File._File-name
+ " table */" skip
(1)
148 "TRIGGER PROCEDURE FOR REPLICATION-"
149 CAPS (rep_action
) " OF " _File._File-name.
151 IF rep_action
= "WRITE" THEN
152 PUT STREAM trg-FILE
UNFORMATTED
153 " NEW BUFFER new" _File._File-Name
154 " OLD BUFFER old" _File._File-Name.
156 PUT STREAM trg-FILE
UNFORMATTED
159 SUBSTRING (rep_action
,1,1) "reptrig.i" skip
160 " &rtable = """ _File._File-name
"""" skip
162 "/*" fill
("-",66) "*/" skip.
167 /* _UIB-CODE-BLOCK-END
*/