Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    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
    -disconnect(DBI::db=HASH(0x21d2680)) invalidates 4 active statements. Either destroy statement handles or call finish on them before disconnecting.

  • #3
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    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'");

  • #4
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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..?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •