-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathD2M2_UTL004.TPW
286 lines (286 loc) · 15.5 KB
/
D2M2_UTL004.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
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! File Name: D2M2_UTL004.tpw
#! Purpose: UTILITY: Check for RESERVED words
#! Author: Copyright © 1999-2999 by Roberto Artigas Jr
#! All rights reserved world wide.
#! Changes:
#! 2020.07.17 Roberto Artigas
#! * Rework template, reformat lines, add DCT2SQL infrastructure.
#! 2007.04.27 Roberto Artigas
#! * Re-arranged output line to align all the fields neatly
#! 2007.04.21 Bo Schmitz
#! * Begin creation of this template (specific requirements)
#!
#UTILITY(D2M2_UTIL_RESERVED, '2020.07.17: [UTIL] Check for RESERVED words')
#!-----------------------------------------------------------------------------
#! 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(%VariablesUtility004) #! RA.2019.07.25.THU: Added
#!---------------------------------------------------------------------
#INSERT(%SqlReservedWords)
#IF(%opt004AddClarion)
#INSERT(%ClarionReservedWords)
#FOR(%ClarionWordList)
#ADD(%SqlWordList,%ClarionWordList)
#ENDFOR
#ENDIF #!IF(%opt004AddClarion)
#!---------------------------------------------------------------------
#SHEET,HSCROLL,AT(,,464)
#INSERT(%MITLicenseD2M2UTL004)
#INSERT(%ShowExplainUtilRESERVED)
#INSERT(%ShowExplainUtilRESERVED2)
#INSERT(%MetabaseTabSelection)
#ENDSHEET
#!---------------------------------------------------------------------
#! START EXECUTION HERE
#!---------------------------------------------------------------------
#!#DECLARE(%DebugSet,LONG)
#!#SET(%DebugSet,1)
#!#DEBUG(%DebugSet)
#!
#SET(%UtilityChekTable , %TRUE)
#SET(%UtilityNameTable , %DictName & '_' & %BaseUtil & '_RESERVED_WORDS.TXT') #! RA.2020.03.24: Changed
#SET(%UtilityNameTableOut , %DictPath & %UtilityNameTable)
#!
#CALL(%UtilityPrefix , %BaseUtil) #! RA.2020.03.24: Changed
#CALL(%BuildQualifiedFiles)
#IF(%TRUE)
#SET(%LineCount , 0)
#SET(%AuditLines, 0)
#!-- Processed Files -- BEGIN %[41]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
-- SEQ# TYPE %[3]NULL PREFIX %[2]NULL FILENAME %[22]NULL TYPENAME %[22]NULL EXTERNALNAME %[28]NULL DRIVERTYPE %[0]NULL RESERVED-WORD
--
#FOR(%NFiles)
#FIX(%File, %NFilesName)
#!
#IF(UPPER(%FileDriver) = 'CLARION' AND %opt004UseDriverClarion)
#CYCLE
#ENDIF
#IF(UPPER(%FileDriver) = 'TOPSPEED' AND %opt004UseDriverTopspeed)
#CYCLE
#ENDIF
#!
#IF(~%opt004IgnoreNamesTable)
#SET(%ItemType,'_FILE_')
#SET(%SqlWordItem, UPPER(%File))
#FIND(%SqlWordList, %SqlWordItem)
#!
#IF(%SqlWordList)
#SET(%LineCount,%LineCount+1)
-- %@N04@(%LineCount) %@S7@(%ItemType) %[0]NULL %[8]FilePrefix %[0]NULL %[30]NFilesName %[0]NULL %[30]NFilesName %[0]NULL %[40]FileName %[0]NULL %[10]FileDriver %[0]NULL %SqlWordList
#SET(%AuditLines, %AuditLines + 1)
#IF(%AuditLines % 20 = 0 AND ITEMS(%NFiles) <> %AuditLines)
--
-- SEQ# TYPE %[3]NULL PREFIX %[2]NULL FILENAME %[22]NULL TYPENAME %[22]NULL EXTERNALNAME %[28]NULL DRIVERTYPE %[0]NULL RESERVED-WORD
--
#ENDIF
#ENDIF
#ENDIF #!IF(~%opt004IgnoreNamesTable)
#!
#IF(~%opt004IgnoreNamesKey)
#SET(%ItemType,'_KEY_')
#FOR(%Key)
#!-----------------------------------------!
#! RA.2010.09.13 - Processing key options. !
#!-----------------------------------------!
#SET(%nLoc1,INSTRING('RASQL(',%KeyUserOptions,1,1))
#SET(%nLoc2,INSTRING(')',%KeyUserOptions,1,%nLoc1))
#SET(%nKeyUser,UPPER(SUB(%KeyUserOptions,%nLoc1,%nLoc2)))
#!SET(%NKeyUser,UPPER(EXTRACT(%KeyUserOptions,'RASQL')))
#SET(%NKeyOpt1,EXTRACT(%NKeyUser,'RASQL',1))
#SET(%NKeyOpt2,EXTRACT(%NKeyUser,'RASQL',2))
#SET(%NKeyOpt3,EXTRACT(%NKeyUser,'RASQL',3))
#SET(%NKeyOpt4,EXTRACT(%NKeyUser,'RASQL',4))
#!%NKeyUser, %NKeyOpt1, %NKeyOpt2, %NKeyOpt3, %NKeyOpt4
#!------------------------------------------------------------!
#! The first option RASQL(NO) controls if a key is processed. !
#!------------------------------------------------------------!
#IF(SUB(%NKeyOpt1,1,1)='N')
#CYCLE
#ENDIF
#SET(%SqlWordItem, UPPER(%KeyID))
#FIND(%SqlWordList, %SqlWordItem)
#!
#IF(%SqlWordList)
#SET(%LineCount,%LineCount+1)
-- %@N04@(%LineCount) %@S7@(%ItemType) %[0]NULL %[8]FilePrefix %[0]NULL %[30]NFilesName %[0]NULL %[30]KeyID %[0]NULL %[40]KeyName %[0]NULL %[10]FileDriver %[0]NULL %SqlWordList
#SET(%AuditLines, %AuditLines + 1)
#IF(%AuditLines % 20 = 0 AND ITEMS(%NFiles) <> %AuditLines)
--
-- SEQ# TYPE %[3]NULL PREFIX %[2]NULL FILENAME %[22]NULL TYPENAME %[22]NULL EXTERNALNAME %[28]NULL DRIVERTYPE %[0]NULL RESERVED-WORD
--
#ENDIF
#ENDIF
#ENDFOR
#ENDIF #!IF(~%opt004IgnoreNamesKey)
#!
#!
#SET(%ItemType,'_FIELD_')
#FOR(%Field)
#SET(%SqlWordItem, UPPER(%FieldID))
#FIND(%SqlWordList, %SqlWordItem)
#IF(%SqlWordList)
#SET(%LineCount,%LineCount+1)
-- %@N04@(%LineCount) %@S7@(%ItemType) %[0]NULL %[8]FilePrefix %[0]NULL %[30]NFilesName %[0]NULL %[30]FieldID %[0]NULL %[40]FieldName %[0]NULL %[10]FileDriver %[0]NULL %SqlWordList
#SET(%AuditLines, %AuditLines + 1)
#IF(%AuditLines % 20 = 0 AND ITEMS(%NFiles) <> %AuditLines)
--
-- SEQ# TYPE %[3]NULL PREFIX %[2]NULL FILENAME %[22]NULL TYPENAME %[22]NULL EXTERNALNAME %[28]NULL DRIVERTYPE %[0]NULL RESERVED-WORD
--
#ENDIF
#ENDIF
#ENDFOR
#!
#!
#ENDFOR
--
-- SEQ# TYPE %[3]NULL PREFIX %[2]NULL FILENAME %[22]NULL TYPENAME %[22]NULL EXTERNALNAME %[28]NULL DRIVERTYPE %[0]NULL RESERVED-WORD
#ENDIF
#CALL(%UtilitySuffix , %BaseUtil) #! RA.2020.03.24: Changed
#!
#!
#!#SET(%DebugSet,0)
#!#DEBUG(%DebugSet)
#!---------------------------------------------------------------------
#! END EXECUTION HERE
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%MITLicenseD2M2UTL004)
#TAB('UTIL_RESERVED'),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 add Clarion reserved words. ON: Add Clarion reserved words.' , CHECK), %opt004AddClarion, AT(10)
#!DISPLAY('')
#PROMPT('OFF: Ignore CLARION driver. ON: Use CLARION driver.' , CHECK), %opt004UseDriverClarion, AT(10)
#PROMPT('OFF: Ignore TOPSPEED driver. ON: Use TOPSPEED driver.' , CHECK), %opt004UseDriverTopspeed, AT(10)
#!DISPLAY('')
#PROMPT('OFF: Use table names. ON: Ignore table names.' , CHECK), %opt004IgnoreNamesTable, AT(10)
#PROMPT('OFF: Use key names. ON: Ignore key names.' , CHECK), %opt004IgnoreNamesKey, AT(10)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%ExplainUtilRESERVED)
#PREPARE
#IF(NOT VAREXISTS(%ExplainTextRESERVED))
#DECLARE(%ExplainTextRESERVED)
#ENDIF
#SET(%ExplainTextRESERVED, '')
#!SET(%ExplainTextRESERVED, %ExplainTextRESERVED & 'This is one of the METABASE templates.')
#!SET(%ExplainTextRESERVED, %ExplainTextRESERVED & '<13,10><13,10>')
#SET(%ExplainTextRESERVED, %ExplainTextRESERVED & 'This generic utility will check file, field, and key names in the dictionary')
#SET(%ExplainTextRESERVED, %ExplainTextRESERVED & ' for SQL reserved words that may give you problems in the various back ends.')
#!SET(%ExplainTextRESERVED, %ExplainTextRESERVED & '<13,10><13,10>')
#!SET(%ExplainTextRESERVED, %ExplainTextRESERVED & '<13,10><13,10>')
#!SET(%ExplainTextRESERVED, %ExplainTextRESERVED & 'This template has been tested with the ABC template chains.')
#SET(%ExplainTextRESERVED, %ExplainTextRESERVED & '')
#ENDPREPARE
#!
#GROUP(%ShowExplainUtilRESERVED)
#INSERT(%ExplainUtilRESERVED)
#!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'),AT(,,454),PROP(PROP:FontStyle,700)
#DISPLAY(''),AT(,,,1)
#DISPLAY(%ExplainTextRESERVED),AT(,,436,204)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!--------------------------------------------------------------------- #! RA.2019.07.25: Added
#GROUP(%VariablesUtility004)
#PREPARE
#DECLARE(%NextLine)
#DECLARE(%AuditLines)
#DECLARE(%ItemType)
#DECLARE(%LineCount)
#!DECLARE(%KeyFieldList)
#!DECLARE(%KeyFieldID)
#!
#DECLARE(%opt004AddClarion ,LONG)
#SET(%opt004AddClarion ,FALSE)
#DECLARE(%opt004UseDriverClarion ,LONG)
#SET(%opt004UseDriverClarion ,FALSE)
#DECLARE(%opt004UseDriverTopspeed ,LONG)
#SET(%opt004UseDriverTopspeed ,FALSE)
#DECLARE(%opt004IgnoreNamesTable ,LONG)
#SET(%opt004IgnoreNamesTable ,FALSE)
#DECLARE(%opt004IgnoreNamesKey ,LONG)
#SET(%opt004IgnoreNamesKey ,FALSE)
#ENDPREPARE
#!---------------------------------------------------------------------
#!--------------------------------------------------------------------- #! RA.2019.07.25: Added
#GROUP(%ReservedFilesFieldsKeys004)
#! #IF(%opt003AuditGUID)
#! #!-- %[05]NULL GUID %[1]NULL TS %[3]NULL STS %[2]NULL DTS %[2]NULL KGUID %[0]NULL KTS %[2]NULL KSTS %[1]NULL KDTS
#! -- %[05]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
#! #ENDIF
#! #IF(ITEMS(%Field) AND %opt004UseDriverClarion)
#! -- %[05]NULL FIELD-NAME %[20]NULL EXTERNAL-NAME %[17]NULL INITIAL-VALUE %[16]NULL FIELD-OPTIONS
#! -- %[05]NULL ========== %[20]NULL ============= %[17]NULL ============= %[16]NULL =============
#! #FOR(%Field)
#! #SET(%NextLine, EXTRACT(%FieldStatement,'NAME'))
#! #SET(%NextLine, SUB(%NextLine,7,LEN(%NextLine)-8))
#! -- %[05]NULL %[30]FieldID %[0]NULL %[30]NextLine %[0]NULL %[29]FieldInitial %[0]NULL %FieldUserOptions
#! #ENDFOR
#! #ENDIF
#! #!
#! #IF(ITEMS(%Key) AND %opt004UseDriverTopspeed)
#! -- %[05]NULL KEY-NAME %[17]NULL EXTERNAL-NAME %[12]NULL KEY-FIELD-LIST %[46]NULL KEY-OPTIONS
#! -- %[05]NULL ======== %[17]NULL ============= %[12]NULL ============== %[46]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 %[25]KeyID %[0]NULL %[25]NextLine %[0]NULL %[60]KeyFieldList %[0]NULL %KeyUserOptions
#! #ENDFOR
#! #ENDIF
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------