Dear Monks,
I continue to receive the following error when trying to execute the code below. The procedure is to convert a date using the SQL to_date function, return it to Perl for processing, and then feed the date into a stored SQL procedure. I've tried passing the date multiple ways but continue to get the same error. Please note that I receive the error with or without the exception handling (not too sure that exception part will work either).
Any insight you can provide would be greatly appreciated. Thank you.
Error Received:
Placeholder :0 invalid, placeholders must be >= 1 at C:/Perl64/lib/DBD/Oracle.pm line 321.
Code Used:
#!/usr/bin/perl
use DBI;
use strict;
my $tdate = $ARGV[0];
my $dbh=DBI->connect("dbi:Oracle:dbname",username,password,{RaiseError
+ => 1 , PrintError => 0});
my $x;
open ($x, '>P_RUN_TIME_LOG.txt');
my $sqlstmt = "select to_date('$tdate','mm/dd/yyyy') from dual";
my $sth = $dbh->prepare($sqlstmt);
$sth->execute() or die $dbh->errstr;
my $tmp;
$sth->bind_columns(undef, \$tmp);
while($sth->fetch()) {$tdate = $tmp;} # LOOP THROUGH RESULTS
$t = localtime();
print $x "DATE formatted at $t. Formatted DATE is $tdate.\n\n";
$t = localtime();
print $x "Executing FT_PROC at $t.\n\n";
$sqlstmt = "BEGIN FT_PROC($tdate);
EXCEPTION
WHEN others THEN
sql_stmt := 'INSERT INTO P_LOG (PRCDR, FT_DATE, RUN_ST
+ATUS) VALUES ('FT_PROC', $tdate, 1)';
execute immediate sql_stmt;
END;";
$sth = $dbh->do($sqlstmt) or die $dbh->errstr;
$dbh -> disconnect;
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.