Click to See Complete Forum and Search --> : Use of uninitialized value in concatenation (.) or string at


adeptz
07-21-2006, 10:44 PM
Ok everyone, first time PERL scripter here, although I have worked with many other languages. I was recently asked to help out a friend with his accounting scripts and for the life of me I cant seem to get this one damn script to compile I know this is a probably due to some miniscule little mistake on my behalf in the coding and thus have hit the net looking for assistance.

firstly I'll start off by stating, I know what that error means. but I cant see why this is not initializing my variable. The error related to the following lines of code.

my $query = "";
<ERROR HERE> $query = "SELECT chart.accno, chart.description, parts.income_accno_id
FROM invoice
WHERE invoice.trans_id = $acc_trans_id
AND parts.id = invoice.parts_id
AND chart.id = parts.income_accno_id
";

my $sth = $dbh->prepare($query);

$sth->execute;

if ($DBI::errstr) {
$dbh->disconnect;
exit 0;
}

here is the full error i receive when compiling with komodo
-Use of uninitialized value in concatenation (.) or string at line <ERROR>
-DBD::Pg::st execute failed: ERROR: syntax error at or near "AND" at character 104
-disconnect(DBI::db=HASH(0x21d2680)) invalidates 4 active statements. Either destroy statement handles or call finish on them before disconnecting.

this is only one part of my script, if anyone would care to help me out with this It would be greatly appreciated

I will attach a copy of my script incase anyone wants to try and compile it in its entirety

robertketter
07-23-2006, 03:37 PM
You can't use line returns in perl scripts. What I mean is your code has several lines with line returns...


my $query = "";
<ERROR HERE> $query = "SELECT chart.accno, chart.description, parts.income_accno_id
FROM invoice
WHERE invoice.trans_id = $acc_trans_id
AND parts.id = invoice.parts_id
AND chart.id = parts.income_accno_id
";

my $sth = $dbh->prepare($query);

$sth->execute;

if ($DBI::errstr) {
$dbh->disconnect;
exit 0;
}

here is the code with line returns removed...

my $query = "";
$query = "SELECT chart.accno, chart.description, parts.income_accno_id FROM invoice WHERE invoice.trans_id = $acc_trans_id AND parts.id = invoice.parts_id AND chart.id = parts.income_accno_id";
my $sth = $dbh->prepare($query);

$sth->execute;

if ($DBI::errstr) {
$dbh->disconnect;
exit 0;
}