Solved

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

Posted on 2002-04-04
3
1,015 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
ID: 6918796
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
ID: 6918943

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
ID: 6919286
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
robocopy for today files 14 139
Include multiple hostnames in this command? 3 55
Correct way to use if / else command 3 72
Filter echo results from batch file output 7 64
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

785 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