Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

eval {} effect on DB Connection

by kprasanna_79 (Hermit)
on Oct 19, 2005 at 06:10 UTC ( [id://501196]=perlquestion: print w/replies, xml ) Need Help??

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

Wise Monks...

I have an issue, for which i suspect the eval{} at this point. You monks have to clarify. Below is the issue.

I have written a daemon which wakes up every minutes and checks for some job cards(xml files in 500 folders) and if it finds some xml files it moves the name of the card to database.

I have put the db connection in eval statement. What happens is when there is some problem with db connection the script exits without handling the situtation. Even i have handled $@ at this point. But end up with vein.

What my question is, IS it wise to use eval at the db connection point, or anything else there to solve the issue.

Kindly Advice
-Prasanna.K

Replies are listed 'Best First'.
Re: eval {} effect on DB Connection
by Fang (Pilgrim) on Oct 19, 2005 at 06:40 UTC

    I believe that if you haven't set the RaiseError attribute to 1, DBI won't die if something bad happens, and therefore an eval block won't catch anything. Alternatively, you can follow every DBI call with an or die statement.

    So, have you set that attribute, or are you dieing properly? If no, try again with those changes. If yes, show us some of your involved code.

Re: eval {} effect on DB Connection
by pajout (Curate) on Oct 19, 2005 at 07:24 UTC
    Please, test it, if you can, without eval{}, to avoid interfering. I think that previously adviced RaiseError will help. Or if you have RaiseError == 0, check $DBI::errstr immediatelly after database handle command.

Log In?
Username:
Password:

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

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

    No recent polls found