开发者

Need help in a batch script: use 1 or 2 arrays OR parse a file with a tuple name number

开发者 https://www.devze.com 2023-02-15 08:29 出处:网络
I want to run a sqlldr command customized with some parameters, more precisely a name and a associated number. For now I only have an iteration through names but I want to associate each of it with a

I want to run a sqlldr command customized with some parameters, more precisely a name and a associated number. For now I only have an iteration through names but I want to associate each of it with a number.

@echo off
set ORACLE_PWD=orcl
set NLS_NUMERIC_CHARACTERS=.,
setlocal
echo "Run number " %1
For %%X in (region nation supplier customer part partsupp orders lineitem) do (
sqlldr userid='sys/%ORACLE_PWD% as sysdba' log=%%X开发者_开发问答%1.log control=%%X.ctl direct=true rows=<associated_number> multithreading=true
)

I have 2 options: do it with another array of numbers (which may the hardest thing) or parse a text file like:

region 25 (or region DELIMITER 25)  
nation 100
supplier 5000 

and so on

and then get those values to vars and use them in the sqlldr command to customize my log name and the number of rows.

I understand that arrays in batch script are a nightmare and I'm trying but I can't get it right. Could someone please help me?


If you save this:

region 25
nation 100
supplier 5000

in a file named, for example, params.txt, then this script will read the file and substitute the values accordingly:

@echo off
set ORACLE_PWD=orcl
set NLS_NUMERIC_CHARACTERS=.,
setlocal
echo "Run number " %1
For /F "tokens=1,2" %%X in (params.txt) do (
sqlldr userid='sys/%ORACLE_PWD% as sysdba' log=%%X%1.log control=%%X.ctl direct=true rows=%%Y multithreading=true
)
0

精彩评论

暂无评论...
验证码 换一张
取 消