Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

error trapping problem

by Anonymous Monk
on Feb 22, 2006 at 10:05 UTC ( [id://531910]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have an issue with a script I've inherited. Before going into the issue I realise that running a command in the way it's done is probably not the most sensible thing to do. Anyhow , the code does this
my $sqlpath="$ENV{SYBASE}/$ENV{SYBASE_OCS}/bin/isql"; open(ISQL, "$sqlpath -U$user -S$server -b -i$script -w1024 -P$passw +ord |") or die "Can't run isql $!\n"; close(ISQL); }
The $script is a user supplied sql script of usually of the format
command go command go command go
The question I have is how do I trap any errors that may come back from the running of the script through the isql call ? Alternatively does anybody know of any module I can use that will execute a user supplied script via DBI/DBD where the error handling would be much easier ?

Replies are listed 'Best First'.
Re: error trapping problem
by mpeppler (Vicar) on Feb 22, 2006 at 19:12 UTC
    Executing that script via DBD::Sybase would be a lot easier to trap the errors.

    That's pretty straightforward - you just need to read in the file and split it on the \ngo\n. Then submit each SQL block with a loop:

    $sth = $dbh->prepare($sql); do { while(my $row = $sth->fetch) { print "@$r\n"; } } while($sth->{syb_more_results});
    Michael
Re: error trapping problem
by Anonymous Monk on Feb 22, 2006 at 10:51 UTC
    perldoc perlopen
    perldoc perlipc

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://531910]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-26 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found