forked from RobertArtigas/DCT2SQL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
D2_99_SQLSCR.TPW
572 lines (566 loc) · 17.6 KB
/
D2_99_SQLSCR.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
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
#!----------------------------------------------------------------------------------------
#!TEMPLATE(SMSSQL,'MS-SQL Templates Afiq Systems Ltd.'),FAMILY('ABC')
#!----------------------------------------------------------------------------------------
#! Vadim Berman (c) 1999 Vadim Berman Ltd.
#! http://www.power10.co.il
#! mailto:[email protected]
#!
#! Version 2
#!
#UTILITY(SaveDICasSQL, '2002.11.14: Generate MSSQL or Oracle conversion / creation script')
#DISPLAY('Generate MSSQL conversion / creation script')
#DISPLAY('1999 (c) by Vadim Berman')
#DISPLAY('')
#PROMPT('Backend ',OPTION),%BackendDriver,DEFAULT('MSSQL')
#PROMPT('MS SQL Server',RADIO),VALUE('MSSQL')
#PROMPT('Oracle',RADIO),VALUE('Oracle')
#PROMPT('Script Type',OPTION),%ScriptType,DEFAULT(2)
#PROMPT('Creation only script',RADIO),VALUE(1)
#PROMPT('Conversion and creation script',RADIO),VALUE(2)
#PROMPT('Save as: ',SAVEDIALOG('Save as file','SQL Script (*.sql)|*.sql')),%OutputFile,default(SUB(%DictionaryFile,1,LEN(%DictionaryFile)-4) & '.sql')
#PROMPT('Include script from: ',OPENDIALOG('Included script','SQL Script (*.sql)|*.sql')),%IncludedScript,default(SUB(%DictionaryFile,1,LEN(%DictionaryFile)-4) & 'con.sql')
#PROMPT('Load list from file: ',OPENDIALOG('Load definitions from file','All files (*.*)|*.*')),%LoadFromFile,DEFAULT('')
#PROMPT('Create all Tables',Check),%AllTables,default(1)
#PROMPT('Create relations',Check),%CreateRelation,default(0)
#ENABLE(%LoadFromFile = '')
#PROMPT('Drop Table',CHECK),%DropTable,DEFAULT(0)
#BUTTON ('Script only for Tables...'), MULTI(%InclTables, %InclTable)
#PROMPT ('Table :', FROM(%File)), %InclTable,REQ
#ENDBUTTON
#ENDENABLE
#PROMPT('Autoincrementing fields',@s35),%UnqID,DEFAULT('UnqID')
#PROMPT('Warnings in the script',CHECK),%VerboseMode,DEFAULT(1)
#!
#DECLARE(%FldList)
#DECLARE(%AlterMode)
#DECLARE(%TPrefix)
#DECLARE(%TGenFldList)
#DECLARE(%TFileName)
#DECLARE(%NFieldType)
#DECLARE(%NFieldName)
#DECLARE(%NFieldDefault)
#DECLARE(%NKeyName)
#DECLARE(%NKeyFields)
#DECLARE(%NKeyField)
#DECLARE(%NAdditAttrib)
#DECLARE(%NKeyFieldCount)
#DECLARE(%TableCount)
#DECLARE(%KeyCount)
#DECLARE(%FieldCount)
#DECLARE(%PKeyCount)
#DECLARE(%OptComma)
#DECLARE(%NRelateFile)
#DECLARE(%Relationfield1)
#DECLARE(%Relationfield2)
#DECLARE(%CStringLen)
#DECLARE(%LastField)
#DECLARE(%InnerGroup)
#DECLARE(%EndLblPos)
#DECLARE(%IDSymbol)
#!
#CASE(%BackendDriver)
#OF('MSSQL')
#SET(%IDSymbol,'"')
#OF('Oracle')
#SET(%IDSymbol,'')
#ENDCASE
#!
#CREATE(%OutputFile)
#!
#IF(%ScriptType = 1)
#MESSAGE('Generating creation script',0)
#ELSE
#MESSAGE('Generating creation / conversion script',0)
#ENDIF
#!
#MESSAGE(%OutputFile,1)
#!
#CASE(%BackendDriver)
#OF('MSSQL')
SET QUOTED_IDENTIFIER ON
-- saving triggers
if not exists(SELECT name
FROM sysobjects
WHERE name = N'triggersav')
create table triggersav
(contents nvarchar(4000))
insert into triggersav
select syscomments.text
from syscomments,sysobjects
where syscomments.id = OBJECT_ID(sysobjects.name) and sysobjects.type = 'TR'
#OF('Oracle')
#ENDCASE
#IF(%LoadFromFile)
#OPEN(%LoadFromFile),READ
#DECLARE(%ListFileRecord)
#LOOP
#READ(%ListFileRecord)
#IF(%ListFileRecord = %EOF)
#BREAK
#ENDIF
#SET(%EndLblPos,INSTRING(' ',%ListFileRecord,1,1))
#IF(%EndLblPos < 1)
#SET(%EndLblPos,LEN(%ListFileRecord))
#ELSE
#SET(%EndLblPos,%EndLblPos - 1)
#ENDIF
#FIX(%File,SLICE(%ListFileRecord,1,%EndLblPos))
#IF(%File = '') #! Just dump it as comments
/* %ListFileRecord */
#CYCLE
#ENDIF
#IF(INSTRING('DROP',UPPER(%ListFileRecord),1,1) < 1)
#SET(%DropTable,0)
#ELSE
#SET(%DropTable,1)
#ENDIF
#INSERT(%ScriptPerFile)
#END
#CLOSE(%LoadFromFile),READ
#ELSE
#FOR( %File )
#INSERT(%ScriptPerFile)
#ENDFOR
#ENDIF
#!
#CASE(%BackendDriver)
#OF('MSSQL')
-- restoring triggers
DECLARE triggerList CURSOR FOR
SELECT contents
FROM triggersav
declare @createQuery nvarchar(4000)
OPEN triggerList
FETCH NEXT FROM triggerList INTO @createQuery
WHILE @@FETCH_STATUS <> -1
BEGIN
EXEC(@createQuery)
FETCH NEXT FROM triggerList INTO @createQuery
END
DEALLOCATE triggerList
drop table triggersav
#ENDCASE
#IF(%IncludedScript <> '')
/* included from %IncludedScript */
#OPEN(%IncludedScript),READ
#DECLARE(%IncludedScriptRecord)
#LOOP
#READ(%IncludedScriptRecord)
#IF(%IncludedScriptRecord = %EOF)
#BREAK
#ENDIF
%IncludedScriptRecord
#ENDLOOP
#CLOSE(%IncludedScript),READ
/* end included from %IncludedScript */
#ENDIF
/* Tables : %TableCount */
/* Primary Keys : %PKeyCount */
/* Keys : %KeyCount */
/* Fields : %FieldCount */
#CLOSE
#RUN('NOTEPAD.EXE "' & %OutputFile & '"')
#!---------------------------------------------
#!---------------------------------------------
#GROUP(%FileDeclaration)
#SET(%TGenFldList,'')
#FOR(%Field)
#! Beny
#IF(%FieldName)
#SET(%NFieldName,SLICE(%FieldName,2,LEN(%FieldName)-1))
#ELSE
#SET(%NFieldName,%FieldID)
#IF(%NFieldName AND %VerboseMode AND %FieldType <> 'GROUP' AND %FieldType <> 'END')
/* warning: using Clarion internal name */
#END
#ENDIF
#SET(%NAdditAttrib,'')
#!#IF(%FieldValidation = 'NONZERO') #! we'll use it anyway so on insert it will insert 0's
#IF(%BackendDriver = 'MSSQL')
#SET(%NAdditAttrib,%NAdditAttrib & ' NOT NULL')
#ENDIF
#!#ENDIF
#IF((UPPER(%FieldID) = UPPER(%UnqID) OR INSTRING(UPPER(%UnqID),UPPER(%FieldUserOptions),1,1) > 0) AND (%UnqID <> ''))
#SET(%TGenFldList,'1')
#IF(%BackendDriver = 'MSSQL')
#SET(%NAdditAttrib,%NAdditAttrib & ' IDENTITY(1,1)')
#ENDIF
#ENDIF
#IF(%FieldType = 'STRING' AND %FieldMemoSize = 8)
#SET(%LastField, %Field)
#CYCLE
#ENDIF
#IF(%FieldType='GROUP')
#SET(%InnerGroup,1)
#IF(INSTRING('OVER(',%FieldStatement,1,1))
%IDSymbol%LastField%IDSymbol DATETIME,
#SET(%FieldCount, %FieldCount + 1)
#ENDIF
#CYCLE
#ENDIF
#IF(%FieldType='END')
#SET(%InnerGroup,0)
#CYCLE
#ENDIF
#IF(%InnerGroup = 1)
#!#CYCLE
#ENDIF
#SET(%FieldCount, %FieldCount + 1)
#SET(%NFieldDefault,'')
#CASE(%FieldType)
#OF('SHORT')
#SET(%NFieldType,'SMALLINT')
#SET(%NFieldDefault,' DEFAULT 0')
#OF('USHORT')
#SET(%NFieldType,'SMALLINT')
#SET(%NFieldDefault,' DEFAULT 0')
#OF('ULONG')
#SET(%NFieldType,'INT')
#SET(%NFieldDefault,' DEFAULT 0')
#OF('LONG')
#SET(%NFieldType,'INT')
#SET(%NFieldDefault,' DEFAULT 0')
#OF('REAL')
#SET(%NFieldType,'FLOAT')
#SET(%NFieldDefault,' DEFAULT 0')
#OF('STRING')
#IF (%FieldMemoSize > 8000) #! which is VARCHAR limit, according to M$
#CASE(%BackendDriver)
#OF('MSSQL')
#SET(%NFieldType,'TEXT' )
#OF('Oracle')
#SET(%NFieldType,'LONG' ) #! pay attention: NOT long integer
#ENDCASE
#ELSIF (%FieldMemoSize > 250)
#CASE(%BackendDriver)
#OF('MSSQL')
#SET(%NFieldType,'VARCHAR(' & %FieldMemoSize & ')' )
#OF('Oracle')
#SET(%NFieldType,'VARCHAR2(' & %FieldMemoSize & ')' )
#ENDCASE
#SET(%NFieldDefault,' DEFAULT ''''')
#ELSE
#SET(%NFieldType,'CHAR(' & %FieldMemoSize & ')' )
#SET(%NFieldDefault,' DEFAULT ''''')
#ENDIF
#OF('CSTRING')
#SET(%CStringLen,%FieldMemoSize - 1)
#IF (%CStringLen > 8000) #! which is VARCHAR limit, according to M$
#CASE(%BackendDriver)
#OF('MSSQL')
#SET(%NFieldType,'TEXT' )
#OF('Oracle')
#SET(%NFieldType,'LONG' ) #! pay attention: NOT long integer
#ENDCASE
#ELSE
#CASE(%BackendDriver)
#OF('MSSQL')
#SET(%NFieldType,'VARCHAR(' & %CStringLen & ')' )
#OF('Oracle')
#SET(%NFieldType,'VARCHAR2(' & %CStringLen & ')' )
#ENDCASE
#ENDIF
#SET(%NFieldDefault,' DEFAULT ''''')
#OF('BYTE')
#CASE(%BackendDriver)
#OF('MSSQL')
#SET(%NFieldType,'TINYINT')
#OF('Oracle')
#SET(%NFieldType,'SMALLINT')
#ENDCASE
#SET(%NFieldDefault,' DEFAULT 0')
#OF('DATE')
#SET(%NFieldType,'DATETIME')
#OF('DECIMAL')
#CASE(%BackendDriver)
#OF('MSSQL')
#SET(%NFieldType,'DECIMAL(' & %FieldMemoSize & ',' & %FieldPlaces & ')')
#OF('Oracle')
#SET(%NFieldType,'NUMBER(' & %FieldMemoSize & ',' & %FieldPlaces & ')')
#ENDCASE
#SET(%NFieldDefault,' DEFAULT ''0''')
#ENDCASE
#IF(INSTRING('IDENTITY',UPPER(%NAdditAttrib),1,1) < 1)
#SET(%NAdditAttrib,%NAdditAttrib & %NFieldDefault)
#IF(UPPER(%NFieldType)<>'TEXT' AND %AlterMode = '1')
#SET(%NAdditAttrib,%NAdditAttrib & ' WITH VALUES')
#ENDIF
#ENDIF
#IF(%NAdditAttrib)
#IF(%AlterMode = '1')
IF NOT EXISTS (SELECT SYSCOLUMNS.name FROM syscolumns where SYSCOLUMNS.name='%NFieldName')
BEGIN
ALTER TABLE %IDSymbol%TFileName%IDSymbol ADD %IDSymbol%NFieldName%IDSymbol %NFieldType %NAdditAttrib
SELECT @FldName = '%TFileName was upgraded'
END
#ELSE
%IDSymbol%NFieldName%IDSymbol %NFieldType %NAdditAttrib,
#ENDIF
#ELSE
#IF(%AlterMode = '1')
IF NOT EXISTS (SELECT SYSCOLUMNS.name FROM syscolumns where SYSCOLUMNS.name='%NFieldName')
BEGIN
ALTER TABLE %IDSymbol%TFileName%IDSymbol ADD %IDSymbol%NFieldName%IDSymbol %NFieldType
SELECT @FldName = '%TFileName was upgraded'
END
#ELSE
%IDSymbol%NFieldName%IDSymbol %NFieldType,
#ENDIF
#ENDIF
#ENDFOR
#IF(%AlterMode = '1')
#RETURN #! Yet to be solved
#ENDIF
#! primary key & all the constraints (unique keys)
#SET(%OptComma,'')
#FOR(%Key),WHERE(NOT %KeyDuplicate)
#IF(%KeyName)
#SET(%NKeyName,SLICE(%KeyName,2,LEN(%KeyName)-1))
#ELSE
#SET(%NKeyName,%KeyID)
#END
#SET(%NKeyFields,'')
#SET(%NKeyFieldCount,0)
#FOR(%KeyField)
#FIND(%Field,%KeyField)
#IF(%FieldName)
#SET(%NKeyField,SLICE(%FieldName,2,LEN(%FieldName)-1))
#ELSE
#SET(%NKeyField, SUB(%KeyField, INSTRING(':',%KeyField,1,1) + 1 , 50))
#ENDIF
#SET(%NKeyFieldCount,%NKeyFieldCount + 1 )
#IF(%NKeyFieldCount = 1)
#SET(%NKeyFields,%IDSymbol & %NKeyField & %IDSymbol)
#ELSE
#SET(%NKeyFields, %NKeyFields & ' ,' & %IDSymbol & %NKeyField & %IDSymbol)
#ENDIF
#ENDFOR
#SET(%NKeyName,%TPrefix & %NKeyName)
#SET(%PKeyCount, %PKeyCount + 1)
#SET(%KeyCount, %KeyCount + 1)
#IF(%KeyPrimary)
%OptComma CONSTRAINT %IDSymbol%NKeyName%IDSymbol PRIMARY KEY (%NKeyFields)
#ELSE
%OptComma CONSTRAINT %IDSymbol%NKeyName%IDSymbol UNIQUE (%NKeyFields)
#ENDIF
#SET(%OptComma,',')
#ENDFOR
#! Close declaration
#CASE(%BackendDriver)
#OF('MSSQL')
)
#OF('Oracle')
);
#ENDCASE
#!
#!---------------------------------------------
#GROUP(%IndicesDeclaration)
#! keys without the primary - outside the file declaration
#FOR(%Key)
#IF(%KeyName)
#SET(%NKeyName,SLICE(%KeyName,2,LEN(%KeyName)-1))
#ELSE
#SET(%NKeyName,UPPER(%KeyID))
#END
#SET(%NKeyFields,'')
#SET(%NKeyFieldCount,0)
#FOR(%KeyField)
#FIND(%Field,%KeyField)
#IF(%FieldName)
#SET(%NKeyField,SLICE(%FieldName,2,LEN(%FieldName)-1))
#ELSE
#SET(%NKeyField, sub(%KeyField, instring(':',%KeyField,1,1) + 1 , 50))
#ENDIF
#SET(%NKeyFieldCount,%NKeyFieldCount + 1 )
#IF(%NKeyFieldCount = 1)
#SET(%NKeyFields,%IDSymbol & %NKeyField & %IDSymbol)
#ELSE
#SET(%NKeyFields, %NKeyFields & ' ,' & %IDSymbol & %NKeyField & %IDSymbol)
#ENDIF
#ENDFOR
#IF(NOT %KeyPrimary)
#SET(%KeyCount, %KeyCount + 1)
#IF(%AlterMode = '1')
#!IF EXISTS (SELECT sysindexes.name FROM sysindexes WHERE sysindexes.name = '%NKeyName') DROP INDEX %TFileName.%NKeyName
#ENDIF
#IF(%KeyDuplicate)
#CASE(%BackendDriver)
#OF('MSSQL')
CREATE INDEX %IDSymbol%NKeyName%IDSymbol ON %IDSymbol%TFileName%IDSymbol (%NKeyFields)
#OF('Oracle')
CREATE INDEX %IDSymbol%NKeyName%IDSymbol ON %IDSymbol%TFileName%IDSymbol (%NKeyFields);
#ENDCASE
#ELSE
#! CREATE UNIQUE INDEX %IDSymbol%NKeyName%IDSymbol ON %IDSymbol%TFileName%IDSymbol (%NKeyFields)
#ENDIF
#ENDIF
#ENDFOR
#! Relations
#IF(%CreateRelation)
#FOR( %File )
#IF (%AllTables = 0)
#FIND (%InclTable, %File)
#IF (%InclTable = '')
#CYCLE
#ENDIF
#ENDIF
#IF (SUB(%FileDriver,1,5) = 'MSSQL' )
#FOR(%Key)
#FOR(%Relation),WHERE(%FileKey = %Key)
#IF(%FileRelationType = 'MANY:1')
#SET(%NKeyField, sub(%FileKey, instring(':',%FileKey,1,1) + 1 , 50))
#SET(%NRelateFile, sub(%RelationKey, 1, instring(':',%RelationKey,1,1) -1 ))
#FOR(%KeyField)
#FIX(%FileKeyField,%KeyField)
#IF(%FileKeyField)
#FIND(%Field,%FileKeyField)
#IF(%FieldName)
#SET(%Relationfield1,SLICE(%FieldName,2,LEN(%FieldName)-1))
#ELSE
#SET(%Relationfield1,SUB(%FileKeyField, INSTRING(':',%FileKeyField,1,1)+1, 50))
#ENDIF
#FIND(%Field,%FileKeyFieldLink)
#IF(%FieldName)
#SET(%Relationfield2,SLICE(%FieldName,2,LEN(%FieldName)-1))
#ELSE
#SET(%Relationfield2,SUB(%FileKeyFieldLink, INSTRING(':',%FileKeyFieldLink,1,1)+1, 50))
#ENDIF
#ENDIF
#ENDFOR
#ENDIF
#IF(%Relationfield1)
ALTER TABLE %IDSymbol%TFileName%IDSymbol ADD
CONSTRAINT %IDSymbol%NKeyField%IDSymbol FOREIGN KEY (%IDSymbol%Relationfield1%IDSymbol)
REFERENCES %IDSymbol%NRelateFile%IDSymbol(%IDSymbol%Relationfield2%IDSymbol)
#SET(%Relationfield1,'')
#SET(%Relationfield2,'')
#ENDIF
#ENDFOR
#ENDFOR
#ENDIF
#ENDFOR
#ENDIF
#!
#!---------------------------------------------
#GROUP(%ConversionScript)
DECLARE @FldName VARCHAR(101)
SELECT @FldName = ''
IF EXISTS (SELECT sysobjects.name FROM sysobjects WHERE sysobjects.name = 'T_%TFileName')
BEGIN
DROP TABLE T_%TFileName
END
IF NOT EXISTS (SELECT sysobjects.name FROM sysobjects WHERE sysobjects.name = '%TFileName')
SELECT @FldName = '%TFileName was created'
ELSE
BEGIN
#SET(%TPrefix,'')
#SET(%AlterMode,'1')
#INSERT(%FileDeclaration)
#!#INSERT(%IndicesDeclaration)
END
#SET(%AlterMode,'')
#SET(%TPrefix,'T_')
IF NOT @FldName = '%TFileName was created'
BEGIN
CREATE TABLE %IDSymbol%TPrefix%FILE%IDSymbol(
#INSERT(%FileDeclaration)
INSERT INTO %IDSymbol%TPrefix%FILE%IDSymbol
#INSERT(%CommaDelimitedFields)
SELECT %FldList FROM %IDSymbol%TFileName%IDSymbol
DROP TABLE %IDSymbol%TFileName%IDSymbol
END
#SET(%TPrefix,'')
CREATE TABLE %IDSymbol%TFileName%IDSymbol(
#INSERT(%FileDeclaration)
#INSERT(%IndicesDeclaration)
IF NOT @FldName = '%TFileName was created'
BEGIN
#SET(%TPrefix,'T_')
INSERT INTO %IDSymbol%TFileName%IDSymbol
#INSERT(%CommaDelimitedFields)
SELECT %FldList FROM %IDSymbol%TPrefix%FILE%IDSymbol
DROP TABLE %IDSymbol%TPrefix%FILE%IDSymbol
END
IF NOT @FldName = '' PRINT @FldName
GO
/*------------------------------------------------------------------------------------------*/
#!
#GROUP(%CommaDelimitedFields),AUTO
#DECLARE(%WasUnqID)
#SET(%FldList,'')
#SET(%WasUnqID,'')
#FOR(%Field)
#IF(%FieldType='GROUP')
#CYCLE
#ENDIF
#IF(%FieldType='END')
#CYCLE
#ENDIF
#IF((UPPER(%FieldID) = UPPER(%UnqID) OR INSTRING(UPPER(%UnqID),UPPER(%FieldUserOptions),1,1) > 0) AND (%UnqID <> ''))
#SET(%WasUnqID,'1')
#CYCLE
#ENDIF
#IF(%FieldName)
#SET(%NFieldName,%IDSymbol & SLICE(%FieldName,2,LEN(%FieldName)-1) & %IDSymbol)
#ELSE
#SET(%NFieldName,%IDSymbol & %FieldID & %IDSymbol)
#ENDIF
#IF(%FldList = '')
#SET(%FldList,%NFieldName)
#ELSE
#SET(%FldList,%FldList & ',' & %NFieldName)
#ENDIF
#ENDFOR
#IF(%WasUnqID = '')
#SET(%FldList,'* ') #! no need to elongate the list
#ENDIF
#!---------------------------------------------
#GROUP(%ScriptPerFile)
#IF( %AliasFile ) #! This file is an alias. We don't need to generate script for it
#RETURN #!#CYCLE
#ENDIF
#IF( INSTRING('/NOSQL',%FileUserOptions,1,1) > 0 )
#RETURN #!#CYCLE
#ENDIF
#MESSAGE(%File,2)
#IF(%FileName AND INSTRING('!',%FileName,1,1) < 1 AND INSTRING(':',%FileName,1,1) < 1)
#SET(%TFileName,UPPER(%FileName))
#IF(SLICE(%TFileName,1,1) = '''') #! eliminate quotes
#SET(%TFileName,SLICE(%TFileName,2,LEN(%TFileName)-1))
#ENDIF
#ELSE
#SET(%TFileName,UPPER(%File))
#ENDIF
#IF(%ScriptType = 2)
/* Table %File */
#INSERT(%ConversionScript)
#RETURN
#ENDIF
#IF (%AllTables = 0)
#FIND (%InclTable, %File)
#IF (%InclTable = '')
#RETURN #!#CYCLE
#ENDIF
#ELSE
#ENDIF
#SET(%TableCount, %TableCount + 1)
/* Table %File */
#IF(%DropTable)
#CASE(%BackendDriver)
#OF('MSSQL')
DROP TABLE %TFileName
#OF('Oracle')
DROP TABLE %TFileName;
#ENDCASE
#ENDIF
CREATE TABLE %IDSymbol%TFileName%IDSymbol(
#INSERT(%FileDeclaration)
#INSERT(%IndicesDeclaration)
#!
#CASE(%BackendDriver)
#OF('MSSQL')
PRINT %TFileName
#OF('Oracle')
PROMPT %TFileName;
#ENDCASE
#!---------------------------------------------