Add %age area column to vacancies section.
[capital-apms-progress.git] / rplctn / mkreptrg.p
blob570e8943c755bb762ecf001f983aff27157a2085
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File : mkreptrg.p
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> )
11 Description :
13 Author(s) : Donald Christie
14 Created : 27/08/97
15 Notes :
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.
26 DEF STREAM df-file.
27 DEF STREAM trg-file.
29 {inc\ofc-this.i}
31 /* _UIB-CODE-BLOCK-END */
32 &ANALYZE-RESUME
35 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
37 /* ******************** Preprocessor Definitions ******************** */
39 &Scoped-define PROCEDURE-TYPE Procedure
43 /* _UIB-PREPROCESSOR-BLOCK-END */
44 &ANALYZE-RESUME
48 /* *********************** Procedure Settings ************************ */
50 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
51 /* Settings for THIS-PROCEDURE
52 Type: Procedure
53 Allow:
54 Frames: 0
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
65 HEIGHT = .29
66 WIDTH = 32.86.
67 /* END WINDOW DEFINITION */
69 &ANALYZE-RESUME
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:
90 FIND FIRST _file
91 WHERE _file._file-name = ReplTrigger.TableToRepl
92 NO-LOCK NO-ERROR.
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".
97 NEXT. /*for each*/
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").
108 END. /* for each */
110 PUT STREAM df-file UNFORMATTED "." SKIP "PSC" SKIP "codepage=iso8859-1" SKIP ".".
112 OUTPUT STREAM df-file CLOSE.
114 /* _UIB-CODE-BLOCK-END */
115 &ANALYZE-RESUME
118 /* ********************** Internal Procedures *********************** */
120 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE create-replication-trigger Procedure
121 PROCEDURE create-replication-trigger :
122 /*------------------------------------------------------------------------------
123 Purpose:
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).
139 /* trigger code */
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 "
145 rep_action
146 " records of the "
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
157 "." skip(1)
158 chr(123) "rplctn/"
159 SUBSTRING (rep_action ,1,1) "reptrig.i" skip
160 " &rtable = """ _File._File-name """" skip
161 " " chr(125) skip(1)
162 "/*" fill("-",66) "*/" skip.
165 END PROCEDURE.
167 /* _UIB-CODE-BLOCK-END */
168 &ANALYZE-RESUME