I'm having a tough time getting a failure code back into my PERL program when invoking SQL Plus via the system command. I have run_package.sql
begin forbesc.test_exception_pg.main('orafail'); end; / exit
and invoke_sqlplus.pl
#!/usr/bin/perl -w my $sqlplus = "sqlplus -s chuckster/im_in\@develo"; my $file = "\@/home/prodadm/scripts/run_package.sql"; my $var = (system($sqlplus . " " . $file)); my $out = $? >> 8; print "The out value is '$out'.\n";
I'm pretty sure that the reason I'm always getting a 0 for $out is because the 'exit' in run_program.sql is executing successfully, but I want to know when the Oracle package is not executed successfully. I know it's not in the above case, as the output looks like:
[prodadm@ora4 scripts]$ ./invoke_sqlplus.pl begin * ERROR at line 1: ORA-01476: divisor is equal to zero ORA-06512: at "FORBESC.TEST_EXCEPTION_PG", line 12 ORA-06512: at line 2 The out value is '0'.
I'm at a loss. Could someone help plant a fire under me and get me going in the right direction? Thanks, Chuckster

In reply to invoking Oracle's SQL Plus, return code always indicates success by chuckster

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.