I have a shell script (.sh) that works in Unix but I'd like to convert it into a Windows batch file (.bat):
cat >flog.ctl <<_EOF
LOAD DATA
INFILE '$1.log' "str ';'"
APPEND INTO TABLE flog
fields terminated by '=' TRAILING NULLCOLS
(
filename constant '$1'
,num char
,data char
)
_EOF
sqlldr <username>/<password>@<instance> control=flog.ctl data=$1.log
I'm not too knowledgable on batch files but if an answer is some hints rather than a complete solution then I'm sure I'll muddle through. This is to help with an answer to another question here .
Windows batch files do not support inlining data this way. You'll have to
ECHO firstLine > flog.ctl
ECHO additionalLine >> flog.ctl
Windows batch files denote variables in ECHO statements using % signs, ie %1%.
So you're resulting file would be something like:
@ECHO OFF
ECHO LOAD DATA > flog.ctl
ECHO INFILE '%1%.log' "str ';'" >> flog.ctl
ECHO APPEND INTO TABLE flog >> flog.ctl
ECHO fields terminated by '=' TRAILING NULLCOLS >> flog.ctl
ECHO ( >> flog.ctl
ECHO filename constant '%1%' >> flog.ctl
ECHO ,num char >> flog.ctl
ECHO ,data char >> flog.ctl
ECHO ) >> flog.ctl
sqlldr <username>/<password>@<instance> control=flog.ctl data=%1%.log
There are some complicated solutions as far as the inlining goes, but as was already mentioned, a simple solution would be to use echo
.
@echo off
echo LOAD DATA > flog.ctl
echo INFILE '%1.log' "str ';'" >> flog.ctl
echo APPEND INTO TABLE flog >> flog.ctl
echo fields terminated by '=' TRAILING NULLCOLS >> flog.ctl
echo ( >> flog.ctl
echo filename constant '%1' >> flog.ctl
echo ,num char >> flog.ctl
echo ,data char >> flog.ctl
echo ) >> flog.ctl
sqlldr <username>/<password>@<instance> control=flog.ctl data=%1.log
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.