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

Esteemed monks,

I know this module is very new. I installed it in my ActiveState Perl 5.8.0 build 804. I used the following code against a MySQL tbale on my local machine which is perfectly okay.

sub doDBItable { my $top = MainWindow->new; my $tkdbi = $top->DBITable ( -sql => 'select * from user', -dbh => $dbh, -display_id => 1, -debug => 1,)->pack(expand => 1, -fill => 'both'); }
This sub is invoked from a menu selection, I just grafted this part into another job I am owkring on to test it. Rsulting in this error response on STDOUT:
Tk::Error: element "J" already exists at K:/Perl/site/lib/Tk.pm line 2 +28. at K:/Perl/site/lib/Tk/Derived.pm line 467 [\&main::doDBItable] (menu invoke)
The empty eindow displays and that is the last of it. The "J" referred to in the error could easily be a value in the first field of a record. There are 3 out of 5 records all have "J" as the first field.

Any ideas? ...john

Replies are listed 'Best First'.
Re: Tk::DBI::Table problem, is it me or a bug??
by Courage (Parson) on Aug 07, 2003 at 10:48 UTC
    Indeed that module is too buggy yet.

    As RTFSing shows, code inserts an element into HList and "item path" equals to first field, but rather should be incremented.

    What if you'll try displaying rows where first column is different in each row? Are things any different?

    If yes, then I'll advice you to change that module to autoincrement first column starting from, say, "00000".
    Otherwise currently I'm out of advices, but feel free to ask further :)

    Courage, the Cowardly Dog

      Thanks Courage

      I assume that RTFSing is reading the f... Source. If that is true then I have to admit that is something I did not do. I got this back from the developer, confirming what you said:

      Good Morning John, you need a first field with a unique content to adress a row for the c +ommand callback. Ok, here a little trick: sub doDBItable { my $top = MainWindow->new; my $tkdbi = $top->DBITable ( -sql => 'select CONCAT(name,pseudonym,age),* from user', -dbh => $dbh, -display_id => 0, # --- dont display the merged id! -debug => 1,)->pack(expand => 1, -fill => 'both'); } I hope this helps.
      I then modified my sql to include the 'id' which is a unique autoincremented value - it worked. It might be buggy, but heck, if I can use this module then it will really save my bacon on a Windows job I have in hand right now.

      Thanks for your help, I will go and look at the source when this job is out of the way.

      ...john

        Polite people spell RTFS as "Read This *Fine* Sources".

        At least it is how I spell it for me once I saw this somewhere on www.perl.org site...
        :)

        Courage, the Cowardly Dog