
steve798
Novice
Nov 16, 2017, 3:02 PM
Post #1 of 2
(5130 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->bind_param(1,$derivdate); $gen_text->bind_param(2,$group); $gen_text->bind_param(3,$row_number); $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()); exit(0); } 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?
|