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

Forgive me if this is a stupid question. I do something with perl and mysql. When i create a table in my database( just create structure, i dont insert any record into this table). In perl script, i use Net::MySQL(and i try with DBI::mysqlPP too) execute a query(select or insert,...). And my perl page not response when i run! But when i use phpmyadmin to insert two record (with one record in that table it doesn't work) into that table, i run my page again and it work!!! It mean all my page only work with mysql tables when those tables have greater than two record!! lol I dont understand why perl cant execute a query with a null table.

Replies are listed 'Best First'.
Re: Perl cant connect to null mysql table
by Corion (Patriarch) on Jun 06, 2009 at 13:57 UTC

    WIthout seeing either your (relevant, short) Perl code nor the SQL you're issuing against your table, it's hard to tell what the actual problem might be. Also, the contents of your webserver error log might help us help you better by giving us some more diagnostics.

      Sorry! This is some test code. If the table dont have any data, this sub doesn't work, my perl page is not response anything, my browser => "Waiting for localhost..." forever !!! So i cant see any error.
      sub checkGroupExist { eval{$mysql=Net::MySQL->new(hostname=>"localhost",database=>"check +k",user=>"root",password=>"pw")}; my ($grname)=@_; if(!$@) { $mysql->query(qq{Select GROUP_NAME from PROJECT_GROUP where GR +OUP_NAME='$grname'}); my $record_set=$mysql->create_record_iterator(); my $record=$record_set->each(); if($record) { return 1; } $mysql->close(); } else { print qq{Can't connect to database. Check your config in 'conf +ig.pl'}; exit; } return 0; }
      I see when a perl page run in the browser, there is a program 'perl.exe' in my Window Task Manager. The page load completely and this programe disappear.
      With my error, is see in my Task Manager have a task with name 'perl.exe' and it's never disappear. I refresh the page and i have one more!!!

        Maybe you should remove the CGI part then, and debug the SQL part alone. I don't see anything obvious why your code should fail or enter a long loop. But as you haven't shown a self-contained example, it's hard to tell.