?
Solved

Trap Sql-Loader Error inside perl script

Posted on 2012-04-11
3
Medium Priority
?
705 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 1000 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 35

Accepted Solution

by:
johnsone earned 1000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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 video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Suggested Courses

752 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