The documentation for DBI is pretty clear on the return value of do and it says:

Prepare and execute a single statement. Returns the number of rows affected or "undef" on error. A return value of "-1" means the number of rows is not known, not applicable, or not available.

But you are not testing the defined-ness or the negativity of the return value, you are testing the truthfulness of it. So, if zero rows are affected the return value will be zero, but your code in its present form takes this to be a failure. Instead of your current test, perhaps something like this might be better:

$rows = $source_dbh->do($ctas_sql); unless (defined $rows) { # handle error condition here }

Caveat: Your comments and code suggest you are using Oracle which I haven't touched for years so there may be something specific to that DB at play here as well.

Update: That's probably cobblers. do should return 0E0 on zero rows and your output clearly shows that rows is '' or undef. Sorry for the noise.


In reply to Re: DBI false error by hippo
in thread DBI false error by kyledba2013

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.