Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: How do you get Perl::DBI to do a desc table_name?

by lachoy (Parson)
on Mar 28, 2002 at 13:23 UTC ( [id://154949]=note: print w/replies, xml ) Need Help??


in reply to Re: How do you get Perl::DBI to do a desc table_name?
in thread How do you get Perl::DBI to do a desc table_name?

Two minor notes:

First, you might want to be careful about the values returned by $sth->{NAME} if you care about case-sensitivity. The DBI doesn't make them consistent or modify them at all -- they're whatever the database returns. And what the database returns can be vendor specific. The NAME_uc and NAME_lc properties do what you'd expect.

Second, I think the integer values returned from $sth->{TYPE} correspond to the DBI SQL type constants. So you can do:

use DBI qw( :sql_types ); ... my $types = $sth->{TYPE}; foreach my $type ( @{ $types } ) { print "VARCHAR" if ( $type == SQL_VARCHAR ); print "DATETIME" if ( $type == SQL_DATETIME ); print "BOOLEAN" if ( $type == SQL_BIT ); print "FLOAT" if ( $type == SQL_FLOAT ); ... }

Conveniently, most of them also map to the ODBC CLI specifications. :-)

You can find the type-to-constant mapping in the 'dbi_sql.h' header file found in your architecture-dependent perl library tree -- for example, mine is in site_perl/5.6.1/i686-linux/auto/DBI/dbi_sql.h

Chris
M-x auto-bs-mode

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://154949]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found