What are the most common reasons that I would be getting this error from running a Perl script:
Memory fault(coredump)
I am running two SQL commands beforehand that only store ~1500 rows each with 6 fields. The SQL works fine out of the script, so I don’t think I’m getting the error from that. And half of my code runs before it takes a bomb and gives me that error.
So what are the most common reasons for this error and what might my reason be?
EDIT – heres the code that works
my $i; $i = 0; while ($DBS->SQLFetch() == *PLibdata::RET_OK) { while ($i != $colnamelen) { if ($i == 1) { $rowfetch = $DBS->{Row}->GetCharValue($colname[$i]); $rowfetch =~ s/(?=..$)/:/; printline($rowfetch); $i++; } if ($i == 2) { $rowfetch = $DBS->{Row}->GetCharValue($colname[$i]); $rowfetch =~ s/(?=..$)/:/; printline($rowfetch); $i++; } if ($i == 10) { $rowfetch = $DBS->{Row}->GetCharValue('meetdays'); $rowfetch =~ s/-//gi; printline($rowfetch); $i++; } if ($i == 12) { $rowfetch = $DBS->{Row}->GetCharValue('fullname'); my ($lname, $fname) = split /,\s*/, $rowfetch; $rowfetch = $fname; printline($rowfetch); $rowfetch = $lname; printline($rowfetch); $i=$i+2; } else { $rowfetch = $DBS->{Row}->GetCharValue($colname[$i]); printline($rowfetch); $i++; } } $i=0; printf $fh '\n'; }
Heres the code that doesnt work – All that was done was optimizing the sql fetch command
my $i; $i = 0; while ($DBS->SQLFetch() == *PLibdata::RET_OK) { while ($i != $colnamelen) { $rowfetch = $DBS->{Row}->GetCharValue($colname[$i]); if ($i == 1) { $rowfetch =~ s/(?=..$)/:/; printline($rowfetch); $i++; } if ($i == 2) { $rowfetch =~ s/(?=..$)/:/; printline($rowfetch); $i++; } if ($i == 10) { $rowfetch =~ s/-//gi; printline($rowfetch); $i++; } if ($i == 12) { my ($lname, $fname) = split /,\s*/, $rowfetch; $rowfetch = $fname; printline($rowfetch); $rowfetch = $lname; printline($rowfetch); $i=$i+2; } else { printline($rowfetch); $i++; } } $i=0; printf $fh '\n'; }
Oh and by the way, there is a functioning SQL statement before this while loop goes into action.. I just didnt want to waste space.
Before the code change, you called GetCharValue after checking if $i was as value you wanted. After the change, you call it even if it’s not 1,2,10,12. Is it possible that the values for $i other than those 4 is causing the issue?