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

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
[Eily]: Discipulus I like chiocciola :D
[Discipulus]: to eat, no? grin
[Eily]: hu, don't tell the other French people I never tried it, I might get kicked out :P
choroba . o O ( The Czech at-sign is also edible )

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2017-11-21 10:49 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (297 votes). Check out past polls.