2017-01-24 174 views
-1

我必须运行多个批处理文件才能将批量数据导入到Oracle中。 我想只运行一个bat文件。Oracle在批处理文件中导入批处理文件

批处理文件在separeted子是这样的:

g:\1\import.bat 
g:\2\import.bat 
... 
g:\n\import.bat 

而且他们看起来是这样的:

@echo off 
REM Copyright (c) 1999-2004 by Intergraph Corporation. All Rights Reserved. 
REM Use this script to create feature class tables via SQL and populate tables with SQL*Loader. 
REM The GDOSYS schema is no longer created via this script. If you want metadata to be loaded, 
REM GDOSYS needs to exist prior to running import. You may use Database Utilities to create GDOSYS. 
REM If you are using a comma for a decimal separator, set the NLS_NUMERIC_CHARACTERS parameter: 
REM SET NLS_NUMERIC_CHARACTERS=,. 
if "%1"=="" goto usage 
SQLPLUS %1> @"kat_ki_vectors_epulet_i_pre.sql" 
SQLLDR %1 CONTROL='kat_ki_vectors_epulet_i' 
SQLPLUS %1 @"kat_ki_vectors_epulet_i_post.sql" 
goto end 
: usage 
echo SYNTAX: "Import username/[email protected]" 
echo WHERE: 
echo - username/password is the Oracle user account where the data will be loaded. 
echo - ConnectString is the Oracle NET string used to connect to the Oracle server. 
echo See the document "Working with GeoMedia Professional" for more 
information. 
echo EXAMPLES: 
echo Import scott/[email protected]_orcl 
: end 
pause 

我试图用这种蝙蝠运行的所有的人文件(带有适当的认证):

call g:\1\import.bat ###/###@###.## 
call g:\2\import.bat ###/###@###.## 
... 
call g:\n\import.bat ###/###@###.## 

,但是这是我的了:

G:\>do_the_trick.bat 
G:\>call g:\1\import.bat ###/###@###.## 
SQL*Plus: Release 11.1.0.6.0 - Production on K. Jan. 24 15:35:08 2017 
Copyright (c) 1982, 2007, Oracle. All rights reserved. 
Kapcsolódási cél: 
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 
SP2-0310: nem lehet megnyitni a(z) "kat_ki_vectors_epulet_i_pre.sql" fájlt 

"Kapcsolódási cél" ---> "Connecting target" 
"nem lehet megnyitni a(z) " ---> "Can not be opened" 
然而

,如果我跑第一个bat文件直接

G:\1>import.bat ###/###@###.## 

导入开始。

请给我一些提示尝试!

+0

不同之处在于您手动从其子目录运行批处理。 – LotPings

回答

1

该批次应该工作,只需要设置最大可能的数量。 该批次将评估当前最高号码。

@Echo off 
CD /D "G:\" 
:: first get the highest number increase if max > 1000 
For /L %%N in (1,1,1000) Do If Exist "G:\%%N" (Set Max=%%N) Else Goto :Cont 
:Cont 
:: iterate through all numbered subdirs 
For /L %%N in (1,1,%Max%) Do (
    Pushd "G:\%%N" 
    Call import.bat ###/###@###.## 
    PopD 
) 

为了得到G:\ ALL子目录,你可以使用

@Echo off 
For /D %%A in (G:\*) Do (
    Pushd "%%~fA" 
    Call import.bat ###/###@###.## 
    PopD 
) 

编辑另一个版本,其中一个管道(空)呼应import.bat所以没必要做手工acknowlede。它还检查是否存在import.bat

@Echo off 
Set App=Import.bat 
Set Cred=###/###@###.## 
For /D %%A in (G:\*) Do (
    Pushd "%%~fA" 
    If Exist %APP% Echo:|Call %App% %Cred% 
    PopD 
) 
+0

好吧,我有点误导我猜:子文件夹名称中的数字仅表示有许多子文件夹。 他们的真名是字母数字。 但我试过你的脚本与3个子文件夹包含Import.bat。 G:\ 1 \ G:\ 2 \ G:\ 3 \ 这是我得到: “系统找不到指定的批处理标签 - 续” – STO

+0

@STO对不起我的错,只是忘了(以上改变)。你想在'G:\'中处理所有子文件夹吗? – LotPings

+0

@STO我添加了一个版本,它将遍历'G:\'的所有**子目录\' – LotPings