Go Back   CodingForums.com > :: Server side development > Perl/ CGI

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-22-2006, 03:44 AM   PM User | #1
adeptz
New to the CF scene

 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
adeptz is an unknown quantity at this point
Use of uninitialized value in concatenation (.) or string at

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
adeptz is offline   Reply With Quote
Old 07-22-2006, 04:31 AM   PM User | #2
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,757
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
Quote:
Use of uninitialized value in concatenation (.) or string
That is most likely comming from $acc_trans_id not beeing assigned. Are you sure it's been assigned a value prior to this statement?

Also, you should add quotes around the values of the where clause.

Code:
$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'";
You should also rework your error handling so that it doesn't give you
Quote:
-disconnect(DBI::db=HASH(0x21d2680)) invalidates 4 active statements. Either destroy statement handles or call finish on them before disconnecting.
FishMonger is offline   Reply With Quote
Old 07-22-2006, 04:40 AM   PM User | #3
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,757
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
Personaly, I've never liked the style of assigning the select statement to a var, when it's just as easy to put it directly into the prepare statement. This is the style that I normally use.
Code:
my $sth = $dbh->prepare("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'");
FishMonger is offline   Reply With Quote
Old 12-01-2011, 08:32 AM   PM User | #4
nmehta
New to the CF scene

 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
nmehta is an unknown quantity at this point
Same error while running perl script.

Use of uninitialized value in concatenation (.) or string
hI

i am running a perl script which is big enough to post here,but i will post the part which throws error.

I am trying to retrieve rows through an sql query.



#--------------script--------------------

#4.1.Finding job sets id
print("\nFinding job sets id from table jobs..\n");
$sql =<<"EOF";
select job_id from moose.jobs
where parent_id = '$job_app'
EOF

debug("SQL>$sql", 2);
$s = $db->prepare($sql);
$s->execute();
while (@row = $s->fetchrow_array){
print join(",",@row),"\n";
$jobs = join(",",@row);
print("jobs = $jobs");
}



Now when I run this script,it gives the following error :

Finding job sets id from table jobs..
Use of uninitialized value in concatenation (.) or string at ./removeMooseBuild_dev_nidhi.pl line 340.
Use of uninitialized value in concatenation (.) or string at ./removeMooseBuild_dev_nidhi.pl line 340.
Use of uninitialized value in concatenation (.) or string at ./removeMooseBuild_dev_nidhi.pl line 340.
Use of uninitialized value in concatenation (.) or string at ./removeMooseBuild_dev_nidhi.pl line 340.
Use of uninitialized value in concatenation (.) or string at ./removeMooseBuild_dev_nidhi.pl line 340.
Use of uninitialized value in concatenation (.) or string at ./removeMooseBuild_dev_nidhi.pl line 340.
Use of uninitialized value in array element at ./removeMooseBuild_dev_nidhi.pl line 340.
Use of uninitialized value in concatenation (.) or string at ./removeMooseBuild_dev_nidhi.pl line 340.
Use of uninitialized value in concatenation (.) or string at ./removeMooseBuild_dev_nidhi.pl line 340.
Use of uninitialized value in array dereference at ./removeMooseBuild_dev_nidhi.pl line 340.
SQL> select job_id from moose.jobs
where parent_id = 1385279
EOF

debug("SQL> select job_id from moose.jobs
where schedule_id = '1385277'
", 2);
DBI::st=HASH(0x51f588) = DBI::db=HASH(0x35cd58)->prepare( select job_id from moose.jobs
where schedule_id = '1385277'
);
DBI::st=HASH(0x51f588)->execute();
....and so on..


Ideally the query returns three rows with a single column integer value in each row such as :
80
84
92

Also,$job_app is not null..can you please help me out with the possible mistake i am making..?
nmehta is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:59 AM.


Advertisement
Log in to turn off these ads.