More Info / SHOW COLUMNS ISSUE

I realize this might be considered a "new topic," and as such, should be its own entry, but since I am working through the task described in the initial message, I thought it would be good to at least start this message here.

So... while plugging away at my own solution, I have found an issue with trying to execute either a "DESCRIBE $table" or "SHOW COLUMNS FROM $table" command. Here is an extracted snippet of code:

my $rval = ''; my $sth2 = $dbh->prepare("SHOW COLUMNS FROM $table"); $sth2->execute() or die 'execute failed'; if ( $sth2->err ) { $rval = 'error: [' . $sth2->errstr . ']'; } else { # the "while" line is #151 from the error message... while ( my @arr = $sth2->fetchrow_arrayref() ) { $rval .= '[' . join('|', @arr ) . ']'; } }

At this point, I am simply trying to gather ANYTHING from the command, so, yes, $rval will not have anything truly meaningful in this example.

What I am getting is an unending stream of:

[Tue Jun 18 10:48:43 2013] [error] [client 10.22.50.24] DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at /var/www/cgi-bin/CaMS2/TableEdit.pm line 151., referer: http://10.22.50.14/CaMS2/index.cgi

I don't need to know how to get a list of column names -- I already have that working. I want "the rest of the story" -- the Type, Null, and Default columns for sure.

mysql> show columns from cmsParms; +--------+-----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-----------+------+-----+---------+-------+ | pKey | char(100) | NO | PRI | NULL | | | pValue | text | NO | | NULL | | +--------+-----------+------+-----+---------+-------+ 2 rows in set (0.01 sec)

So that's my current issue. I'm currently hacking at it. When I get a solution, I'll post it here. If, however, anyone has already crossed this bridge, and can toss me some hints/tips/tricks/etc, I would greatly appreciate it!!!

Lee Crites
lee@critesclan.com

In reply to Re: Replacement for/working version of CGI::App::Plugin::BREAD ??? by lee_crites
in thread Replacement for/working version of CGI::App::Plugin::BREAD ??? by lee_crites

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.