Solved

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

Posted on 2002-04-04
3
1,007 Views
Last Modified: 2007-11-27
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
Comment
Question by:gsmom94121
3 Comments
 
LVL 30

Expert Comment

by:SteveGTR
Comment Utility
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
 
LVL 7

Accepted Solution

by:
rin1010 earned 100 total points
Comment Utility

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
 
LVL 1

Author Comment

by:gsmom94121
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now