CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Use of uninitialized value in concatenation or string ..



Nov 16, 2017, 3:02 PM

Post #1 of 2 (7199 views)
Use of uninitialized value in concatenation or string .. Can't Post

The below code fails when I try to pass in 3 parameters in the Perl script which connects to a Oracle Database.

my $gen_text = $dbh->prepare(qq(SELECT col1, col2 FROM region WHERE STATUS = 'N' AND PARTITION_KEY IN (SELECT col_1 AS part_key FROM Sched  WHERE derivdate = to_date(?,'YYYY-MM-DD') and group = ? and row_number = ?)))    
or die("Could not get data from table '$_'".DBI->errstr);


$gen_text->execute($derivdate, $group, $row_number);

my @firstrow;
my @columns;

if (exists($$cols[0])) {

foreach my $col (@$cols) {
my ($name) = $$col[0];
$name =~ s/\s+//g;
push @columns, $name;
} else {

my $rc = $gen_text->fetchrow_hashref() or $nodata = 1;
if ($nodata) {
print(" - No data found in table '$_' ".$gen_text->errstr());
my @row = @{$gen_text->{NAME}};
@$cols = @row;

foreach my $col (@$cols) {
my $name = $col;
$name =~ s/\s+//g;
my $data = $rc->{$name};
push @firstrow, $data;
push @columns, $name;
print "Creating export file for table '$_'\n";

The error code occurs on the line below

print("  - No data found in table '$_' ".$gen_text->errstr())

There is data in the table when I select the column from the database. Also, the script works when I hardcode the values for derivdate, group and row number. It FAILS when I assign the bind param for the 3 variables. What am I doing wrong on the bind variable assignments?

Chris Charley

Nov 16, 2017, 4:31 PM

Post #2 of 2 (7194 views)
Re: [steve798] Use of uninitialized value in concatenation or string .. [In reply to] Can't Post

I think you need to bind the params, then execute with no arguments, $gen_text->execute;.

See from the docs for DBI.

Either that or don't bind the values themselves and use the statement $gen_text->execute($derivdate, $group, $row_number); that you have (without explicitly binding them before).

This may solve your problem.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives