Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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 (Vicar) 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://979731]
Approved by herveus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-07-07 23:04 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 (93 votes), past polls