I'm trying to use fetchall_array to store the results of a SELECT in a
2-dimensional array. It does the first while statement, but then does some
crazy things at the foreach loop. It sits there for a few minutes, then
starts endlessly looping, printing out the following error messages over and
over again:

Use of uninitialized value in array element at ./cvgroup.pl line 31.
Use of uninitialized value in array element at ./cvgroup.pl line 31.
Use of uninitialized value in array element at ./cvgroup.pl line 32.
Use of uninitialized value in array element at ./cvgroup.pl line 33.
Use of uninitialized value in array element at ./cvgroup.pl line 34.
Use of uninitialized value in array dereference at ./cvgroup.pl line 34.
Use of uninitialized value in concatenation (.) at ./cvgroup.pl line 67.
Use of uninitialized value in concatenation (.) at ./cvgroup.pl line 67.
Use of uninitialized value in concatenation (.) at ./cvgroup.pl line 75.
DBD::Pg::st execute failed: ERROR:  parser: parse error at or near "" at
../cvgroup.pl line 77.

Here is a snippet of code:
---------<snip>----------
## Populate array with list of Part Numbers, etc.

$sql = "SELECT mfg, type, size FROM conveyor";
$sth = $conn->prepare($sql);
$sth->execute();
$i = 0;
while (@row = $sth->fetchrow_array) {
  @{$col[$i]} = @row;
  print "@{$col[$i]}";
  $i++;
}

foreach $thing (@col) {
  if ($col[$thing][0] && $col[$thing][1]) {
    $mfg = @{$col[$thing][0]};
    $type = @{$col[$thing][1]};
    $size = @{$col->[$thing][2]};
    if ($size) {
    $size_n = $size;
    $size_n =~ s/^(\d)\.+(\d)/$1$2/g;
    $partno = $mfg_n . $type_n . $size_n;
    }
    else {
    $partno = $mfg_n . $type_n;
    }
    $sql = "UPDATE conveyor SET cvgroupid = '$partno' WHERE mfg = '$mfg' AND
type = '$type' AND size::float = $size";
    $sth = $conn->prepare($sql);
    $sth->execute();
  }
}

Reply via email to