Error Handling using ISQL for oracle connection in Perl


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Error Handling using ISQL for oracle connection in Perl
# 1  
Old 01-11-2012
Error Handling using ISQL for oracle connection in Perl

Hi

Am making connection to oracle using ISQL as shown in the code.
This code is just a minor part of a big code.
I want to capture the error if the password/login is wrong or if connection is not made.
I need to capture the error code also.
Also, If such an error occurs, i need to exit out of the script
How can this be done in ISQL


Any help will be appreciated.
Thanks in advance.

Code:
 
my $fileLoad = <<LOADEOF;
set term off;
set linesize 1500;
set feedback off;
spool ${data_file}
$orcl_query;
spool off
LOADEOF
 
 
open (ISQL, "|sqlplus -S ${db_login}/${db_passwd}\@${oracle_sid}");
ISQL $fileLoad;
close (ISQL);

# 2  
Old 01-11-2012
Code:
open (ISQL, "|sqlplus -S ${db_login}/${db_passwd}\@${oracle_sid}") or die "Couldn't execute program: $!";

$! will have the error information
# 3  
Old 01-11-2012
ThanksSmilie
But how to capture the error no?

Also how can it be done using "eval"?

Last edited by irudayaraj; 01-11-2012 at 05:17 AM..
# 4  
Old 01-11-2012
i guess, you will get the reason and error code in the $!

otherwise

you can use DBI module

DBI - search.cpan.org
# 5  
Old 01-11-2012
Thanks
But die/eval/whenever sqlerror exit sql.sqlcode doesnt work.
Is there any other better option to capture the error code there itself and exit from the script?

Last edited by irudayaraj; 01-11-2012 at 09:28 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl file handling error

Hi, I am reading and file and writting each word to other file. where I have used array to store the data. I am getting below error as "Use of uninitialized value in concatenation (.) or string at customize_split_raw.pl line 51, <IN_FILE> " Where my line 51 code is 50 foreach... (8 Replies)
Discussion started by: Beginer123
8 Replies

2. Shell Programming and Scripting

Perl Oracle connection error

I've a Centralized Server which can connect to all Oracle Databases. When I was trying the below code it doesn't work, But tnsping was working fine. #!D:/perl5/bin/perl.exe use DBI; my $dbh = DBI->connect('dbi:Oracle:QBDIWCE', 'IDUSER', 'SECRET123#' ) || die( $DBI::errstr . "\n" ) ; ... (1 Reply)
Discussion started by: ilugopal
1 Replies

3. Shell Programming and Scripting

PERL error handling

I have a PERL command line embedded in a UNIX script. The script doesn't handle errors coming out of this command. I'm processing large files and occassionally I run out of disk space and end up with half a file. perl -p -e 's/\n/\r\n/g' < TR_TMP_$4 > $4 How do I handle errors coming out... (1 Reply)
Discussion started by: OTChancy
1 Replies

4. Shell Programming and Scripting

How do i access sybase using isql and how do i get result set in perl script?

Hi, How do i get result set in perl script using isql while connecting sybase server. I have a perl script which connected to sybase and get the result set. but i wanted to get the result set. How do i get the result set in perl script not unix shell script.. $server ="ServerName"; open... (1 Reply)
Discussion started by: solo123
1 Replies

5. Infrastructure Monitoring

Perl Error Handling Problem

I can get this working, but if something is down I get an error and the script does not move on. I can not get the "else" function working. What might I be doing wrong? use SNMP::Simple my %ios = (); $list="list.list"; open(DAT, $list) || die("Can't Open List"); @raw_data=<DAT>;... (4 Replies)
Discussion started by: mrlayance
4 Replies

6. Shell Programming and Scripting

SSH Connection To Oracle

My problem is this....:eek: Platform=Sun Solaris UNIX / Oracle 10g 1) I'm trying to SSH from my local system A to remote system B 2) Once connected, I need to sudo to ID that has the ability to connect to the Oracle database 3) Then run a script that connects via sqlplus and... (2 Replies)
Discussion started by: khand67
2 Replies

7. Shell Programming and Scripting

Perl and Sockets - Error handling

Hello all, I have created a Perl script that tries to open connections to various systems on different ports in order to see if the machines are reachable, the ports are open, etc. There appears to be a difference between Solaris (10) and Linux (RH/Oracle and Ubuntu) in the status or error it... (4 Replies)
Discussion started by: Hollinch
4 Replies

8. Shell Programming and Scripting

Perl connect to remote oracle db without local oracle installation

I want to use Perl to connect to a remote Oracle DB I have no oracle installation on my server (and dont plan on installing one) I am using solaris 9 on x86 server. Is this possible? I basically want to run some basic sql queries on the remote oracle db which I have access to using perl on my... (0 Replies)
Discussion started by: frustrated1
0 Replies

9. Windows & DOS: Issues & Discussions

Oracle 9i ODBC connection

I am attempting to access an Oracle 9i database located on a Solaris server from an XP client. The server is running Oracle 9i9.2.0.1.0 and the XP is Oracle client 9i 9.2.0.1.0. When I start a listener on the server, the listener starts but I receive a message “The listener supports no services”. I... (3 Replies)
Discussion started by: jkuchar747
3 Replies

10. UNIX for Advanced & Expert Users

Unix + oracle connection

Requirements: Using a shell script I have to check the 4 values from a table in Oracle and then store the result as "Y" in a Unix variable if the values are desired and "N" if the values are not desired. Explanation: There is a table abc in oracle which has 4 fields. if all the four values... (2 Replies)
Discussion started by: decci_7
2 Replies
Login or Register to Ask a Question