Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

After two days of reading the CPAN doc on DBI and saying to myself "I KNOW it's here somewhere", I have to ask for help.

The following, I believe, retrieves *all* available metadata info for each column, and puts it into an array:

# Get all columns for each table of interest # my $sth_column_info = $dbh->column_info( $catalog, $schema, $table, undef ); my $aoa_ref = $sth_column_info->fetchall_arrayref; $tables{$table} = $aoa_ref; # Debugging only... # say $table; for my $aref (@$aoa_ref) { my @list = map $_ // 'undef', @$aref; say join '|', @list; }
Here is some sample output:
dw_contact_source undef|dwcust1|dw_contact_source|contact_id|4|BIGINT|20|undef|undef|10| +0|undef|undef|4|undef|undef|1|NO|undef|undef|undef|undef|undef|undef| +undef|undef|undef|undef|undef|undef|undef|undef|undef|undef|undef|und +ef|1|bigint(20)|undef|0 undef|dwcust1|dw_contact_source|company_id|4|SMALLINT|6|undef|undef|10 +|0|undef|undef|4|undef|undef|2|NO|undef|undef|undef|undef|undef|undef +|undef|undef|undef|undef|undef|undef|undef|undef|undef|undef|undef|un +def|1|smallint(6)|undef|0 undef|dwcust1|dw_contact_source|contact_type_id|4|TINYINT|4|undef|unde +f|10|0|undef|undef|4|undef|undef|3|NO|undef|undef|undef|undef|undef|u +ndef|undef|undef|undef|undef|undef|undef|undef|undef|undef|undef|unde +f|undef||tinyint(4)|undef|0 undef|dwcust1|dw_contact_source|insert_date|11|DATETIME|19|undef|0|und +ef|0|undef|undef|9|-79|undef|4|NO|undef|undef|undef|undef|undef|undef +|undef|undef|undef|undef|undef|undef|undef|undef|undef|undef|undef|un +def||datetime|undef|0 undef|dwcust1|dw_contact_source|update_date|11|DATETIME|19|undef|0|und +ef|0|undef|undef|9|-79|undef|5|NO|undef|undef|undef|undef|undef|undef +|undef|undef|undef|undef|undef|undef|undef|undef|undef|undef|undef|un +def||datetime|undef|0

My questions are:

* Where is each field documented?

* Where is a list of translations for the codes appearing in some fields?

* Are there any helpful constants or other symbols anywhere, for referring to the columns and the codes within?

* If there *are* helpful symbols identifying these various fields, how can I use them in a call to fetchall_arrayref? (I tried fetchall_arrayref(qw/COLUMN_NAME .../), choosing some symbol-like strings from the documentation, but only got back undefs.)

I'd be very grateful if someone could help me move past this point of complete frustration!

In reply to DBI: interpreting column_info() by ibm1620

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!
  • 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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (8)
    As of 2015-07-03 18:19 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (55 votes), past polls