Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Datatype of fetch'ed columns using Perl-Sybase

by perl@1983 (Sexton)
on Jul 03, 2012 at 15:12 UTC ( #979731=perlquestion: print w/replies, xml ) Need Help??
perl@1983 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am generating an HTML page from a (Sybase) resultset of a select query (using latest versions of DBI and DBD::Sybase). In that, I am printing the column names, but along with column names, I also wanted to print the datatype and size of respective columns. Can someone please guide with regards to how can I get the datatypes and size of each column? I've gone through the DBI and DBD::Sybase + some online articles, but couldn't figure it out. Any pointers would be appreciated. Thanks in advance.
  • Comment on Datatype of fetch'ed columns using Perl-Sybase

Replies are listed 'Best First'.
Re: Datatype of fetch'ed columns using Perl-Sybase
by Corion (Pope) on Jul 03, 2012 at 15:18 UTC

    Have a look at the "catalog" functions of DBI. They return the database type of columns for a given query.

      Thanks for the quick reply Corion! I went through those functions and if I understood correctly, they would return the datatype as a number representing their ISO counerpart. Is it possible to see the actual Sybase datatype (instead of number)?

        You could certainly translate them yourself:

        First, create your translation table (ficticious data, of course):

        my %translation_table = ( 1=>"bool", 27=>"char", 13=>"dec", 34=>"nul", 55=>"etc...", );

        Then, using the value from catalog functions, select and then print (or say) the appropriate data-type-word to your output.

Re: Datatype of fetch'ed columns using Perl-Sybase
by erix (Parson) on Jul 03, 2012 at 16:37 UTC
Re: Datatype of fetch'ed columns using Perl-Sybase
by mpeppler (Vicar) on Jul 27, 2012 at 14:51 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://979731]
Approved by herveus
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2018-06-21 03:24 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.