Hi all, This thing has been bothering me for a little while so here it is..

BACKGROUND
What i have is a simple search interface for an Oracle 8.1 database. The script takes an input value (ss#) from the user and process it (returns employee record) through the DBI.

PROBLEM
My problem is on the data handling portion of this program.
Here i am simply searching for let say an employee with his ss#. If that employee with the supplied ss# does not exist print "employee does not exist". Simple right!
Some people suggested that i rely on error codes returned through $DBI::errstr and use that in my code to handle conditions, but this i think wont work in oracle because it will ALWAYS return 0 for things like "not found". And i don't think that using eval{..}and if ($@){..} will be a good idea also. Not to confuse not found with an error. Remeber we are just wanting to handle a not found condition.
look at my while statement. I know the "EMPLOYEE DOES NOT EXIST" part should be outside the while loop.

Searching with this:

my $quotedSearch = $dbh->quote( $search_for_id ); $SQL = "SELECT * FROM EMPLOYEE WHERE employee_number = $quotedSearch"; eval{ $sth = $dbh->prepare($SQL); }
Here is my problem:
while (@row = $sth->fetchrow_array) { # Handle null or "undef's" $employee_number = (defined $row[0]) ? $row[0] : ''; $first_name = (defined $row[1]) ? $row[1] : ''; $last_name = (defined $row[2]) ? $row[2] : ''; $email = (defined $row[3]) ? $row[3] : ''; if ($#row > 0) { print "HERE IS ALL YOUR DATA\n"; } else { print "NO DATA FOR RECECORD SEARCHED. DO you WANT TO ADD NEW DATA\n"; } }

As always, any suggestions will go a long ways....

In reply to Handling conditions DBI in Oracle 8.1 by data67

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.