Oracle导入bat文件中的批处理文件

时间:2022-11-14 16:03:28

I have to run several bat file to import mass data into Oracle. I'd like to run only one bat file.

我必须运行几个bat文件才能将海量数据导入Oracle。我想只运行一个bat文件。

The batch files are in separeted subfolders like this:

批处理文件位于separeted子文件夹中,如下所示:

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

And they looks like this:

它们看起来像这样:

@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/password@ConnectString" 
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/tiger@db_orcl
: end 
pause

I tried to run all of them with this bat file (with proper authentication):

我尝试用这个bat文件运行所有这些(使用适当的身份验证):

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

but this is what I got:

但这就是我得到的:

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"

however if I run the first bat file directly

但是,如果我直接运行第一个bat文件

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

The import begins.

进口开始了。

Please give me some tips to try out!

请给我一些尝试的提示!

1 个解决方案

#1


1  

This batch should work, and only requires to set the maximal possible number. The batch will evaluate the current highest number.

此批处理应该起作用,并且只需要设置最大可能的数量。批次将评估当前的最高数字。

@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
)

To get ALL subdirs of G:\ you could use

要获得G:\的所有子目录,你可以使用

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

EDIT Another version which pipes an (empty) echo to import.bat so no need to do acknowlede manually. It also checks for the existence of import.bat

编辑另一个将(空)回显传递给import.bat的版本,因此无需手动确认。它还检查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
)

#1


1  

This batch should work, and only requires to set the maximal possible number. The batch will evaluate the current highest number.

此批处理应该起作用,并且只需要设置最大可能的数量。批次将评估当前的最高数字。

@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
)

To get ALL subdirs of G:\ you could use

要获得G:\的所有子目录,你可以使用

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

EDIT Another version which pipes an (empty) echo to import.bat so no need to do acknowlede manually. It also checks for the existence of import.bat

编辑另一个将(空)回显传递给import.bat的版本,因此无需手动确认。它还检查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
)