ORA-0900 is an invalid SQL statement - so I think the SQL is the problem, not the Perl. If you are checking the SQL in sqlplus, you should know that sqlplus has its own syntax and you need to remove the sqlplus specific stuff (the / in particular - there may be more, but I don't know because I don't use sqlplus) and send pure SQL or PL/SQL to Oracle from DBI. I recommend not using sqlplus at all - I use Toad, and I'm sure there are other Oracle clients out there that do not make you add non-SQL syntax.

I'm a little confused by your terminology, but I think what you are calling a "command file" is known as a "PL/SQL block".

First of all, make sure you are not sending DOS style line endings in your PL/SQL block - that will kill it every time.

Next, buy a book on PL/SQL. Here's a quick tutorial in the meantime:

A PL/SQL block starts with an optional "DECLARE" section, in which you declare your variables, then has a "BEGIN", after which you put the multiple sql statements (don't use the / to separate/run them as you do in sqlplus), then an optional "EXCEPTION" section, then an "END;" to finish it off. It's almost exactly like a procedure definition, except for the explicit DECLARE section (which you get for free in a procedure after the IS). Example:
DECLARE null_tmpString EXCEPTION; tmpString VARCHAR2(20); BEGIN --someProcedure sets tmpString as an OUT parameter someProcedure( 'asdf', 1, tmpString ); INSERT INTO someTable ( column1, column2 ) VALUES ( tmpString, 'qwer' ); IF tmpString IS NULL THEN --raise an error to go to the exceptions section --in this case, we skip the update but still --commit the insert RAISE null_tmpString; END IF; UPDATE someOtherTable SET otherColumn1 = 5 WHERE otherColumn2 = tmpString; COMMIT; EXCEPTION WHEN null_tmpString THEN COMMIT; WHEN OTHERS THEN ROLLBACK; END;
As for how to execute it in DBI - I'm trapped in PHPland so I can't tell you precisely, but you basically just want to "parse" it and "execute" it (maybe set the prefetch before executing), both of which you are doing. So again, I don't think the problem is with your perl code.
Update
Clarified the main point, that the SQL (which was not given) is probably in error, not the perl code.

In reply to Re: DBI & Oracle Command Files by bean
in thread DBI & Oracle Command Files by Ronnie

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.