procedure pCreate_SQL_Load_Files
*
lparameter tcViewName
if vartype(tcViewName) <> "C" or empty(tcViewName) or isnull(tcViewName)
return
endif
local lcView, lcTable
lcView = alltrim(tcViewName)
if empty(lcView)
return
endif
lcTable = substr(lcView, 3)
if file("D:\Apps\Npdes99\SQL_Load\" + lcTable + ".ctl")
erase "D:\Apps\Npdes99\SQL_Load\" + lcTable + ".ctl"
endif
if file("D:\Apps\Npdes99\SQL_Load\" + lcTable + ".par")
erase "D:\Apps\Npdes99\SQL_Load\" + lcTable + ".par"
endif
if file("D:\Apps\Npdes99\SQL_Load\" + lcTable + ".dat")
erase "D:\Apps\Npdes99\SQL_Load\" + lcTable + ".dat"
endif
select (lcView)
set order to
local i
set textmerge on
set textmerge to "d:\apps\npdes99\sql_load\" + lcTable + ".par" noshow
\\userid=my_ora_id/my_password@dsn
\control=<>.ctl
\bad=<>.bad
set textmerge to "d:\apps\npdes99\sql_load\" + lcTable + ".ctl" noshow
\\LOAD DATA
\INFILE <>.dat
\INSERT
\ INTO TABLE <>
\ FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '~'
\ TRAILING NULLCOLS
\ (
for i = 1 to fcount()
if i > 1
\\
endif
do case
case type(field(i)) = "D"
\\<> DATE (8) "YYYYMMDD"
case type(field(i)) = "M"
&& assuming no memo field is longer than 1500 chars. can be increased.
\\<> CHAR (1500)
otherwise
\\<>
endcase
if i < fcount()
\\,
\
endif
endfor
\\)
\
set textmerge to "D:\Apps\Npdes99\SQL_Load\" + lcTable + ".dat"
locate
local lcProgCaption
lcProgCaption = lcTable + " Data File Creation Progress "
oBar.Value = 0
oProgress.Caption = lcProgCaption
oProgress.Show()
scan
for i = 1 to fcount()
do case
case inlist(type(field(i)), "C", "M")
\\~<>~
case type(field(i)) = "N"
\\<>
case type(field(i)) = "D"
\\<>
otherwise
\\<>
endcase
if i < fcount()
\\,
endif
endfor
\
lnVal = abs(recno(lcView))/min(reccount(lcView), MAX_RECS) * 100
oProgress.Caption = lcProgCaption + str(lnVal, 3, 0) + "%"
oBar.Value = min(lnVal, 100)
endscan
set textmerge to
set textmerge off
return
Mark McCasland
Midlothian, TX USA