-
Notifications
You must be signed in to change notification settings - Fork 1
/
D2M2_UTL000.TPW
385 lines (385 loc) · 25.1 KB
/
D2M2_UTL000.TPW
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! File Name: D2M2_UTL000.tpw
#! Purpose: UTILITY: Check GUID related areas
#! Author: Copyright © 1999-2999 by Roberto Artigas Jr
#! All rights reserved world wide.
#! Changes:
#! 2018.07.04 Roberto Artigas
#! * Template utility creation.
#!
#UTILITY(D2M2_UTIL_GUID, '2019.07.04: [UTIL] Verify GUID information')
#!-----------------------------------------------------------------------------
#! RA.2017.12.17 - The %BaseName determines what backend you are processing.
#! All the specific items related to a backend can be coded with a case statement.
#! This will make the code easier to maintain accross all the backends.
#PREPARE
#DECLARE(%BaseName) #! Define the BACKEND here
#SET(%BaseName, 'PSQL') #! PSQL: ???
#SET(%BaseName, 'INTERBASE') #! INTERBASE: ???
#SET(%BaseName, 'PERVASIVE') #! PERVASIVE: ???
#SET(%BaseName, 'FIREBIRD') #! FIREBIRD: ???
#SET(%BaseName, 'SYBASE') #! SYBASE: ???
#SET(%BaseName, 'DB2') #! DB2: ???
#SET(%BaseName, 'ORACLE') #! ORACLE: ???
#SET(%BaseName, 'MYSQL') #! MYSQL: RAYS.2018.09.03: Tested.
#SET(%BaseName, 'SQLANYWHERE') #! SQLANYWHERE: RAYS.2018.06.12: Tested.
#SET(%BaseName, 'MSSQL') #! MSSQL: RAYS.2018.06.03: Tested.
#SET(%BaseName, 'MIMER') #! MIMER: RAYS.2018.04.07: Tested.
#SET(%BaseName, 'POSTGRESQL') #! POSTGRESQL: RAYS.2018.06.10: Tested.
#SET(%BaseName, 'METABASE') #! METABASE: Generic-Skeleton. NO backend.
#DECLARE(%pBaseName) #! RA.2020.07.16: Needs Definion. WTH! [???]
#SET(%pBaseName,'TPLUTILITY') #! TPLUTILITY: NOT A BACKEND
#DECLARE(%BaseUtil) #! Define the UTILITY here
#SET(%BaseUtil, 'TPLUTILITY') #! TPLUTILITY: NOT A BACKEND
#ENDPREPARE
#!---------------------------------------------------------------------
#INSERT(%VariablesCommon) #! Need a few simple variables
#INSERT(%GetDictionaryPath) #! Get dictionary path and names
#INSERT(%VariablesDeclare) #! Option checks and output file names
#INSERT(%VariablesSetup) #! Setup output file names
#INSERT(%VariablesOptions) #! All option variables setup here
#INSERT(%DefineAreasOptions) #! File,Field,Keys,Relations
#INSERT(%ReserveWordDefines) #! Reserved Words Defines
#INSERT(%PreambleUtility) #! Basic copyright message
#INSERT(%VariablesUtility000) #! RA.2019.07.25.THU: Added
#!---------------------------------------------------------------------
#SHEET,HSCROLL,AT(,,464)
#INSERT(%MITLicenseD2M2UTL000)
#INSERT(%ShowExplainUtilGUID)
#INSERT(%ShowExplainUtilGUID2)
#INSERT(%ShowExplainUtilGUID3) #! RA.2019.11.20.WED: Added
#INSERT(%MetabaseTabSelection)
#ENDSHEET
#!---------------------------------------------------------------------
#! START EXECUTION HERE
#!---------------------------------------------------------------------
#!#DECLARE(%DebugSet,LONG)
#!#SET(%DebugSet,1)
#!#DEBUG(%DebugSet)
#!
#SET(%UtilityChekTable , %TRUE)
#SET(%UtilityNameTable , %DictName & '_' & %BaseUtil & '_GUID_VERIFY.TXT') #! RA.2020.03.24: Changed
#SET(%UtilityNameTableOut , %DictPath & %UtilityNameTable)
#!
#CALL(%UtilityPrefix , %BaseUtil) #! RA.2020.03.24: Changed
#CALL(%BuildQualifiedFiles)
#IF(%TRUE)
#SET(%AuditLines, 0)
-- SEQ# %[0]NULL FILENAME %[42]NULL KC-PK-FLD %[1]NULL GUID %[1]NULL TS %[3]NULL STS %[2]NULL DTS %[2]NULL KGUID %[0]NULL KTS %[2]NULL KSTS %[1]NULL KDTS %[1]NULL NCRPT %[3]NULL PREFIX %[6]NULL FILEPATH %[42]NULL FILEOPTIONS
--
#FOR(%NFiles)
#FIX(%File, %NFilesName)
#SET(%NFilesFullPath , %FileName)
#IF(LEN(%NFilesFullPath) > 0)
#IF (INSTRING('''',%NFilesFullPath,1,1) < 1)
#SET(%NFilesFullPath , '!' & %NFilesFullPath)
#ENDIF
#ENDIF
#!INSERT(%MetabaseSqlField,%BaseUtil)
#SET(%NFilesKeyCount , ITEMS(%Key))
#SET(%NFilesFieldCount , ITEMS(%Field))
#INSERT(%BuildQualifiedFieldsGUID , %BaseUtil) #! RA.2020.03.24: Changed
#INSERT(%BuildQualifiedKeysGUID , %BaseUtil) #! RA.2020.03.24: Changed
-- %@N04@(%NFilesCount) %[0]NULL %[50]NFilesName %[0]NULL %[2]NFilesKeyCount-%[2]NFilesKeyPrimary-%[3]NFilesFieldCount %[1]NULL %[2]NFilesCountGUID-%[2]NFilesOptionGUID %[0]NULL %[2]NFilesCountTS-%[2]NFilesOptionTS %[0]NULL %[2]NFilesCountSTS-%[2]NFilesOptionSTS %[0]NULL %[2]NFilesCountDTS-%[2]NFilesOptionDTS %[0]NULL %[2]NFilesKeyGUID-%[2]NFilesFieldGUID %[0]NULL %[2]NFilesKeyTS-%[2]NFilesFieldTS %[0]NULL %[2]NFilesKeySTS-%[2]NFilesFieldSTS %[0]NULL %[2]NFilesKeyDTS-%[2]NFilesFieldDTS %[0]NULL %[2]NFilesCountEncrypt %[5]NULL [%[12]FilePrefix] %[50]NFilesFullPath %[0]NULL %FileUserOptions
#INSERT(%AuditFieldsAndKeys000)
#SET(%AuditLines, %AuditLines + 1)
#IF(%AuditLines % 20 = 0 AND ITEMS(%NFiles) <> %AuditLines)
--
-- SEQ# %[0]NULL FILENAME %[42]NULL KC-PK-FLD %[1]NULL GUID %[1]NULL TS %[3]NULL STS %[2]NULL DTS %[2]NULL KGUID %[0]NULL KTS %[2]NULL KSTS %[1]NULL KDTS %[1]NULL NCRPT %[3]NULL PREFIX %[6]NULL FILEPATH %[42]NULL FILEOPTIONS
--
#ENDIF
#ENDFOR
--
-- SEQ# %[0]NULL FILENAME %[42]NULL KC-PK-FLD %[1]NULL GUID %[1]NULL TS %[3]NULL STS %[2]NULL DTS %[2]NULL KGUID %[0]NULL KTS %[2]NULL KSTS %[1]NULL KDTS %[1]NULL NCRPT %[3]NULL PREFIX %[6]NULL FILEPATH %[42]NULL FILEOPTIONS
#ENDIF
#CALL(%UtilitySuffix , %BaseUtil) #! RA.2020.03.24: Changed
#!
#!
#!#SET(%DebugSet,0)
#!#DEBUG(%DebugSet)
#!---------------------------------------------------------------------
#! END EXECUTION HERE
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%MITLicenseD2M2UTL000)
#TAB('UTIL_GUID'),PROP(PROP:FontStyle,700)
#INSERT(%MITLicense)
#BOXED('Options'),AT(,,454),PROP(PROP:FontStyle,700),PROP(PROP:FontColor,0C79A3H)
#DISPLAY(''),AT(,,,1)
#PROMPT('OFF: Do NOT audit fields. ON: Audit the fields.', CHECK), %opt000AuditFields, AT(10)
#PROMPT('OFF: Do NOT audit keys. ON: Audit the keys.', CHECK), %opt000AuditKeys, AT(10)
#PROMPT('OFF: Do NOT audit relations. ON: Audit the relations.', CHECK), %opt000AuditRelations, AT(10)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%ExplainUtilGUID)
#PREPARE
#IF(NOT VAREXISTS(%ExplainTextGUID))
#DECLARE(%ExplainTextGUID)
#ENDIF
#SET(%ExplainTextGUID, '')
#!SET(%ExplainTextGUID, %ExplainTextGUID & 'This is one of the METABASE templates.')
#!SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><13,10>')
#SET(%ExplainTextGUID, %ExplainTextGUID & 'This generic utility will verify your database has the basic GUID and TIME STAMP components in place')
#SET(%ExplainTextGUID, %ExplainTextGUID & ' so you can have scalable and distributed databases as large as you desire.')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><13,10>')
#SET(%ExplainTextGUID, %ExplainTextGUID & 'It will provide an audit listing that contains the following header components:')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>KC-PK-FLD<9>GUID<9>TS<9>STS<9>DTS')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>4 -1 -21<9><9>1 -1<9>1 -1<9>1 -1<9>1 -1<13,10>')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>KC<9>= Key count for this table.')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>PK<9>= Primary key for this table exists.<9>(yes=1, no=0)')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>KC<9>= Field count for this table.')
#!SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>GUID<9>= How many GUID items have been detected.')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><13,10>')
#SET(%ExplainTextGUID, %ExplainTextGUID & 'Under the GUID, TS, STS, and DTS what is important is the 1 - 1 to be there.')
#SET(%ExplainTextGUID, %ExplainTextGUID & ' This tells you that field name and field options for the time stamps have been added. (yes=1, no=0)')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><13,10>For the Field NAMES:')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>GUID<9>= GUID<9><9><9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>TS<9>= TimeStamp<9><9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>STS<9>= ServerTimeStamp<9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>DTS<9>= DeletedTimeStamp<9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><13,10>For the Field OPTIONS:')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>GUID<9>= GUID(1):Integer<9><9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>TS<9>= TimeStamp(1):Integer<9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>STS<9>= ServerTimeStamp(1):Integer<9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><9>DTS<9>= DeletedTimeStamp(1):Integer<9>Has been detected? (yes=1, no=0)')
#!SET(%ExplainTextGUID, %ExplainTextGUID & '<13,10><13,10>')
#!SET(%ExplainTextGUID, %ExplainTextGUID & 'This template has been tested with the ABC template chains.')
#SET(%ExplainTextGUID, %ExplainTextGUID & '')
#ENDPREPARE
#!
#GROUP(%ShowExplainUtilGUID)
#INSERT(%ExplainUtilGUID)
#!TAB(UPPER(%Application) & '.' & UPPER(%ProgramExtension)),PROP(PROP:FontStyle,700),PROP(PROP:FontColor,0C79A3H)
#TAB('Documentation'),PROP(PROP:FontColor,0C79A3H) #! ,PROP(PROP:FontStyle,700),PROP(PROP:FontColor,0C79A3H)
#BOXED('Documentation (Screen 1)'),AT(,,454),PROP(PROP:FontStyle,700)
#DISPLAY(''),AT(,,,1)
#DISPLAY(%ExplainTextGUID),AT(,,436,204)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%ExplainUtilGUID2)
#PREPARE
#IF(NOT VAREXISTS(%ExplainTextGUID2))
#DECLARE(%ExplainTextGUID2)
#ENDIF
#SET(%ExplainTextGUID2, '')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & 'After the original audit template was written a few more items were discovered that seem')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & ' to need checking for accuracy.')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><13,10>')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & 'The following header components were added to the audit:')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><9>KGUID<9>KTS<9>KSTS<9>KDTS')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><9>1 -1<9>1 -1<9>1 -1<9>1 -1')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><13,10>')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & 'Under the KGUID, KTS, KSTS, and KDTS what is important is the 1 - 1 to be there.')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & ' This tells you that key names for the time stamps have been created, and field name for the time stamps')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & ' have been added in the correct keys. (yes=1, no=0)')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><13,10>For the KEY NAMES:')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><9>KGUID<9>= _PKEY<9><9><9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><9>KTS<9>= TimeStampKey<9><9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><9>KSTS<9>= ServerTimeStampKey<9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><9>KDTS<9>= DeletedTimeStampKey<9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><13,10>For the Field NAMES inside the KEY NAMES:')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><9>KGUID<9>= GUID<9><9><9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><9>KTS<9>= TimeStamp<9><9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><9>KSTS<9>= ServerTimeStamp<9><9>Has been detected? (yes=1, no=0)')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><9>KDTS<9>= DeletedTimeStamp<9><9>Has been detected? (yes=1, no=0)')
#!SET(%ExplainTextGUID2, %ExplainTextGUID2 & '<13,10><13,10>')
#!SET(%ExplainTextGUID2, %ExplainTextGUID2 & 'This template has been tested with the ABC template chains.')
#SET(%ExplainTextGUID2, %ExplainTextGUID2 & '')
#ENDPREPARE
#!
#GROUP(%ShowExplainUtilGUID2)
#INSERT(%ExplainUtilGUID2)
#!TAB(UPPER(%Application) & '.' & UPPER(%ProgramExtension)),PROP(PROP:FontStyle,700),PROP(PROP:FontColor,0C79A3H)
#TAB('Documentation'),PROP(PROP:FontColor,0C79A3H) #! ,PROP(PROP:FontStyle,700),PROP(PROP:FontColor,0C79A3H)
#BOXED('Documentation (Screen 2)'),AT(,,454),PROP(PROP:FontStyle,700)
#DISPLAY(''),AT(,,,1)
#DISPLAY(%ExplainTextGUID2),AT(,,436,204)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%ExplainUtilGUID3)
#PREPARE
#IF(NOT VAREXISTS(%ExplainTextGUID3))
#DECLARE(%ExplainTextGUID3)
#ENDIF
#SET(%ExplainTextGUID3, '')
#SET(%ExplainTextGUID3, %ExplainTextGUID3 & 'Additional checks have been added for the security features.')
#SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><13,10>')
#SET(%ExplainTextGUID3, %ExplainTextGUID3 & 'The following header components were added to the audit:')
#SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><9>NCRPT')
#SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><9>1')
#SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><13,10>')
#SET(%ExplainTextGUID3, %ExplainTextGUID3 & 'The NCRPT is a check to see if the <39>EncryptionVersion<39> field is in the table.')
#SET(%ExplainTextGUID3, %ExplainTextGUID3 & '')
#SET(%ExplainTextGUID3, %ExplainTextGUID3 & '')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><13,10>For the KEY NAMES:')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><9>KGUID<9>= _PKEY<9><9><9><9>Has been detected? (yes=1, no=0)')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><9>KTS<9>= TimeStampKey<9><9><9>Has been detected? (yes=1, no=0)')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><9>KSTS<9>= ServerTimeStampKey<9><9>Has been detected? (yes=1, no=0)')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><9>KDTS<9>= DeletedTimeStampKey<9><9>Has been detected? (yes=1, no=0)')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><13,10>For the Field NAMES inside the KEY NAMES:')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><9>KGUID<9>= GUID<9><9><9><9>Has been detected? (yes=1, no=0)')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><9>KTS<9>= TimeStamp<9><9><9>Has been detected? (yes=1, no=0)')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><9>KSTS<9>= ServerTimeStamp<9><9>Has been detected? (yes=1, no=0)')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><9>KDTS<9>= DeletedTimeStamp<9><9>Has been detected? (yes=1, no=0)')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & '<13,10><13,10>')
#!SET(%ExplainTextGUID3, %ExplainTextGUID3 & 'This template has been tested with the ABC template chains.')
#SET(%ExplainTextGUID3, %ExplainTextGUID3 & '')
#ENDPREPARE
#!
#GROUP(%ShowExplainUtilGUID3)
#INSERT(%ExplainUtilGUID3)
#!TAB(UPPER(%Application) & '.' & UPPER(%ProgramExtension)),PROP(PROP:FontStyle,700),PROP(PROP:FontColor,0C79A3H)
#TAB('Documentation'),PROP(PROP:FontColor,0C79A3H) #! ,PROP(PROP:FontStyle,700),PROP(PROP:FontColor,0C79A3H)
#BOXED('Documentation (Screen 3)'),AT(,,454),PROP(PROP:FontStyle,700)
#DISPLAY(''),AT(,,,1)
#DISPLAY(%ExplainTextGUID3),AT(,,436,204)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!--------------------------------------------------------------------- #! RA.2019.07.25: Added
#GROUP(%VariablesUtility000)
#PREPARE
#DECLARE(%NextLine)
#DECLARE(%KeyFieldList)
#DECLARE(%KeyFieldID)
#DECLARE(%AuditLines)
#DECLARE(%RelKeyFromID)
#DECLARE(%RelKeyToID)
#DECLARE(%RelFieldFromList)
#DECLARE(%RelFieldToList)
#DECLARE(%RelSort),MULTI,UNIQUE
#DECLARE(%RelFind , %RelSort)
#DECLARE(%RelShow , %RelSort)
#DECLARE(%RelType , %RelSort)
#DECLARE(%RelPrefix , %RelSort)
#DECLARE(%RelRASQL , %RelSort)
#DECLARE(%RelFromId , %RelSort)
#DECLARE(%RelToId , %RelSort)
#DECLARE(%RelFromList , %RelSort)
#DECLARE(%RelToList , %RelSort)
#!
#DECLARE(%opt000AuditFields ,LONG)
#SET(%opt000AuditFields ,FALSE)
#DECLARE(%opt000AuditKeys ,LONG)
#SET(%opt000AuditKeys ,FALSE)
#DECLARE(%opt000AuditRelations ,LONG) #! RA.2020.05.22: Added
#SET(%opt000AuditRelations ,FALSE)
#ENDPREPARE
#!---------------------------------------------------------------------
#!--------------------------------------------------------------------- #! RA.2019.07.25: Added
#GROUP(%AuditFieldsAndKeys000)
#IF(ITEMS(%Field) AND %opt000AuditFields)
-- %[05]NULL FIELD-NAME %[40]NULL EXTERNAL-NAME %[37]NULL INITIAL-VALUE %[25]NULL FIELD-OPTIONS
-- %[05]NULL ========== %[40]NULL ============= %[37]NULL ============= %[25]NULL =============
#FOR(%Field)
#SET(%NextLine, EXTRACT(%FieldStatement,'NAME'))
#SET(%NextLine, SUB(%NextLine,7,LEN(%NextLine)-8))
-- %[05]NULL %[50]FieldID %[0]NULL %[50]NextLine %[0]NULL %[38]FieldInitial %[0]NULL %FieldUserOptions
#ENDFOR
#ENDIF
#!
#IF(ITEMS(%Key) AND %opt000AuditKeys)
-- %[05]NULL KEY-NAME %[22]NULL EXTERNAL-NAME %[17]NULL KEY-FIELD-LIST %[64]NULL KEY-OPTIONS
-- %[05]NULL ======== %[22]NULL ============= %[17]NULL ============== %[64]NULL ===========
#FOR(%Key)
#SET(%NextLine, EXTRACT(%KeyStatement,'NAME'))
#SET(%NextLine, SUB(%NextLine,7,LEN(%NextLine)-8))
#SET(%KeyFieldList,'')
#FOR(%KeyField)
#!SET(%KeyFieldID,SUB(%KeyField, 6, LEN(%KeyField) - 5))
#SET(%KeyFieldID,SUB(%KeyField, INSTRING(':',%KeyField,1,1) + 1, LEN(%KeyField) - INSTRING(':',%KeyField,1,1)))
#SET(%KeyFieldList, %KeyFieldList & SUB(%KeyFieldSequence,1,1) & ':' & %KeyFieldID & ';')
#ENDFOR
#IF(LEN(%KeyFieldList) > 80)
#SET(%KeyFieldList, SUB(%KeyFieldList,1,80))
#ENDIF
-- %[05]NULL %[30]KeyID %[0]NULL %[30]NextLine %[0]NULL %[78]KeyFieldList %[0]NULL %KeyUserOptions
#ENDFOR
#ENDIF
#IF(ITEMS(%Relation) AND %opt000AuditRelations)
-- %[05]NULL R-TYPE %[0]NULL FROM-HERE %[45]NULL TO-THERE %[60]NULL RELATION-OPTIONS
-- %[05]NULL ====== %[0]NULL ============= %[45]NULL ============== %[60]NULL ================
#FREE(%RelSort)
#FOR(%Relation)
#IF(CLIP(EXTRACT(%RelationUserOptions,'RASQL',4)) <> '')
#ADD(%RelSort , %FileRelationType & '-' & EXTRACT(%RelationUserOptions,'RASQL',4))
#ELSE
#ADD(%RelSort , %FileRelationType & '-' & %RelationKey)
#END
#SET(%RelPrefix , %RelationPrefix)
#SET(%RelType , %FileRelationType)
#SET(%RelRASQL , %RelationUserOptions)
#SET(%RelFind , %RelationKey)
#SET(%RelShow , SUB(%RelationKey , INSTRING(':',%RelationKey,1,1) + 1 , LEN(%RelationKey) - INSTRING(':',%RelationKey,1,1)))
#SET(%RelFromId , SUB(%FileKey , INSTRING(':',%FileKey,1,1) + 1 , LEN(%FileKey) - INSTRING(':',%FileKey,1,1)))
#SET(%RelToId , SUB(%RelationKey , INSTRING(':',%RelationKey,1,1) + 1 , LEN(%RelationKey) - INSTRING(':',%RelationKey,1,1)))
#SET(%RelFromList ,'')
#SET(%RelToList ,'')
#FOR(%FileKeyField)
#SET(%RelFromList , %RelFromList & SUB(%FileKeyField , INSTRING(':',%FileKeyField,1,1) + 1 , LEN(%FileKeyField) - INSTRING(':',%FileKeyField,1,1)) & ';')
#SET(%RelToList , %RelToList & SUB(%FileKeyFieldLink , INSTRING(':',%FileKeyFieldLink,1,1) + 1 , LEN(%FileKeyFieldLink) - INSTRING(':',%FileKeyFieldLink,1,1)) & ';')
#ENDFOR
#ENDFOR
#!-----------------------------------------------------------------------------------------!
#! RA.2020.05.23.SAT: The plain GUID is on the left side. Consistency helps with patterns. !
#!-----------------------------------------------------------------------------------------!
#FOR(%RelSort)
#!---- %[60]RelSort %@S30@(%RelFind) %@S30@(%RelShow) (%[60]RelRASQL)
#IF(%RelType='1:MANY')
-- %[05]NULL %[06]RelType %[0]NULL %[58]RelFromId %[0]NULL %[58]RelToId %[1]NULL [%[12]RelPrefix] %RelRASQL
-- %[13]NULL %[58]RelFromList %[0]NULL %[58]RelToList
#ELSE
-- %[05]NULL %[06]RelType %[0]NULL %[58]RelToId %[0]NULL %[58]RelFromId %[1]NULL [%[12]RelPrefix] %RelRASQL
-- %[13]NULL %[58]RelToList %[0]NULL %[58]RelFromList
#ENDIF
#ENDFOR
#!
#! #FOR(%Relation)
#! #IF(%FileRelationType='1:MANY')
#! #SET(%RelKeyFromID,SUB(%FileKey , INSTRING(':',%FileKey,1,1) + 1 , LEN(%FileKey) - INSTRING(':',%FileKey,1,1)))
#! #SET(%RelKeyToID ,SUB(%RelationKey, INSTRING(':',%RelationKey,1,1) + 1 , LEN(%RelationKey) - INSTRING(':',%RelationKey,1,1)))
#! -- %[05]NULL %[06]FileRelationType %[0]NULL %[67]RelKeyFromID %[0]NULL %[67]RelKeyToID %[0]NULL %RelationUserOptions
#! #!-- %[05]NULL %[06]FileRelationType %[0]NULL %[67]FileKey %[0]NULL %[67]RelationKey %[0]NULL %RelationUserOptions
#! #SET(%RelFieldFromList,'')
#! #SET(%RelFieldToList,'')
#! #FOR(%FileKeyField)
#! #SET(%RelFieldFromList, SUB(%FileKeyField , INSTRING(':',%FileKeyField,1,1) + 1 , LEN(%FileKeyField) - INSTRING(':',%FileKeyField,1,1)) & ';')
#! #SET(%RelFieldToList , SUB(%FileKeyFieldLink, INSTRING(':',%FileKeyFieldLink,1,1) + 1 , LEN(%FileKeyFieldLink) - INSTRING(':',%FileKeyFieldLink,1,1)) & ';')
#! #!-- %[05]NULL %[30]FileKeyField %[0]NULL %[30]FileKeyFieldLink
#! #ENDFOR
#! -- %[13]NULL %[67]RelFieldFromList %[0]NULL %[67]RelFieldToList
#! #ENDIF
#! #ENDFOR
#! #FOR(%Relation)
#! #IF(%FileRelationType='MANY:1')
#! #SET(%RelKeyFromID,SUB(%FileKey , INSTRING(':',%FileKey,1,1) + 1 , LEN(%FileKey) - INSTRING(':',%FileKey,1,1)))
#! #SET(%RelKeyToID ,SUB(%RelationKey, INSTRING(':',%RelationKey,1,1) + 1 , LEN(%RelationKey) - INSTRING(':',%RelationKey,1,1)))
#! -- %[05]NULL %[06]FileRelationType %[0]NULL %[67]RelKeyFromID %[0]NULL %[67]RelKeyToID %[0]NULL %RelationUserOptions
#! #!-- %[05]NULL %[06]FileRelationType %[0]NULL %[67]FileKey %[0]NULL %[67]RelationKey %[0]NULL %RelationUserOptions
#! #SET(%RelFieldFromList,'')
#! #SET(%RelFieldToList,'')
#! #FOR(%FileKeyField)
#! #SET(%RelFieldFromList, SUB(%FileKeyField , INSTRING(':',%FileKeyField,1,1) + 1 , LEN(%FileKeyField) - INSTRING(':',%FileKeyField,1,1)) & ';')
#! #SET(%RelFieldToList , SUB(%FileKeyFieldLink, INSTRING(':',%FileKeyFieldLink,1,1) + 1 , LEN(%FileKeyFieldLink) - INSTRING(':',%FileKeyFieldLink,1,1)) & ';')
#! #!-- %[05]NULL %[30]FileKeyField %[0]NULL %[30]FileKeyFieldLink
#! #ENDFOR
#! -- %[13]NULL %[67]RelFieldFromList %[0]NULL %[67]RelFieldToList
#! #ENDIF
#! #ENDFOR
#!
#ENDIF
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------