Ramnarayan
Programmer
Hi,
I have written the below code snippet which selects the value of date from a table. Now it is working fine. But when I give to_char function, it is giving uninitialized value. Can someone help me here why PERL is not processing when Oracle works fine!
HEre is the code:
my $sth = do_select($dbh,
"select to_char(PUB_DATE, 'DD-MM-YYYY') " .
"from iz_article where article_id=? and batch_no=?", $art_id, '008Ma');
while (defined (my $r = $sth->fetchrow_hashref()))
{
my $pub_date = $r->{$c_pub_date};
print "~~~$pub_date~~~\n";
}
The error given out is "Use of uninitialized value in concatenation(.) or string at a.pl line no 8.
~~~~~~
However if the above code is run without the to_char function, it works fine as below:
my $sth = do_select($dbh,
"select PUB_DATE " .
"from iz_article where article_id=? and batch_no=?", $art_id, '008Ma');
while (defined (my $r = $sth->fetchrow_hashref()))
{
my $pub_date = $r->{$c_pub_date};
print "~~~$pub_date~~~\n";
}
OUTPUT: ~~~01-MAY-07~~~
I have written the below code snippet which selects the value of date from a table. Now it is working fine. But when I give to_char function, it is giving uninitialized value. Can someone help me here why PERL is not processing when Oracle works fine!
HEre is the code:
my $sth = do_select($dbh,
"select to_char(PUB_DATE, 'DD-MM-YYYY') " .
"from iz_article where article_id=? and batch_no=?", $art_id, '008Ma');
while (defined (my $r = $sth->fetchrow_hashref()))
{
my $pub_date = $r->{$c_pub_date};
print "~~~$pub_date~~~\n";
}
The error given out is "Use of uninitialized value in concatenation(.) or string at a.pl line no 8.
~~~~~~
However if the above code is run without the to_char function, it works fine as below:
my $sth = do_select($dbh,
"select PUB_DATE " .
"from iz_article where article_id=? and batch_no=?", $art_id, '008Ma');
while (defined (my $r = $sth->fetchrow_hashref()))
{
my $pub_date = $r->{$c_pub_date};
print "~~~$pub_date~~~\n";
}
OUTPUT: ~~~01-MAY-07~~~