Solved

Trap Sql-Loader Error inside perl script

Posted on 2012-04-11
3
697 Views
Last Modified: 2012-04-11
HI,

I have a problem. I want to catch the return code from SQL Loader inside perl script. How can I do it?

I am doing the following. Here SQL Loader returns 0, even if it is successful to insert all rows which is correct but it also returns 0 if the column name is changed and as a result no rows are getting inserted which I am assuming is wrong. What is the problem here? Is this the right way to trap SQL-LDR errors?

A.pl
---------------------------------------------------------


`ksh file1.ksh`;


print "\nThe sqlldr return code is $?\n";

if (($? == 0) or  ($? ==2))

{

print \nError in Loading\n";
exit 1;
}

else { print "\nData Loaded in DB in Table1\n";
}


---------------------------------------------------------------------

Here is my file1.ksh --->


file1.ksh
-----------------------------------------------------------------

sqlldr id/pwd@server control=Table1.ctl log=Table1.log
--------------------------------------------------------------
0
Comment
Question by:sunny82
3 Comments
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 250 total points
ID: 37833000
>>Is this the right way to trap SQL-LDR errors?

I believe sqlloader is always successful.  I mean that it always executes.

You will likely need to parse the log file to see if it actaully loaded everytihng it was supposed to.
0
 
LVL 34

Accepted Solution

by:
johnsone earned 250 total points
ID: 37833202
SQL*Loader does have a return code to tell you whether a load is successful or not.  They are detailed here:

http://docs.oracle.com/cd/E11882_01/server.112/e22490/ldr_params.htm#i1005019

If you want to get more information than the return codes give you, you would have to parse the log file.
0
 

Author Comment

by:sunny82
ID: 37833403
ok many thanks to both of you...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

789 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