I have a process that queries an oracle database, many times the query contains some mathematical functions. At times we get the dreaded ORA-01476: divisor is equal to zero error which haults processing.

I am trying capture the rowid of the record that is causing this error for review. What I have come up with seems to only give me the rowid of the last successful record. (By the way, I am writing the output of the query to a flat file, so there is a little bit of code in here to print all of the columns except the rowid.)

I have a command line switch that allows the user to request the rowid, otherwise it just runs the supplied sql statement.
while ((@cols)=$sth->fetchrow_array){ if ($row_id) { $cur_rowid=$cols[0]; @cols=(@cols[1..$col_cnt]); print OFILE join "$delimiter" => (@cols),"\n"; } else { print OFILE join "$delimiter" => (@cols),"\n"; } } #end while
Does anyone know how I can capture the specifics of the row that is actually failing? Based on the behavior, it appears as though the behavior is that the array @cols isn't populated when the error occurs. Regards

In reply to get rowid for failed records using dbi by ctaustin

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.