forked from RobertArtigas/DCT2SQL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
D2_00_UTIL3.TPW
176 lines (174 loc) · 6.58 KB
/
D2_00_UTIL3.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
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! File Name: D2UTIL3.tpw
#! Purpose: Utilites to deal with dictionaries
#! Author: Copyright © 1999-2011 by Roberto Artigas Jr
#! All rights reserved world wide.
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#CODE(MB_FindMismatchedColumnNames,'2018.06.03: [DCT2SQL-MG] Find Mistmatched Column External names')
#!--------------------------------------------------------------------
#! Changes:
#! 2018.06.03.SUN Michael Gorman
#! * Give me some code to show this Mismatched column names
#!--------------------------------------------------------------------
#Declare(%TempKeyColumn)
#Declare(%TempTableName)
#FOR(%File)
#SET(%TempTableName,%File)
#IF(SUB(%TempTableName,1,2) = 'A_')
#Cycle
#ELSIF(SUB(%TempTableName,1,2) = 'A2')
#Cycle
#ELSIF(SUB(%TempTableName,1,2) = 'A3')
#Cycle
#ELSIF(SUB(%TempTableName,1,2) = 'A4')
#Cycle
#ELSIF(SUB(%TempTableName,1,2) = 'A5')
#Cycle
#ELSIF(SUB(%TempTableName,1,3) = 'AUT')
#Cycle
#ELSIF(SUB(%TempTableName,1,7) = 'TagFile')
#Cycle
#ELSIF(SUB(%TempTableName,1,6) = 'TagSet')
#Cycle
#ELSIF(SUB(%TempTableName,1,7) = 'Convert')
#Cycle
#ELSIF(SUB(%TempTableName,1,3) = 'SIE')
#Cycle
#ELSIF(SUB(%TempTableName,1,5) = 'LIMIT')
#Cycle
#ELSIF(SUB(%TempTableName,1,7) = 'SourceF')
#Cycle
#ELSIF(SUB(%TempTableName,1,7) = 'OutlayT')
#Cycle
#ELSIF(SUB(%TempTableName,1,7) = 'Outlayt')
#Cycle
#ELSIF(SUB(%TempTableName,1,7) = 'DBMSSet')
#Cycle
#ENDIF
#FOR(%Key),Where(%KeyPrimary=1)
#FOR(%KeyField)
#FIX(%Field,%KeyField)
#SET(%TempKeyColumn,SUB(%FieldName,2,LEN(CLIP(%FieldName))-2))
#IF(Instring('|',%TempKeyColumn,1,1))
#SET(%TempKeyColumn,CLIP(SUB(%TempKeyColumn,1,(Instring('|',%TempKeyColumn,1,1)-1))))
#ENDIF
#IF(lower(%FieldId) <> lower(%TempKeyColumn))
#!EMBED(%DCT2SQL_BegMistmatch,'Before: Mistmatch CHECK done')
! MisMatch: %TempTableName with %Field %FieldStatement vs [%fieldId] [%TempKeyColumn]
#!EMBED(%DCT2SQL_BegMistmatch,'Before: Mistmatch CHECK done')
#ENDIF
#ENDFOR
#ENDFOR
#ENDFOR
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
GROUP(%CopyrightMISMATCHED)
#BOXED('Version 1.0 [ 2018.06.01 ]'),AT(,,278),PROP(PROP:FontStyle,700)
#!DISPLAY(''),AT(,,,1)
#DISPLAY('MISTMATCHED EXTERNAL PKEY names in use for ABC.' ),AT(10)
#DISPLAY('Copyright © 2001-2099 by Roberto Artigas y Soler.'),AT(10)
#DISPLAY('All copyrights reserved world wide.' ),AT(10)
#DISPLAY('E-MAIL: [email protected]' ),AT(10)
#ENDBOXED
#!
#GROUP(%MITLicenseLOCKCHECK)
#TAB('MISTMATCHED'),PROP(PROP:FontStyle,700)
#INSERT(%CopyrightMISMATCHED)
#INSERT(%MITLicenseDCT2SQL)
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#EXTENSION(zFindMismatchedColumnNames,'2018.06.03: [DCT2SQL-MG] Find Mistmatched Column External names'),PROCEDURE
#!INSERT(%Preamble) #! Basic copyright message
#DISPLAY('')
#DISPLAY('')
#DISPLAY('')
#DISPLAY('')
#DISPLAY('')
#DISPLAY('')
#DISPLAY('')
#SHEET,AT(,,288),HSCROLL
#!INSERT(%MITLicenseLOCKCHECK)
#TAB('General')
#BOXED('FindMismatchedColumnNames'),AT(,,280)
#DISPLAY(''),AT(,,,1)
#DISPLAY('Find Mistmatched Column External Names.')
#!DISPLAY('')
#!DISPLAY('This has been tested with the ABC template chains.')
#ENDBOXED
#BOXED('Hidden Variables'),AT(,,280),HIDE
#DISPLAY(''),AT(,,,1)
#PROMPT('MistmatchCount:',@N3),%MistmatchCount,DEFAULT(0)
#PROMPT('TempKeyColumn: ',@s120),%TempTableName
#PROMPT('TempTableName: ',@s120),%TempKeyColumn
#ENDBOXED
#ENDTAB
#ENDSHEET
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! #Declare(%TempKeyColumn)
#! #Declare(%TempTableName)
#!---------------------------------------------------------------------
#AT(%DataSection),PRIORITY(5)
#SET(%MistmatchCount,0)
#!EMBED(%DCT2SQL_BegMistmatch,'Before: Mistmatch CHECK done')
! LIST: Items that do not match between the PRIMARY key and the EXTERNAL name.
#FOR(%File)
#!----------------------------------!
#! Ignore certain file DRIVER types !
#!----------------------------------!
#CASE(%FileDriver)
#OF ('ASCII')
#OROF('BASIC')
#OROF('DOS')
#OROF('MEMORY')
#CYCLE
#ENDCASE
#!---------------------------!
#! Ignore certain FILE types !
#!---------------------------!
#CASE(%FileType)
#OF ('VIEW')
#OROF('ALIAS')
#CYCLE
#ENDCASE
#!-------------------------------------!
#! Ignore FILES with NO FIELDS in them !
#!-------------------------------------!
#IF(NOT ITEMS(%Field))
#CYCLE
#ENDIF
#!
#CASE(UPPER(%File))
#OF ('LIMIT')
#CYCLE
#ENDCASE
#!
#SET(%TempTableName,%File)
#FOR(%Key),Where(%KeyPrimary=1)
#FOR(%KeyField)
#FIX(%Field,%KeyField)
#SET(%TempKeyColumn,SUB(%FieldName,2,LEN(CLIP(%FieldName))-2))
#IF(Instring('|',%TempKeyColumn,1,1))
#SET(%TempKeyColumn,CLIP(SUB(%TempKeyColumn,1,(Instring('|',%TempKeyColumn,1,1)-1))))
#ENDIF
#IF(lower(%FieldId) <> lower(%TempKeyColumn))
#SET(%MistmatchCount,%MistmatchCount + 1)
! MisMatch: %TempTableName with %Field %FieldStatement vs [%fieldId] [%TempKeyColumn]
#ENDIF
#ENDFOR
#ENDFOR
#ENDFOR
! TOTAL: There are %MistmatchCount items that do not match between the PRIMARY key and the EXTERNAL name.
#!EMBED(%DCT2SQL_EndMistmatch,'After: Mistmatch CHECK done')
#ENDAT
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------