in reply to uninitialized value in Tk::DBI::Table

You will get that error alot as you go along, especially if you "use strict". You just need to tightenup the code. You don't give much code to go on, so I would guess that $sql_query or $dbh hasn't been initialized yet. Try putting
my $sql_query = ''; my $dbh = '';
before your code.(Don't wipe out your $dbh if it's already initialized.). Or try just printing them first.
print "$sql_query \t $dbh \n";
before your code , and see what you get.

P.S. Writing big apps involves ALOT of this type of debugging. Printing values at critical points, can help trace down errors.


I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: uninitialized value in Tk::DBI::Table
by TonyDonker (Novice) on Feb 16, 2005 at 15:08 UTC
    Hi zentara,

    I initialized $sql_query & $dbh, but it doesn't help me. The following below is a print of $sql_query and the message that is being generated when one clicks on first column:

    select cdate AS 'Creation Date/Time', case when statusType = '1' then 'Debug' when statusType = '2' then 'Info' when statusType = '3' then 'Warning' when statusType = '4' then 'Error' else 'unknown' end as Status, statusValue AS 'Description' from statusmessages order by cdate desc LIMIT 100


    Use of uninitialized value in string eq at E:/Perl/site/lib/Tk/DBI/Table.pm line 294.
    Use of uninitialized value in string eq at E:/Perl/site/lib/Tk/DBI/Table.pm line 294.
    Use of uninitialized value in string eq at E:/Perl/site/lib/Tk/DBI/Table.pm line 294.
    Use of uninitialized value in string eq at E:/Perl/site/lib/Tk/DBI/Table.pm line 294.


    Note that the message is being generated 4 times -> I click only 1 time...
      I think you just CAN'T sort the first column if you put:

      -display_id => 1,

      switch for displaying the index column...

      Is that right?
      Well I can barely feel my way around DBI stuff myself, and I've never used Tk::DBI::Table, so I really can't say what the glitch is. Maybe someone else knows. All I can tell you to do is this: try to get the simplest example possible which works the way you want. Then start adding the extras into it, until it fails, then try to sort out the reason. So maybe try a very simple $sql_query statement, and see if you can get it to work, like "select * from statusmessages" or whatever is the simplest. You probably have some syntax error in the $sql_query.

      Like for starters...you have

      when statusType = '1' then 'Debug'
      maybe that should be == (or eq) not = ; which is sort of hinted at in the error message 4 times....

      Use of uninitialized value in string eq

      = is for assignment

      == or eq is for testing equality

      You may need 'eq' if you quote your numbers.


      I'm not really a human, but I play one on earth. flash japh
        The '=' you are referring to is from a sql statement, not a perl statement, so it is for equality, not assignment.