Dear Monks,
I am finally writting a DBI Perl script.
I want to call a stored proc. from my script ...
#!/usr/bin/perl -w
use strict;
use DBI;
use Getopt::Std;
use vars qw/ $opt_d $opt_u $opt_p /;
my $db = 'SPROD';
my $user = 'SPROD';
my $pass = 'SPROD';
my $dbd = 'Oracle';
my $sql = 'exec RBC_test( :? );';
getopts ( "d:u:p:h" );
if ( $opt_d ) { $db = $opt_d; }
if ( $opt_u ) { $user = $opt_u; }
if ( $opt_p ) { $pass = $opt_p; }
my $dbh = DBI->connect ( $db, $user, $pass, $dbd );
if( !$dbh ) {
print "Cannot connect to database: $DBI::errstr\n";
die "Terminating\n";
}
my $sth = $dbh->prepare( $sql );
#$sth->bind_param( ":p", 123 );
$sth->execute(321) or print "Error [" . $sth->errstr . "]\n";
my $rc = $dbh->disconnect();
print "Disconnected rc = $rc\n";
Here's the error message ...
Error [ORA-00900: invalid SQL statement (DBD ERROR: OCIStmtExecute)]
Disconnected rc = 1
procedure RBC_test is very simple procedure that takes one
parameter and then just does a DBMS_OUTPUT.PUT_LINE( to_char(n) );
How am suppose to call stored procedures from a DBI script?
Thanks
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.