TonyDonker has asked for the wisdom of the Perl Monks concerning the following question:

Hi!

When clicking on the first column (id) of my DBI-table I receive the following message:

"Use of initialized value in string eq at ../Table.pm line 294"

The source is:

$tkdbi = $view->DBITable( -sql => $sql_query, -dbh => $dbh, -display_id => 1, )->pack(expand => 0, -fill => 'both');


It only occurs when clicking (=sorting) on the first column.

Any ideas? - Thanks,

Ton

Replies are listed 'Best First'.
Re: uninitialized value in Tk::DBI::Table
by zentara (Cardinal) on Feb 16, 2005 at 14:20 UTC
    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
      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
Re: uninitialized value in Tk::DBI::Table
by runrig (Abbot) on Feb 16, 2005 at 18:08 UTC
    Tk::DBI::Table assumes the first column in a select statement is the id column, and when I select a date/time column as the first column (as you have), I get this error before the table shows up:
    parent element "1980-01-01 00:00:00" does not exist at C:/Perl/site/li +b/Tk.pm li ne 247. at C:/Perl/site/lib/Tk/Derived.pm line 469
    This is with Tk 800.24, Tk::DBI::Table 0.02, perl 5.8.4 (AS build 810).

    Update: After some mucking about, I found that the "." in the date/time string was messing up the $hlist->add($entryPath) method (the date/time being used as the entry path for the HList). The "." is truncatated from the string in the error message, because "." is the default path 'separator' for an HList.

      But can you sort the first column?
        I just found out, that you even't can't use DBI::Table, if 2 (or more) identical rows in your database...

        HELP!!!

        element "18-02-2005 09:45:10" already exists at E:/Perl/site/lib/Tk.pm line 228.

        at E:/Perl/site/lib/Tk/Derived.pm line 467