Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1028
  • Last Modified:

MS DOS Batch file - Running Oracle Processes, Executes too quickly & does not Redirect Output

I'm using a batch file to execute several steps in updating a database:
Step 1 - Trucates the tables in Oracle
Step 2 - Loads new infor into the tables
Step 3 - Updates info
Ect, Ect - eventually there will be 5 steps
For now I am just trying to accomplish the first 2 steps

My Batch file code looks like this:

start WAIT/C:\ORANT\Bin\Plus80W.exe Userid/pw@db @C:\Testing\sql.TXT>C:\Log.txt

START WAIT/C:\ORANT\Bin\sqlldr80.exe parfile=C:\Test.par>>C:\Log.txt
 
I have a 2 part problem:

1)
Step 2 executes before step 1 finishes truncating the tables - HOW DO I CORRECT THIS?

2)
***If I run each of these from the command line - all of both steps output shows up in LOG.txt,  
When I seperate into 2 batch files and run seperately I get only the output from step 1.  
Or if I just run step 2 as a seperate batch file then Log.txt is blank.
Need to be able to have all output in one log.
0
gsmom94121
Asked:
gsmom94121
1 Solution
 
SteveGTRCommented:
The /WAIT option should do it. You could try:

cmd /c ...your Oracle program w/parms...

Are there any command line options to Plus80W.exe that tell it to do the processing in batch?

Good Luck,
Steve
0
 
rin1010Commented:

gsmom,

One thing i notice that may be disrupting it is placement of the slash
specifying the Wait parameter... If that's not a typo,
put the slash before the Wait option... e.g:

start /wait ping.exe www.experts-exchange.com

If that's not the problem, you may have success running the first command
with the Call command. And depending on your OS you could try using
the Command.com (or cmd.exe) /C switch to start a new instance
of the command interpreter to process that line and then exit.

It seems that the first command should execute before returning to the batch file
without the use of Start.exe and then run the subsequent command
without launching another instance of the command interpreter.
That could explain the difference between running it from a batch script
and manually from the command line.

For example, using Start without the /wait option spawns a new command instance
to perform the command, but immediately returns to the initiating batch file
before it's completed, like:

@echo off
cls
start ping www.experts-exchange.com
echo.
echo    %0 Done...
echo.


And the following would also create another instance of the command interpreter
but would wait before returning if used in a batch script or from a command prompt...

@echo off
cls
start /wait ping www.experts-exchange.com
echo.
echo    %0 Done...
echo.


But using the Call command processes the line in the same command session
before returning to the calling script, like:

@echo off
cls
call ping www.experts-exchange.com
echo.
echo    %0 Done...
echo.


Regarding your other question, you say,
"If I run each of these from the command line -
all of both steps output shows up in LOG.txt..."
and "Need to be able to have all output in one log."

It sounds like you may have the logging as you want
if you can just get the first command to process before the next.
Please post back if none of this works and provide your OS and ver...
If we can first get the processing sequence corrected
the logging should be simple...
 
0
 
gsmom94121Author Commented:
Interesting...Problem Solved thanks to you rin1010

Yes, the WAIT/ was a typo

Here's what I actually had to do to accomplish the task:

First I created a master batch file:
Call C:\JB_Step_1_test.bat
call C:\JB_Step_2_test.bat

Step_1 Batch:
start /wait C:\ORANT\Bin\Plus80W.exe ID/PW@DB @C:\jb_test.sql

In jb_test.sql:
set serveroutput on
spool C:\JB_test_log4.txt
TRUNCATE TABLE TEST;
commit;
spool out;
exit

Step_2 Batch:
call c:\ORANT\Bin\sqlldr80.exe parfile=c:\TEST.par>>C:\JB_test_log4.txt

Contents of JB_test_log4.txt:

Table truncated.

Commit complete.

SQL*Loader: Release 8.0.5.0.0 - Production on Thu Apr 4 13:3:51 2002

(c) Copyright 1998 Oracle Corporation.  All rights reserved.

Commit point reached - logical record count 100

Exactly what I needed.
Thank you so much!


0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now