-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathD2M2_000.TPW
More file actions
4320 lines (4308 loc) · 245 KB
/
D2M2_000.TPW
File metadata and controls
4320 lines (4308 loc) · 245 KB
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! File Name: D2M2_000.tpw
#! Purpose: METABASE: DCT to GENERIC creation script
#! Author: Copyright © 1999-2999 by Roberto Artigas Jr
#! All rights reserved world wide.
#! Changes:
#! 2025.08.30.SAT Roberto Artigas y Soler
#! * Added pading default(40) for the create DDL script.
#! 2020.09.11.FRI Roberto Artigas (REQUEST: Mr. Hickey)
#! * Convert REAL to BIGINT for TimeStamp [???] ts,sts,dts (GUID)
#! 2020.06.11.WED: Roberto Artigas
#! * Let's add quoting. Need to deal with Postgres "MixedCase" names.
#! 2020.05.25.MON: Roberto Artigas (Mr. John Hickey found bug.)
#! * Correct missed external options for some items.
#! 2019.07.25: Roberto Artigas
#! * Moved some code into other source files.
#! 2019.07.19: Roberto Artigas
#! * Added basic GUID/UUID create table generation setup options. Not much else.
#! 2019.07.04: Roberto Artigas
#! * Added option to select files to do SQL generation.
#! 2018.11.09 Roberto Artigas
#! * No AUTO-INCREMENT flag found (And you need to generate a ROW level AUTO-INCREMENT)
#! Problem created by Mr. Michael Gorman. Changed how he does things with no warning.
#! Lucky: There is enough information available to ---guess--- this needs to happen.
#! 2018.04.07 Roberto Artigas
#! * The backend being generated for is now passed as a parameter.
#! 2018.03.15 Roberto Artigas
#! * Metabase and Mimer templates use WinSQL to process DDL statements.
#! This means the semi-colons at the end get replaced with GO.
#! * Seems that WinSQL has a problem with comments being submitted
#! by themselves and then reaching the end of a DDL script.
#! You get a syntax error that has nothing to do with anything.
#! 2017.09.29 Roberto Artigas
#! * Creation of this generic structured template
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%MITLicenseD2M2000)
#TAB('MIT'),PROP(PROP:FontStyle,700)
#INSERT(%MITLicense)
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!
#UTILITY(D2M2_000, '2019.07.28: [MB] METABASE-SKELETON script')
#!-----------------------------------------------------------------------------
#! RA.2018.03.16 - Mimer: WinSQL does not like trailing comments. Gives errors.
#! RA.2017.12.27 - Made the METABASE same as MIMER. Got to have a starting point.
#! 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(%BaseUtil) #! Define the UTILITY here
#SET(%BaseUtil, 'CLARION') #! TPLUTILITY: NOT A BACKEND
#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, 'SQLITE') #! SQLITE: ???
#SET(%BaseName, 'MYSQL') #! MYSQL: RAYS.2018.09.03: Tested.
#SET(%BaseName, 'SQLANYWHERE') #! SQLANYWHERE: RAYS.2018.06.12: Tested.
#SET(%BaseName, 'POSTGRESQL') #! POSTGRESQL: RAYS.2018.06.10: Tested.
#SET(%BaseName, 'MSSQL') #! MSSQL: RAYS.2018.06.03: Tested.
#SET(%BaseName, 'MIMER') #! MIMER: RAYS.2018.04.07: Tested.
#SET(%BaseName, 'METABASE') #! METABASE: Generic-Skeleton. NO backend.
#ENDPREPARE
#!---------------------------------------------------------------------
#!INSERT(%Preamble) \ #! Basic copyright message
#!INSERT(%DefineAreasOptions) #! File,Field,Keys,Relations
#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(%Preamble) #! Basic copyright message
#!---------------------------------------------------------------------
#!SHEET,HSCROLL,AT(,,288)
#SHEET,HSCROLL,AT(,,464)
#INSERT(%ShowVariables)
#INSERT(%MITLicenseD2M2000)
#INSERT(%MetabaseTabSelection) #! RA.2019.07.04: Added FILE selection
#INSERT(%MetabaseTabNames)
#INSERT(%MetabaseTabCreateDropOther)
#INSERT(%MetabaseTabCreateDropScripting) #! RA.2019.07.28: Added
#INSERT(%MetabaseTabOptions)
#INSERT(%MetabaseTabStrings)
#INSERT(%MetabaseTabArrays)
#ENDSHEET
#!---------------------------------------------------------------------
#! START EXECUTION HERE
#!---------------------------------------------------------------------
#!#DECLARE(%DebugSet,LONG)
#!#SET(%DebugSet,1)
#!#DEBUG(%DebugSet)
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#!INSERT(%MetabaseGenerate) #! DDL scripts for METABASE
#!CALL(%MetabaseGenerate) #! DDL scripts for METABASE
#CALL(%MetabaseGenerate,%BaseName) #! DDL scripts for METABASE
#!
#!#SET(%DebugSet,0)
#!#DEBUG(%DebugSet)
#!---------------------------------------------------------------------
#! END EXECUTION HERE
#!---------------------------------------------------------------------
#GROUP(%Preamble) #! Basic copyright message
#BOXED('The METABASE-' & %BaseName & ' Script Creator'),PROP(PROP:FontStyle,700)
#DISPLAY(''),AT(,,,1)
#!DISPLAY('The METABASE-' & %BaseName & ' Script Creator.')
#DISPLAY('Copyright © 1999-2999 by Roberto Artigas y Soler')
#DISPLAY('All Rights Reserved World Wide.')
#DISPLAY('Released under the conditions of the MIT license.')
#DISPLAY('E-mail: roberto.artigas.dev@gmail.com')
#DISPLAY('Skype: Clarion Live Chat | CW-Talk')
#ENDBOXED
#!---------------------------------------------------------------------
#GROUP(%PreambleUtility) #! 2019.07.07.SUN: Added
#BOXED('A UTILITY-' & %BaseName & ' Generic Utility'),PROP(PROP:FontStyle,700)
#DISPLAY(''),AT(,,,1)
#DISPLAY('Copyright © 1999-2999 by Roberto Artigas y Soler')
#DISPLAY('All Rights Reserved World Wide.')
#DISPLAY('Released under the conditions of the MIT license.')
#DISPLAY('E-mail: roberto.artigas.dev@gmail.com')
#DISPLAY('Skype: Clarion Live Chat | CW-Talk')
#ENDBOXED
#!---------------------------------------------------------------------
#GROUP(%PreambleCombined) #! 2019.08.14.WED: Added
#BOXED('A COMBINED-' & %BaseName & ' Script Creator'),PROP(PROP:FontStyle,700)
#DISPLAY(''),AT(,,,1)
#DISPLAY('Copyright © 1999-2999 by Roberto Artigas y Soler')
#DISPLAY('All Rights Reserved World Wide.')
#DISPLAY('Released under the conditions of the MIT license.')
#DISPLAY('E-mail: roberto.artigas.dev@gmail.com')
#DISPLAY('Skype: Clarion Live Chat | CW-Talk')
#ENDBOXED
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%ExplainDCT2SQL)
#PREPARE
#IF(NOT VAREXISTS(%ExplainTextDCT2SQL))
#DECLARE(%ExplainTextDCT2SQL)
#ENDIF
#SET(%ExplainTextDCT2SQL, '')
#!SET(%ExplainTextDCT2SQL, %ExplainTextDCT2SQL & 'This is one of the METABASE templates.')
#!SET(%ExplainTextDCT2SQL, %ExplainTextDCT2SQL & '<13,10><13,10>')
#SET(%ExplainTextDCT2SQL, %ExplainTextDCT2SQL & 'The CREATE and DROP tabs have a set of unique DDL scripts that will allow')
#SET(%ExplainTextDCT2SQL, %ExplainTextDCT2SQL & ' the generating of these scripts individually so you can mix and match scripts.')
#SET(%ExplainTextDCT2SQL, %ExplainTextDCT2SQL & '<13,10><13,10>')
#SET(%ExplainTextDCT2SQL, %ExplainTextDCT2SQL & 'These DDL scripts will help in the loading of the data and the reindexing')
#SET(%ExplainTextDCT2SQL, %ExplainTextDCT2SQL & ' of the any database tables as needed.')
#!SET(%ExplainTextDCT2SQL, %ExplainTextDCT2SQL & '<13,10><13,10>')
#!SET(%ExplainTextDCT2SQL, %ExplainTextDCT2SQL & 'This template has been tested with the ABC template chains.')
#SET(%ExplainTextDCT2SQL, %ExplainTextDCT2SQL & '')
#ENDPREPARE
#!
#GROUP(%ShowVariables)
#INSERT(%ExplainDCT2SQL)
#!TAB(UPPER(%Application) & '.' & UPPER(%ProgramExtension)),PROP(PROP:FontStyle,700),PROP(PROP:FontColor,0C79A3H)
#TAB(UPPER(%DictName) & '.DCT'),PROP(PROP:FontStyle,700),PROP(PROP:FontColor,0C79A3H)
#BOXED('Instructions'),AT(,,454),PROP(PROP:FontStyle,700)
#DISPLAY(''),AT(,,,1)
#!DISPLAY(%ExplainTextDCT2SQL),AT(,,260,74)
#!DISPLAY(%ExplainTextDCT2SQL),AT(,,260,40)
#DISPLAY(%ExplainTextDCT2SQL),AT(,,436,34)
#ENDBOXED
#!------------------------------------------------------!
#!+++BANANA: TESTING: Hide or show debug variables !
#!------------------------------------------------------!
#BOXED('Hidden Variables'),AT(,,454) #!,HIDE
#DISPLAY(''),AT(,,,1)
#!PROMPT('' ,@S120), %CreateNameTable , AT(10,,266), PROP(PROP:Readonly, 1) #!, PROP(PROP:Trn, 1)
#!PROMPT('' ,@S120), %CreateNameTableOut, AT(10,,266), PROP(PROP:Readonly, 1) #!, PROP(PROP:Trn, 1)
#PROMPT('' ,@S120), %CreateNameTable , AT(10,,444), PROP(PROP:Readonly, 1) #!, PROP(PROP:Trn, 1)
#PROMPT('' ,@S120), %CreateNameTableOut, AT(10,,444), PROP(PROP:Readonly, 1) #!, PROP(PROP:Trn, 1)
#!PROMPT('DictPath: ' ,@S80 ), %DictPath, AT(60,,216), PROP(PROP:Readonly, 1), PROP(PROP:Skip, 1)
#PROMPT('DictPath: ' ,@S80 ), %DictPath, AT(60,,394), PROP(PROP:Readonly, 1), PROP(PROP:Skip, 1)
#PROMPT('DictName: ' ,@S40 ), %DictName, AT(60,,60), PROP(PROP:Readonly, 1)
#PROMPT('BaseName: ' ,@S40 ), %BaseName, AT(60,,60), PROP(PROP:Readonly, 1)
#!PROMPT('nLoc1: ' ,@N4 ), %nLoc1, AT(60,,60), PROP(PROP:Readonly, 1)
#!PROMPT('nLoc2: ' ,@N4 ), %nLoc2, AT(60,,60), PROP(PROP:Readonly, 1)
#PROMPT('Generate comments (filtered out by backend)', CHECK), %Comments, AT(10), DEFAULT(TRUE)
#PROMPT('Trace the SQL DDL code generation group flow', CHECK), %TraceFlow, AT(10), DEFAULT(FALSE)
#PROMPT('Trace detail generation for debug purposes', CHECK), %TraceDetail, AT(10), DEFAULT(FALSE)
#PROMPT('Trace option parameters for debug purposes', CHECK), %TraceOption, AT(10), DEFAULT(FALSE)
#!PROMPT('Database: ' ,@S80 ), %NameDatabase , AT(60,,60)
#!PROMPT('Owner: ' ,@S40 ), %NameOwner , AT(60,,60)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2025.07.15: Added possible number of files you can select
#! RA.2019.07.04: Added option to select files to do SQL generation.
#GROUP(%MetabaseTabSelection)
#TAB('Selection') #!,PROP(PROP:FontStyle,700),PROP(PROP:FontColor,0C79A3H)
#BOXED('Dictionary: ' & %DictName & '.DCT ( There are ' & ITEMS(%NFilesSort) & ' possible tables to select )'),AT(,,454),PROP(PROP:FontStyle,700)
#DISPLAY(''),AT(,,,1)
#PROMPT ('Generate SQL for all files in the dictionary?', CHECK), %optUseAllFiles, DEFAULT(1), AT(10)
#DISPLAY(''),AT(,,,1)
#ENABLE(~%optUseAllFiles)
#!PROMPT ('File Selection', FROM (%File)), %optFileSelection, INLINE, SELECTION('File Selection')
#PROMPT ('File Selection', FROM (%NFilesSort)), %optFileSelection, INLINE, SELECTION('File Selection')
#ENDENABLE
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.08 - Define some names for script generation
#GROUP(%MetabaseTabNames)
#TAB('Defines')
#! RA.2018.04.20: A bit more useful if it is the only item on the screen
#! #BOXED,SECTION
#! #BOXED('Define Constant Names'),AT(,0,454),WHERE(%optNameEnable)
#! #!DISPLAY(''),AT(,,,1)
#! #!PROMPT('Database: ' ,@S80 ), %NameDatabase , AT(60,,216)
#! #PROMPT('Database: ' ,@S80 ), %NameDatabase , AT(60,,60)
#! #PROMPT('Owner: ' ,@S40 ), %NameOwner , AT(60,,60)
#! #ENDBOXED
#! #BOXED('Define Constant Names (OPTION NOT REQUIRED)'),AT(,0,454),WHERE(NOT %optNameEnable)
#! #!DISPLAY(''),AT(,,,1)
#! #DISPLAY('')
#! #DISPLAY('')
#! #ENDBOXED
#! #ENDBOXED
#!
#! RA.2018.04.21: %NameDatabase is READ-ONLY. Just a reminder...
#! RA.2018.04.20: The "%optNameEnable" in both places blanks out everything.
#! Preserves the vertical spacing if you have several boxes.
#ENABLE(%optNameEnable)
#BOXED('Define Constant Names'),AT(,,454),WHERE(%optNameEnable)
#DISPLAY(''),AT(,,,1)
#!PROMPT('Database: ' ,@S80 ), %NameDatabase , AT(60,,216)
#PROMPT('Database: ' ,@S40 ), %NameDatabase , AT(60,,60) , PROP(PROP:Readonly, 1)
#PROMPT('Owner: ' ,@S40 ), %NameOwner , AT(60,,60)
#ENABLE(%optNameOwnerEnable)
#PROMPT('Use "Owner:" prefix when generating tables?', CHECK), %optNameOwnerUse, AT(10)
#ENDENABLE
#ENDBOXED
#ENDENABLE
#ENABLE(%optDefineNamesEnable)
#BOXED('Table Names | File Names'),AT(,,454)
#DISPLAY(''),AT(,,,1)
#PROMPT('Table Name Generation:',DROP('Table Names|File Names')),%optDefineNames,AT(110,,90),DEFAULT('Table Names')
#ENDBOXED
#ENDENABLE
#! RA.2019.07.19: This is basic GUID/UUID create table generation setup. Not much else.
#ENABLE(%optEnableGenerateGUID)
#BOXED('Enable GUID/UUID Generation'),AT(,,454)
#DISPLAY(''),AT(,,,1)
#PROMPT('Use backend support for GUID/UUID generation?', CHECK),%optGenerateGUID,AT(10)
#ENDBOXED
#ENDENABLE
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%MetabaseTabCreateDropOther)
#TAB('CREATE')
#!BOXED(''),AT(,,454)
#BOXED(%BaseName),AT(,,454),PROP(PROP:FontStyle,700)
#PROMPT('CREATE Table?' ,CHECK),%CreateChekTable ,AT(10)
#PROMPT('' ,@S120),%CreateNameTable ,AT(10,,444)
#!PROMPT('' ,@S120),%CreateNameTable ,AT(10,,266)
#!DISPLAY('')
#PROMPT('CREATE Sequence?' ,CHECK),%CreateChekSequence ,AT(10)
#PROMPT('' ,@S120),%CreateNameSequence ,AT(10,,444)
#!DISPLAY('')
#PROMPT('CREATE Primary Key?' ,CHECK),%CreateChekKeyPrimary ,AT(10)
#PROMPT('' ,@S120),%CreateNameKeyPrimary ,AT(10,,444)
#!DISPLAY('')
#PROMPT('CREATE Index Unique?' ,CHECK),%CreateChekIndexUnique ,AT(10)
#PROMPT('' ,@S120),%CreateNameIndexUnique ,AT(10,,444)
#!DISPLAY('')
#PROMPT('CREATE Index Not Unique?' ,CHECK),%CreateChekIndexNotUnique ,AT(10)
#PROMPT('' ,@S120),%CreateNameIndexNotUnique ,AT(10,,444)
#!DISPLAY('')
#PROMPT('CREATE Relation?' ,CHECK),%CreateChekRelation ,AT(10)
#PROMPT('' ,@S120),%CreateNameRelation ,AT(10,,444)
#!DISPLAY('')
#PROMPT('CREATE Grant? ' ,CHECK),%CreateChekGrant ,AT(10)
#PROMPT('' ,@S120),%CreateNameGrant ,AT(10,,444)
#ENDBOXED
#ENDTAB
#TAB('DROP')
#!BOXED(''),AT(,,454)
#BOXED(%BaseName),AT(,,454),PROP(PROP:FontStyle,700)
#PROMPT('DROP Table?' ,CHECK),%DropItChekTable ,AT(10)
#PROMPT('' ,@S120),%DropItNameTable ,AT(10,,444)
#!DISPLAY('')
#PROMPT('DROP Sequence?' ,CHECK),%DropItChekSequence ,AT(10)
#PROMPT('' ,@S120),%DropItNameSequence ,AT(10,,444)
#!DISPLAY('')
#PROMPT('DROP Primary Key?' ,CHECK),%DropItChekKeyPrimary ,AT(10)
#PROMPT('' ,@S120),%DropItNameKeyPrimary ,AT(10,,444)
#!DISPLAY('')
#PROMPT('DROP Index Unique?' ,CHECK),%DropItChekIndexUnique ,AT(10)
#PROMPT('' ,@S120),%DropItNameIndexUnique ,AT(10,,444)
#!DISPLAY('')
#PROMPT('DROP Index Not Unique?' ,CHECK),%DropItChekIndexNotUnique ,AT(10)
#PROMPT('' ,@S120),%DropItNameIndexNotUnique ,AT(10,,444)
#!DISPLAY('')
#PROMPT('DROP Relation?' ,CHECK),%DropItChekRelation ,AT(10)
#PROMPT('' ,@S120),%DropItNameRelation ,AT(10,,444)
#!DISPLAY('')
#PROMPT('DROP Grant? ' ,CHECK),%DropItChekGrant ,AT(10)
#PROMPT('' ,@S120),%DropItNameGrant ,AT(10,,444)
#ENDBOXED
#ENDTAB
#!
#! RA.2019.07.29: This area requires some knowledge of the SCRIPTING language for the backend.
#! NOTE: The ,WHERE(%optUseScripting) only shows the tabs for the BACKENDs that currently support this.
#!
#TAB('OTHER'),WHERE(%optUseScripting)
#BOXED(%BaseName),AT(,,454),PROP(PROP:FontStyle,700)
#PROMPT('Build GUID Index?' ,CHECK),%BuildChekIndexGUID ,AT(10)
#PROMPT('' ,@S120),%BuildNameIndexGUID ,AT(10,,444)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2019.07.28: This area requires some knowledge of the SCRIPTING language for the backend.
#! NOTE: The ,WHERE(%optUseScripting) only shows the tabs for the BACKENDs that currently support this.
#!
#! So it is only enabled if the code exists for the specific backend. Working on PostgreSQL.
#! At this time this is only in the METABASE (not a real backend) and PostgreSQL (what I use)
#! NOTE: TRIGGERs also contain logic and table field names that are specific to your system.
#! So that means that this area is highly customizable. (You need to know about templates.)
#GROUP(%MetabaseTabCreateDropScripting)
#TAB('CREATE2'),WHERE(%optUseScripting)
#BOXED(%BaseName),AT(,,454),PROP(PROP:FontStyle,700)
#PROMPT('CREATE Triggers?' ,CHECK),%CreateChekTrigger ,AT(10)
#PROMPT('' ,@S120),%CreateNameTrigger ,AT(10,,444)
#ENDBOXED
#ENDTAB
#TAB('DROP2'),WHERE(%optUseScripting)
#BOXED(%BaseName),AT(,,454),PROP(PROP:FontStyle,700)
#PROMPT('DROP Triggers?' ,CHECK),%DropItChekTrigger ,AT(10)
#PROMPT('' ,@S120),%DropItNameTrigger ,AT(10,,444)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.12.THU - Added full path name and driver to the comments.
#! RA.2018.04.08.SUN - Pass %BaseName as a parameter
#! RA.2018.03.17.SAT - No trailing comments for WinSQL. Errors out.
#GROUP(%TableNameComments,%pBaseName)
#IF(%Comments)
#CASE(%pBaseName) #! BACKEND EXCEPTIONS
#OF ('MIMER')
#ELSE
--
-- TABLE NAME: %NFilesName [%FilePrefix]
-- FILE NAME: %NFilesFullPath [%FileDriver]
--
#ENDCASE #! BACKEND EXCEPTIONS
#ENDIF
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%MetabaseTabOptions)
#TAB('Options')
#BOXED('Cosmetic Options'),AT(,,454)
#DISPLAY(''),AT(,,,1)
#PROMPT('Do DDL table create statement alignment for verification purposes? (ON=Align. OFF=No align.)',CHECK),%optDoSpaceAlign,AT(10)
#ENABLE(%optDoSpaceAlign) #! RA.2018.09.03: Added
#PROMPT('Pad Length: ',@S120),%optDoSpaceLength ,REQ,AT(100,,050),DEFAULT(40) #! 2025.08.30 RA: (NA)
#ENDENABLE
#ENDBOXED
#BOXED('Tables, Fields, Sequences, Indexes, Relations'),AT(,,454)
#DISPLAY(''),AT(,,,1)
#PROMPT('Add "_" to the end of reserved SQL words? (ON=Add "_". OFF=Do not add "_".)',CHECK),%optUnderReservedWords,AT(10)
#!-------------------------------------------------------------------------------------------!
#! RA.2020.09.08: Needs FURTHER testing or removal. Or just indexes to avoid the duplicates. !
#!-------------------------------------------------------------------------------------------!
#!PROMPT('Add table prefix to SQL names? (ON=Add prefix. OFF=Do not add prefix.)',CHECK),%optPrefixAllNames,AT(10)
#PROMPT('Add "quotes" around SQL names? (ON=Add quotes. OFF=Do not add quotes.)',CHECK),%optQuoteAllThings,AT(10)
#PROMPT('Make SQL names lower case? (ON=Make lower case. OFF=Leave case alone.)',CHECK),%optLowerCaseAllThings,AT(10)
#ENDBOXED
#BOXED('Odd and Ends Options'),AT(,,454)
#DISPLAY(''),AT(,,,1)
#PROMPT('Do not change Clarion LONG to SQL backend DATE and TIME? (ON=Leave LONG. OFF=Make change to DATE and TIME.)',CHECK),%optDoNotChangeLongToDateAndTime,AT(10)
#PROMPT('Make large STRINGs into CSTRINGs (CHAR -> VARCHAR)? (ON=VARCHAR. OFF=No VARCHAR.)',CHECK),%optDoChar2VarChar,AT(10)
#ENABLE(%optDoChar2VarChar) #! RA.2025.09.01: Added
#PROMPT('VARCHAR Length: ',@S120),%optDoChar2VarCharLength ,REQ,AT(100,,050),DEFAULT(128) #! 2025.09.01 RA: (NA)
#ENDENABLE
#!DISPLAY('')
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%MetabaseTabStrings)
#TAB('Strings/Keys/Blobs')
#BOXED('International Strings'),AT(,,454)
#DISPLAY(''),AT(,,,1)
#PROMPT('Generate international strings? ',CHECK),%optGenIntlString,AT(10)
#ENDBOXED
#!DISPLAY('')
#BOXED('NOT NULL Keys'),AT(,,454)
#DISPLAY(''),AT(,,,1)
#PROMPT('Generate NOT NULL keys? ',CHECK),%optGenNotNullKeys,AT(10)
#ENDBOXED
#!DISPLAY('')
#BOXED('BLOB to CLOB'),AT(,,454)
#DISPLAY(''),AT(,,,1)
#PROMPT('Generate CLOB fields? ',CHECK),%optGenClobFields,AT(10)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%MetabaseTabArrays)
#TAB('Arrays')
#BOXED('Handle Array Processing'),AT(,,454)
#DISPLAY(''),AT(,,,1)
#DISPLAY('There are two ways to handle arrays:')
#DISPLAY(''),AT(,,,1)
#DISPLAY('1) You defined a group with all the fields of the array inside this group.')
#DISPLAY(' Then you put the array OVER the group. If you set up your arrays in this manner,')
#DISPLAY(' then LEAVE the checkbox bellow OFF.')
#DISPLAY(''),AT(,,,1)
#DISPLAY('2) You define your arrays as actual fields using no groups whatsoever. ')
#DISPLAY(' If you set up your arrays this way, then TURN ON the checkbox bellow.')
#DISPLAY('')
#PROMPT('I DO NOT HAVE ARRAYS OVER GROUPS. ',CHECK),%optNoArrayOver,AT(10)
#ENDBOXED
#ENDTAB
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#!GROUP(%MetabaseGenerate)
#GROUP(%MetabaseGenerate,%pBaseName) #! %BaseName as a parameter
#!---------------------------------------------------------------------
#INSERT(%ReserveWordBuild) #! Reserved Words
#INSERT(%BuildQualifiedFiles) #! List of QUALIFIED tables
#INSERT(%BuildFieldsNOTNULL) #! Fields that are NOT NULL
#!---------------------------------------------------------------------
#CALL(%MetabaseTableCreate ,%pBaseName) #! TABLE create
#CALL(%MetabaseTableDropIt ,%pBaseName) #! TABLE drop
#CALL(%MetabaseSequenceCreate ,%pBaseName) #! SEQUENCE create
#CALL(%MetabaseSequenceDropIt ,%pBaseName) #! SEQUENCE drop
#CALL(%MetabaseKeyPrimaryCreate ,%pBaseName) #! KEY PRIMARY create
#CALL(%MetabaseKeyPrimaryDropIt ,%pBaseName) #! KEY PRIMARY drop
#CALL(%MetabaseIndexUniqueCreate ,%pBaseName) #! INDEX UNIQUE create
#CALL(%MetabaseIndexUniqueDropIt ,%pBaseName) #! INDEX UNIQUE drop
#CALL(%MetabaseIndexNotUniqueCreate ,%pBaseName) #! INDEX NOT UNIQUE create
#CALL(%MetabaseIndexNotUniqueDropIt ,%pBaseName) #! INDEX NOT UNIQUE drop
#CALL(%MetabaseRelationCreate ,%pBaseName) #! RELATION create
#CALL(%MetabaseRelationDropIt ,%pBaseName) #! RELATION drop
#CALL(%MetabaseGrantCreate ,%pBaseName) #! GRANT create
#CALL(%MetabaseGrantDropIt ,%pBaseName) #! GRANT drop
#!--------------------------------------------------------------------- #! RA.2019.07.28: Added calls bellow
#CALL(%MetabaseTriggerCreate ,%pBaseName) #! TRIGGER create
#CALL(%MetabaseTriggerDropIt ,%pBaseName) #! TRIGGER drop
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseTableCreate,%pBaseName) #! TABLE create
#CALL(%MetabaseTableCreatePrefix ,%pBaseName) #! TABLE create prefix
#CALL(%MetabaseTableCreateGenerate ,%pBaseName) #! TABLE create generate
#CALL(%MetabaseTableCreateSuffix ,%pBaseName) #! TABLE create suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseTableDropIt,%pBaseName) #! TABLE drop
#CALL(%MetabaseTableDropItPrefix ,%pBaseName) #! TABLE drop prefix
#CALL(%MetabaseTableDropItGenerate ,%pBaseName) #! TABLE drop generate
#CALL(%MetabaseTableDropItSuffix ,%pBaseName) #! TABLE drop suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseSequenceCreate,%pBaseName) #! SEQUENCE create
#CALL(%MetabaseSequenceCreatePrefix ,%pBaseName) #! SEQUENCE create prefix
#CALL(%MetabaseSequenceCreateGenerate ,%pBaseName) #! SEQUENCE create generate
#CALL(%MetabaseSequenceCreateSuffix ,%pBaseName) #! SEQUENCE create suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseSequenceDropIt,%pBaseName) #! SEQUENCE drop
#CALL(%MetabaseSequenceDropItPrefix ,%pBaseName) #! SEQUENCE drop prefix
#CALL(%MetabaseSequenceDropItGenerate ,%pBaseName) #! SEQUENCE drop generate
#CALL(%MetabaseSequenceDropItSuffix ,%pBaseName) #! SEQUENCE drop suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseKeyPrimaryCreate,%pBaseName) #! KEY PRIMARY create
#CALL(%MetabaseKeyPrimaryCreatePrefix ,%pBaseName) #! KEY PRIMARY create prefix
#CALL(%MetabaseKeyPrimaryCreateGenerate ,%pBaseName) #! KEY PRIMARY create generate
#CALL(%MetabaseKeyPrimaryCreateSuffix ,%pBaseName) #! KEY PRIMARY create suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseKeyPrimaryDropIt,%pBaseName) #! KEY PRIMARY drop
#CALL(%MetabaseKeyPrimaryDropItPrefix ,%pBaseName) #! KEY PRIMARY drop prefix
#CALL(%MetabaseKeyPrimaryDropItGenerate ,%pBaseName) #! KEY PRIMARY drop generate
#CALL(%MetabaseKeyPrimaryDropItSuffix ,%pBaseName) #! KEY PRIMARY drop suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseIndexUniqueCreate,%pBaseName) #! INDEX UNIQUE create
#CALL(%MetabaseIndexUniqueCreatePrefix ,%pBaseName) #! INDEX UNIQUE create prefix
#CALL(%MetabaseIndexUniqueCreateGenerate ,%pBaseName) #! INDEX UNIQUE create generate
#CALL(%MetabaseIndexUniqueCreateSuffix ,%pBaseName) #! INDEX UNIQUE create suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseIndexUniqueDropIt,%pBaseName) #! INDEX UNIQUE drop
#CALL(%MetabaseIndexUniqueDropItPrefix ,%pBaseName) #! INDEX UNIQUE drop prefix
#CALL(%MetabaseIndexUniqueDropItGenerate ,%pBaseName) #! INDEX UNIQUE drop generate
#CALL(%MetabaseIndexUniqueDropItSuffix ,%pBaseName) #! INDEX UNIQUE drop suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseIndexNotUniqueCreate,%pBaseName) #! INDEX NOT UNIQUE create
#CALL(%MetabaseIndexNotUniquePrefix ,%pBaseName) #! INDEX NOT UNIQUE create prefix
#CALL(%MetabaseIndexNotUniqueCreateGenerate ,%pBaseName) #! INDEX NOT UNIQUE create generate
#CALL(%MetabaseIndexNotUniqueSuffix ,%pBaseName) #! INDEX NOT UNIQUE create suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseIndexNotUniqueDropIt,%pBaseName) #! INDEX NOT UNIQUE drop
#CALL(%MetabaseIndexNotUniqueDropItPrefix ,%pBaseName) #! INDEX NOT UNIQUE drop prefix
#CALL(%MetabaseIndexNotUniqueDropItGenerate ,%pBaseName) #! INDEX NOT UNIQUE drop generate
#CALL(%MetabaseIndexNotUniqueDropItSuffix ,%pBaseName) #! INDEX NOT UNIQUE drop suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseRelationCreate,%pBaseName) #! RELATION create
#CALL(%MetabaseRelationCreatePrefix ,%pBaseName) #! RELATION create prefix
#CALL(%MetabaseRelationCreateGenerate ,%pBaseName) #! RELATION create generate
#CALL(%MetabaseRelationCreateSuffix ,%pBaseName) #! RELATION create suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseRelationDropIt,%pBaseName) #! RELATION drop
#CALL(%MetabaseRelationDropItPrefix ,%pBaseName) #! RELATION drop prefix
#CALL(%MetabaseRelationDropItGenerate ,%pBaseName) #! RELATION drop generate
#CALL(%MetabaseRelationDropItSuffix ,%pBaseName) #! RELATION drop suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseGrantCreate,%pBaseName) #! GRANT create
#CALL(%MetabaseGrantCreatePrefix ,%pBaseName) #! GRANT create prefix
#CALL(%MetabaseGrantCreateGenerate ,%pBaseName) #! GRANT create generate
#CALL(%MetabaseGrantCreateSuffix ,%pBaseName) #! GRANT create suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseGrantDropIt,%pBaseName) #! GRANT drop
#CALL(%MetabaseGrantDropItPrefix ,%pBaseName) #! GRANT drop prefix
#CALL(%MetabaseGrantDropItGenerate ,%pBaseName) #! GRANT drop generate
#CALL(%MetabaseGrantDropItSuffix ,%pBaseName) #! GRANT drof suffix
#!---------------------------------------------------------------------
#!--------------------------------------------------------------------- #! RA.2019.07.28: Added
#GROUP(%MetabaseTriggerCreate,%pBaseName) #! TRIGGER create
#CALL(%MetabaseTriggerCreatePrefix ,%pBaseName) #! TRIGGER create prefix
#CALL(%MetabaseTriggerCreateGenerate ,%pBaseName) #! TRIGGER create generate
#CALL(%MetabaseTriggerCreateSuffix ,%pBaseName) #! TRIGGER create suffix
#!---------------------------------------------------------------------
#!--------------------------------------------------------------------- #! RA.2019.07.28: Added
#GROUP(%MetabaseTriggerDropIt,%pBaseName) #! TRIGGER drop
#CALL(%MetabaseTriggerDropItPrefix ,%pBaseName) #! TRIGGER drop prefix
#CALL(%MetabaseTriggerDropItGenerate ,%pBaseName) #! TRIGGER drop generate
#CALL(%MetabaseTriggerDropItSuffix ,%pBaseName) #! TRIGGER drof suffix
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2017.12.17 - The commented code has been tested where you can see the outcome
#! as you are processing the DCT. Then some of the processing is moved to their final
#! locations where there might not be any output file open yet to show the testing
#! as we processing.
#!---------------------------------------------------------------------
#! For example: The qualified files were tested here. After testing they were moved
#! to an earlier moment to process as the qualified files can be used by all the items
#! that generate. But not all the options may generate trace output.
#!---------------------------------------------------------------------
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseTableCreateGenerate,%pBaseName) #! TABLE create generate
#!-- [GENERATE TABLE CREATE]
#!INSERT(%ShowFiles) #! Simple table show (TESTING)
#!--INSERT(%ReserveWordBuild) #! Reserved Words
#!--INSERT(%BuildQualifiedFiles) #! List of QUALIFIED tables
#!--#INSERT(%BuildFieldsNOTNULL) #! Fields that are NOT NULL
#INSERT(%ProcessTableCreate ,%pBaseName) #! RA.2017.12.19: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseTableDropItGenerate,%pBaseName) #! TABLE drop generate
#!-- [GENERATE TABLE DROP]
#INSERT(%ProcessTableDropIt ,%pBaseName) #! RA.2017.12.19: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseSequenceCreateGenerate,%pBaseName) #! SEQUENCE create generate
#!-- [GENERATE SEQUENCE CREATE]
#INSERT(%ProcessSequenceCreate ,%pBaseName) #! RA.2017.12.21: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseSequenceDropItGenerate,%pBaseName) #! SEQUENCE drop generate
#!-- [GENERATE SEQUENCE DROP]
#INSERT(%ProcessSequenceDropIt ,%pBaseName) #! RA.2017.12.21: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseKeyPrimaryCreateGenerate,%pBaseName) #! KEY PRIMARY create generateN
#!-- [GENERATE KEY PRIMARY CREATE]
#INSERT(%ProcessPrimaryCreate ,%pBaseName) #! RA.2017.12.23: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseKeyPrimaryDropItGenerate,%pBaseName) #! KEY PRIMARY drop generate
#!-- [GENERATE KEY PRIMARY DROP]
#INSERT(%ProcessPrimaryDropIt ,%pBaseName) #! RA.2017.12.23: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseIndexUniqueCreateGenerate,%pBaseName) #! INDEX UNIQUE create generate
#!-- [GENERATE INDEX UNIQUE CREATE]
#INSERT(%ProcessIndexUniqueCreate ,%pBaseName) #! RA.2017.12.26: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseIndexUniqueDropItGenerate,%pBaseName) #! INDEX UNIQUE drop generate
#!-- [GENERATE INDEX UNIQUE DROP]
#INSERT(%ProcessIndexUniqueDropIt ,%pBaseName) #! RA.2017.12.26: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseIndexNotUniqueCreateGenerate,%pBaseName) #! INDEX NOT UNIQUE create generate
#!-- [GENERATE INDEX NOT UNIQUE CREATE]
#INSERT(%ProcessIndexNonUniqueCreate ,%pBaseName) #! RA.2018.01.12: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseIndexNotUniqueDropItGenerate,%pBaseName) #! INDEX NOT UNIQUE drop generate
#!-- [GENERATE INDEX NOT UNIQUE DROP]
#INSERT(%ProcessIndexNonUniqueDropIt ,%pBaseName) #! RA.2018.01.12: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseRelationCreateGenerate,%pBaseName) #! RELATION create generate
#!-- [GENERATE RELATION CREATE]
#INSERT(%ProcessRelationCreate ,%pBaseName) #! RA.2018.02.25: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseRelationDropItGenerate,%pBaseName) #! RELATION drop generate
#!-- [GENERATE RELATION DROP]
#INSERT(%ProcessRelationDropIt ,%pBaseName) #! RA.2018.02.25: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseGrantCreateGenerate,%pBaseName) #! GRANT create generate
#!-- [GENERATE GRANT CREATE]
#INSERT(%ProcessGrantCreate ,%pBaseName) #! RA.2018.02.25: Tested
#!
#! RA.2018.04.07 - Pass %BaseName as a parameter
#GROUP(%MetabaseGrantDropItGenerate,%pBaseName) #! GRANT drop generate
#!-- [GENERATE GRANT DROP]
#INSERT(%ProcessGrantDropIt ,%pBaseName) #! RA.2018.02.25: Tested
#!
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#GROUP(%DefineAreasOptions) #! File,Field,Keys,Relations
#INSERT(%DefineFileOptions) #! File Options
#INSERT(%DefineFieldOptions) #! Field Options
#INSERT(%DefineKeyOptions) #! Key Options
#INSERT(%DefineRelationOptions) #! Relation Options
#!---------------------------------------------------------------------
#GROUP(%DefineFileOptions)
#!DECLARE(%NFilesSort),MULTI,UNIQUE #! RA.2019.07.04: Define a bit earlier
#DECLARE(%CountNFiles)
#DECLARE(%NFiles),MULTI #!,UNIQUE
#DECLARE(%NFilesCount ,%NFiles) #! ID: Table Count
#DECLARE(%NFilesName ,%NFiles) #! Table Name
#DECLARE(%NFilesDatabase ,%NFiles) #! Table Database #! RA.2020.06.18: (Earlier part of the name)
#DECLARE(%NFilesOwner ,%NFiles) #! Table Owner #! RA.2020.06.18: (Prefix|Schema part of the name)
#DECLARE(%NFilesSeqWhere ,%NFiles) #! Table Sequence Location #! RA.2020.06.18: Sequence Location
#DECLARE(%NFilesSeqName ,%NFiles) #! Table Sequence Name
#DECLARE(%NFilesSeqField ,%NFiles) #! Table Sequence Field
#DECLARE(%NFilesPKeyName ,%NFiles) #! Table Primary Key Name
#DECLARE(%NFilesPKeyField ,%NFiles) #! Table Primary Field Name
#DECLARE(%NFilesFullPath ,%NFiles) #! Table Full Path Name
#! RA.2019.07.06: Additional GUID items to verify per file
#DECLARE(%NFilesKeyCount ,%NFiles) #! Table Count Keys
#DECLARE(%NFilesKeyPrimary ,%NFiles) #! Table Count Primary Keys
#DECLARE(%NFilesFieldCount ,%NFiles) #! Table Count Fields
#DECLARE(%NFilesCountGUID ,%NFiles) #! Table Count GUID
#DECLARE(%NFilesCountTS ,%NFiles) #! Table Count TS
#DECLARE(%NFilesCountSTS ,%NFiles) #! Table Count STS
#DECLARE(%NFilesCountDTS ,%NFiles) #! Table Count DTS
#DECLARE(%NFilesOptionGUID ,%NFiles) #! Table Option GUID
#DECLARE(%NFilesOptionTS ,%NFiles) #! Table Option TS
#DECLARE(%NFilesOptionSTS ,%NFiles) #! Table Option STS
#DECLARE(%NFilesOptionDTS ,%NFiles) #! Table Option DTS
#! RA.2019.07.26: Verify more GUID items per file
#DECLARE(%NFilesKeyGUID ,%NFiles) #! Key for GUID
#DECLARE(%NFilesKeyTS ,%NFiles) #! Key for TS
#DECLARE(%NFilesKeySTS ,%NFiles) #! Key for STS
#DECLARE(%NFilesKeyDTS ,%NFiles) #! Key for DTS
#DECLARE(%NFilesFieldGUID ,%NFiles) #! Key-Field for GUID
#DECLARE(%NFilesFieldTS ,%NFiles) #! Key-Field for TS
#DECLARE(%NFilesFieldSTS ,%NFiles) #! Key-Field for STS
#DECLARE(%NFilesFieldDTS ,%NFiles) #! Key-Field for DTS
#! RA.2019.11.20: Added the EncryptionVersion logic to the template.
#DECLARE(%NFilesCountEncrypt ,%NFiles) #! Table Count EncryptionVersion
#DECLARE(%NFilesOptionEncrypt ,%NFiles) #! Table Option EncryptionVersion (Not used)
#!
#INSERT(%VarOptFile) #! RA.2019.07.28: Options: File
#!
#DECLARE(%TheTable) #! Reserved word change
#DECLARE(%TheTable2) #! Reserved word change (related tables) - RA.2018.06.03.SUN: Added
#!---------------------------------------------------------------------
#GROUP(%DefineFieldOptions)
#DECLARE(%CountNFields)
#DECLARE(%NFields),MULTI #!,UNIQUE
#DECLARE(%NFieldsCount ,%NFields) #! ID: Field Count
#DECLARE(%NFieldsKey ,%NFields) #! Clarion: Prefix:FieldName
#DECLARE(%NFieldsName ,%NFields) #! Clarion: Field Name
#DECLARE(%NFieldsType ,%NFields) #! Clarion: Field Type
#DECLARE(%NFieldsFormat ,%NFields) #! Clarion: Display Format
#DECLARE(%NFieldsDatLen ,%NFields) #! Clarion: Data Length - RA.2018.04.15: Added
#DECLARE(%NFieldsDatDec ,%NFields) #! Clarion: Data Decimals - RA.2018.04.15: Added
#DECLARE(%NFieldsDspLen ,%NFields) #! Clarion: Display Length - RA.2018.04.15: Added
#DECLARE(%NFieldsDspDec ,%NFields) #! Clarion: Display Decimals - RA.2018.04.15: Added
#DECLARE(%NFieldsOpts ,%NFields) #! Clarion: %FieldUserOptions - RA.2019.04.30: Added
#DECLARE(%NFieldsNSql ,%NFields) #! SQL: Name
#DECLARE(%NFieldsTSql ,%NFields) #! SQL: Type
#DECLARE(%NFieldsDef ,%NFields) #! SQL: Default
#DECLARE(%NFieldsAuto ,%NFields) #! SQL: AUTO_INCREMENT
#DECLARE(%NFieldsNN ,%NFields) #! SQL: NOT NULL
#!
#DECLARE(%CountAFields)
#DECLARE(%AFields),MULTI #!,UNIQUE
#DECLARE(%AFieldsCount ,%AFields) #! ID: Field Count
#DECLARE(%AFieldsKey ,%AFields) #! Clarion: Prefix:FieldName
#DECLARE(%AFieldsName ,%AFields) #! Clarion: Field Name
#DECLARE(%AFieldsType ,%AFields) #! Clarion: Field Type
#DECLARE(%AFieldsFormat ,%AFields) #! Clarion: Display Format
#DECLARE(%AFieldsDatLen ,%AFields) #! Clarion: Data Length - RA.2018.04.15: Added
#DECLARE(%AFieldsDatDec ,%AFields) #! Clarion: Data Decimals - RA.2018.04.15: Added
#DECLARE(%AFieldsDspLen ,%AFields) #! Clarion: Display Length - RA.2018.04.15: Added
#DECLARE(%AFieldsDspDec ,%AFields) #! Clarion: Display Decimals - RA.2018.04.15: Added
#DECLARE(%AFieldsOpts ,%AFields) #! Clarion: %FieldUserOptions - RA.2019.04.30: Added
#DECLARE(%AFieldsNSql ,%AFields) #! SQL: Name
#DECLARE(%AFieldsTSql ,%AFields) #! SQL: Type
#DECLARE(%AFieldsDef ,%AFields) #! SQL: Default
#DECLARE(%AFieldsAuto ,%AFields) #! SQL: AUTO_INCREMENT
#DECLARE(%AFieldsNN ,%AFields) #! SQL: NOT NULL
#!
#DECLARE(%NFieldsNOTNULL),MULTI,UNIQUE #! Fields: KEY, INDEX
#DECLARE(%IFieldInKey)
#!
#! RA.2018.04.23: Track the auto increment fields for specific backends.
#DECLARE(%NFieldsAUTOINC),MULTI,UNIQUE #! Fields: Auto-Increment
#DECLARE(%IFieldAutoInc)
#!
#! RA.2018.04.23: Track the primary keys to NOT-NULL them at create
#DECLARE(%NFieldsPRIMARY),MULTI,UNIQUE #! Fields: Primary
#DECLARE(%IFieldPrimary)
#!
#INSERT(%VarOptField) #! RA.2019.07.28: Options: Field
#!
#DECLARE(%TheField) #! Reserved word change
#DECLARE(%CStringLen) #! Length of types shortened by one
#DECLARE(%LastField) #! Last field processed
#DECLARE(%InnerGroup) #! Inner group level processed
#DECLARE(%FieldComma) #! Number of fields - 1
#!
#DECLARE(%TestLenDec)
#DECLARE(%MoreLenDec)
#!
#DECLARE(%NFieldPKey) #! Field is Primary Key?
#DECLARE(%NFieldName) #! Field Name
#DECLARE(%NFieldType) #! Field Type
#DECLARE(%NFieldNSql) #! Field SQL Name
#DECLARE(%NFieldTSql) #! Field SQL Type
#DECLARE(%NFieldAuto) #! Field AUTO_INCREMENT
#DECLARE(%NFieldNN) #! Field NOT NULL
#DECLARE(%NFieldDef) #! Field default
#DECLARE(%NFieldLineCount) #! Count DDL line fields
#DECLARE(%NFieldLine) #! Output DDL line
#DECLARE(%NFieldLine1) #! Line piece
#DECLARE(%NFieldSize ,LONG) #! Field decimal size
#DECLARE(%NFieldDec ,LONG) #! Field decimal places
#DECLARE(%NLeadZero ,LONG) #! Have a leading zero
#DECLARE(%NFNameAuto) #! Field Name Auto Increment
#!
#DECLARE (%DimCount ,LONG) #! Number of dimensions
#DECLARE (%FldArray ,STRING) #! Created field name from array
#DECLARE (%FD1S ,STRING) #! Number for dimension 1
#DECLARE (%FD2S ,STRING) #! Number for dimension 2
#DECLARE (%FD3S ,STRING) #! Number for dimension 3
#DECLARE (%FD4S ,STRING) #! Number for dimension 4
#DECLARE (%FD1I ,LONG) #! Looping in Dimension 1
#DECLARE (%FD2I ,LONG) #! Looping in Dimension 2
#DECLARE (%FD3I ,LONG) #! Looping in Dimension 3
#DECLARE (%FD4I ,LONG) #! Looping in Dimension 4
#DECLARE (%FD1L ,LONG) #! Set to %FieldDimension1
#DECLARE (%FD2L ,LONG) #! Set to %FieldDimension2
#DECLARE (%FD3L ,LONG) #! Set to %FieldDimension3
#DECLARE (%FD4L ,LONG) #! Set to %fieldDimension4
#!---------------------------------------------------------------------
#GROUP(%DefineKeyOptions)
#DECLARE(%CountNKeys)
#DECLARE(%NKeys),MULTI #!,UNIQUE
#DECLARE(%NKeysCount ,%NKeys) #! ID: Key Count
#DECLARE(%NKeysKey ,%NKeys) #! Prefix:KeyName
#DECLARE(%NKeysName ,%NKeys) #! Key Name
#DECLARE(%NKeysType ,%NKeys) #! Key Type
#DECLARE(%NKeysFlagPri ,%NKeys) #! Key is: Primary
#DECLARE(%NKeysFlagSeq ,%NKeys) #! Key is: Sequence
#DECLARE(%NKeysFlagUni ,%NKeys) #! Key is: Unique
#DECLARE(%NkeysAutoField ,%NKeys) #! Auto-Inc Field Name
#DECLARE(%NKeysFieldCount ,%NKeys) #! Number of Fields
#DECLARE(%NKeysField01 ,%NKeys) #! Field 01
#DECLARE(%NKeysField02 ,%NKeys) #! Field 02
#DECLARE(%NKeysField03 ,%NKeys) #! Field 03
#DECLARE(%NKeysField04 ,%NKeys) #! Field 04
#DECLARE(%NKeysField05 ,%NKeys) #! Field 05
#DECLARE(%NKeysField06 ,%NKeys) #! Field 06
#DECLARE(%NKeysField07 ,%NKeys) #! Field 07
#DECLARE(%NKeysField08 ,%NKeys) #! Field 08
#DECLARE(%NKeysField09 ,%NKeys) #! Field 09
#DECLARE(%NKeysSort01 ,%NKeys) #! Sort Order 01
#DECLARE(%NKeysSort02 ,%NKeys) #! Sort Order 02
#DECLARE(%NKeysSort03 ,%NKeys) #! Sort Order 03
#DECLARE(%NKeysSort04 ,%NKeys) #! Sort Order 04
#DECLARE(%NKeysSort05 ,%NKeys) #! Sort Order 05
#DECLARE(%NKeysSort06 ,%NKeys) #! Sort Order 06
#DECLARE(%NKeysSort07 ,%NKeys) #! Sort Order 07
#DECLARE(%NKeysSort08 ,%NKeys) #! Sort Order 08
#DECLARE(%NKeysSort09 ,%NKeys) #! Sort Order 09
#!
#INSERT(%VarOptKey) #! RA.2019.07.28: Options: Key
#!
#DECLARE(%TheKey) #! Reserved word change
#DECLARE(%NKeyCount) #! File key counts
#DECLARE(%NKeyPrimary) #! File primary key counts
#DECLARE(%NKeyPrimaryValidSeq) #! Valid sequence is a number
#DECLARE(%NKeyFieldIndex) #! Set field array into table
#DECLARE(%NKeyDidIndex) #! Have created an Index
#DECLARE(%NKeyComma) #! How many commas do I need?
#DECLARE(%NKeyFieldAD) #! Key Field A/D line
#DECLARE(%NKeyFieldID) #! Key Field ID Name
#DECLARE(%NKeySortOrder) #! Key Field ASC/DESC sort order
#!---------------------------------------------------------------------
#GROUP(%DefineRelationOptions)
#DECLARE(%CountNRelations)
#DECLARE(%NRelas),MULTI #!,UNIQUE
#DECLARE(%NRelasCount ,%NRelas) #! ID: Relation Count
#DECLARE(%NRelasFileFromKey ,%NRelas) #! File From: Prefix:Name
#DECLARE(%NRelasFileLinkKey ,%NRelas) #! File Link: Prefix:Name
#DECLARE(%NRelasKeyFromKey ,%NRelas) #! Key From: Prefix:Name
#DECLARE(%NRelasKeyLinkKey ,%NRelas) #! Key Link: Prefix:Name
#DECLARE(%NRelasType ,%NRelas) #! Relation Type
#DECLARE(%NRelasFileFrom ,%NRelas) #! Relation File: Main from
#DECLARE(%NRelasFileLink ,%NRelas) #! Relation File: Relate to
#DECLARE(%NRelasKeyFrom ,%NRelas) #! Relation Key: Main from
#DECLARE(%NRelasKeyLink ,%NRelas) #! Relation Key: Relate to
#DECLARE(%NRelasOnUpdate ,%NRelas) #! ON UPDATE: What to do?
#DECLARE(%NRelasOnDelete ,%NRelas) #! ON DELETE: What to do?
#DECLARE(%NRelasKeyFromCount ,%NRelas) #! Key From: Field Count
#DECLARE(%NRelasKFfield01 ,%NRelas) #! Key From: Field 01
#DECLARE(%NRelasKFfield02 ,%NRelas) #! Key From: Field 02
#DECLARE(%NRelasKFfield03 ,%NRelas) #! Key From: Field 03
#DECLARE(%NRelasKFfield04 ,%NRelas) #! Key From: Field 04
#DECLARE(%NRelasKFfield05 ,%NRelas) #! Key From: Field 05
#DECLARE(%NRelasKFfield06 ,%NRelas) #! Key From: Field 06
#DECLARE(%NRelasKFfield07 ,%NRelas) #! Key From: Field 07
#DECLARE(%NRelasKFfield08 ,%NRelas) #! Key From: Field 08
#DECLARE(%NRelasKFfield09 ,%NRelas) #! Key From: Field 09
#DECLARE(%NRelasKFlabel01 ,%NRelas) #! Key From: Label 01
#DECLARE(%NRelasKFlabel02 ,%NRelas) #! Key From: Label 02
#DECLARE(%NRelasKFlabel03 ,%NRelas) #! Key From: Label 03
#DECLARE(%NRelasKFlabel04 ,%NRelas) #! Key From: Label 04
#DECLARE(%NRelasKFlabel05 ,%NRelas) #! Key From: Label 05
#DECLARE(%NRelasKFlabel06 ,%NRelas) #! Key From: Label 06
#DECLARE(%NRelasKFlabel07 ,%NRelas) #! Key From: Label 07
#DECLARE(%NRelasKFlabel08 ,%NRelas) #! Key From: Label 08
#DECLARE(%NRelasKFlabel09 ,%NRelas) #! Key From: Label 09
#DECLARE(%NRelasKeyLinkCount ,%NRelas) #! Key Link: Field Count
#DECLARE(%NRelasKLfield01 ,%NRelas) #! Key Link: Field 01
#DECLARE(%NRelasKLfield02 ,%NRelas) #! Key Link: Field 02
#DECLARE(%NRelasKLfield03 ,%NRelas) #! Key Link: Field 03
#DECLARE(%NRelasKLfield04 ,%NRelas) #! Key Link: Field 04
#DECLARE(%NRelasKLfield05 ,%NRelas) #! Key Link: Field 05
#DECLARE(%NRelasKLfield06 ,%NRelas) #! Key Link: Field 06
#DECLARE(%NRelasKLfield07 ,%NRelas) #! Key Link: Field 07
#DECLARE(%NRelasKLfield08 ,%NRelas) #! Key Link: Field 08
#DECLARE(%NRelasKLfield09 ,%NRelas) #! Key Link: Field 09
#DECLARE(%NRelasKLlabel01 ,%NRelas) #! Key Link: Label 01
#DECLARE(%NRelasKLlabel02 ,%NRelas) #! Key Link: Label 02
#DECLARE(%NRelasKLlabel03 ,%NRelas) #! Key Link: Label 03
#DECLARE(%NRelasKLlabel04 ,%NRelas) #! Key Link: Label 04
#DECLARE(%NRelasKLlabel05 ,%NRelas) #! Key Link: Label 05
#DECLARE(%NRelasKLlabel06 ,%NRelas) #! Key Link: Label 06
#DECLARE(%NRelasKLlabel07 ,%NRelas) #! Key Link: Label 07
#DECLARE(%NRelasKLlabel08 ,%NRelas) #! Key Link: Label 08
#DECLARE(%NRelasKLlabel09 ,%NRelas) #! Key Link: Label 09
#!
#INSERT(%VarOptRelation) #! RA.2019.07.28: Options: Relation
#!
#DECLARE(%TheRelation) #! Reserved word change
#DECLARE(%NRelaFound) #! Found a relation to process
#DECLARE(%NRelaFieldIndex) #! Set field array into table
#DECLARE(%NRelaDidRelation) #! Have created an Index
#DECLARE(%NRelaFieldsParent) #! Relation field list for Parent table
#DECLARE(%NRelaFieldsChild) #! Relation field list for Child table
#DECLARE(%NRelaRestrict) #! Change RESTRICT_SERVER to RESTRICT
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2017.12.05 - Show the files to make sure the get presented correctly
#GROUP(%ShowFiles)
#FREE(%NFiles)
#FOR(%File)
#!----------------------------------!
#! Ignore certain file DRIVER types !
#!----------------------------------!
#CASE(%FileDriver)
#OF('ASCII')
#OROF('BASIC')
#OROF('DOS')
#OROF('MEMORY') #! RA.2018.04.12 - Ignored
---- IGNORED: "%File" [DRIVER type %FileDriver]
#CYCLE
#ENDCASE
#!---------------------------!
#! Ignore certain FILE types !
#!---------------------------!
#CASE(%FileType)
#OF ('VIEW')
#OROF('ALIAS')
---- IGNORED: "%File" [FILE type %FileType]
#CYCLE
#ENDCASE
#!-------------------------------------!
#! Ignore FILES with NO FIELDS in them !
#!-------------------------------------!
#IF(NOT ITEMS(%Field)) #! RA.2001.12.01
---- IGNORED: "%File" [No fields found]
#CYCLE #! RA.2001.12.01
#ENDIF #! RA.2001.12.01
#!-----------------------!
#! Check the OPTIONS now !
#!-----------------------!
#INSERT(%GetFileOptions)
#!-------------------------------------------------------------!
#! The first option RASQL(NO) controls if a file is processed. !
#!-------------------------------------------------------------!
#IF(SUB(%NFileOpt1,1,1)='N') #! Ignore this file
---- IGNORED: "%File" [FILE options say NO]
#CYCLE
#ENDIF
#!---------------------------!
#! We pass FILE requirements !
#!---------------------------!
#!#ADD(%NFiles,%File) #! This FILE is processed
#! RA.2017.12.05 - Changes to track and output CSV files
#ADD(%NFiles,ITEMS(%NFiles) + 1) #! This FILE is processed
#SET(%NFilesCount , ITEMS(%NFiles)) #! Table ID number
#SET(%NFilesName , %File) #! Table Name
#!
#!--------------------------------------------------------------------------------!
#! RA.2020.06.18: Sequences need to be in the same schema in which they are used. !
#!--------------------------------------------------------------------------------!
#SET (%NFilesDatabase, %NameDatabase) #! RA.2020.06.18: From TPL options
#SET (%NFilesOwner , %NameOwner) #! RA.2020.06.18: From TPL options
#SET (%NFilesSeqName , %NFilesName & '_seq') #! Table Sequence Name - RA.2017.12.21
#CALL(%DoPrefixToName,%NFilesSeqName,%FilePrefix,%NFilesSeqName,'_',%optPrefixAllNames) #! RA.2020.07.11: Add table prefix
#!CALL(%QuoteThisThing,%NFilesSeqName,%NFilesSeqName,%pBaseName,%optQuoteAllThings) #! RA.2020.06.18: Add quotes
#SET (%NFilesSeqWhere, %NFilesOwner & '.' & %NFilesSeqName) #! RA.2020.06.18: Sequence Location
#CALL(%QuoteThisThing,%NFilesSeqWhere,%NFilesSeqWhere,%pBaseName,%optQuoteAllThings) #! RA.2020.06.18: Add quotes
#CALL(%MakeSingleCase,%NFilesSeqWhere,%NFilesSeqWhere,%optLowerCaseAllThings) #! RA.2020.07.03: Make lower case
#!
#CALL(%HasOnePrimaryKey) #! At least ONE primary key
#!
#ENDFOR
#!
#IF(%TRUE)
#FOR(%NFiles)
#FIX(%File, %NFilesName)
---- PROCESSING: %[3]NFilesCount %[90]NFilesName [%FilePrefix]
#ENDFOR
#ENDIF
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! BUILD QUALIFIED FILES
#!---------------------------------------------------------------------
#!---------------------------------------------------------------------
#! RA.2019.08.04: We need to filter these before presenting for selections. [This is done in D2M2_003.TPW]
#! FOR NOW: We are going copy the filter code and take other code out later. [In the #GROUP(%VariablesSetup)]
#! After you start adding aliases and vendor tools/utilities it gets messy.
#! FILTER CODE IS A CANDIDATE FOR IT'S OWN GROUP: CHECK FOR REFACTOR OPTIONS!
#! RA.2019.07.04: Added option to select files to do SQL generation.
#! RA.2017.12.17: This builds a table of QUALIFIED files that can be used
#! by all the different GROUPS that generate DDL scripts or CSV files.
#GROUP(%BuildQualifiedFiles)
#FREE(%NFilesSort) #! Name order for files
#!
#!#FOR(%File) #! Read all the files
#! #ADD(%NFilesSort,%File) #! Name sort them by
#!#ENDFOR #! processing them all
#!