Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBI question

Status
Not open for further replies.

Haazi2

Programmer
Aug 25, 2000
51
US
I'm using DBI to access an Informix database on SUN OS 5.7 I'm doing a search to find records according to some criterion. My question is if no match is found in the database does DBI return an error? I'm using DBI::errstr to catch errors. How can I print out these errors? Thanks in advance for any help offered.
 
"no match" is not an error. It is simply an empty table. You should be reading your results into an array, right? Check if it is empty (ie. if (!@array)) to determine if there were matches or not.

To print out DBI errors, just || die "$DBI::errstr";
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Thanks Tom! This is my first project using DBI which I find very good for database operations.
 
DBI, as with pretty much all the Perl modules, comes with great documentation! To get at it, just do "perldoc DBI" - if you take the time to read it, it will answer these questions, and help you to better understand and use DBI. When you bring up "perldoc DBI", you can search for a specific word by doing "/{word to search for}" like "/errstr". The perldocs describe in detail every DBI command - what each command returns for success, and for failure.

I would also highly recommend "Programming the Perl DBI" by Descartes & Bunce - towards the back they have specific sections for each of the different databases - Informix *IS* in there - not that you need it for these questions.

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top