PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: ct_describe produces surprising output
Date: Nov 25 1997 10:04PM

Ezra Van Everbroeck wrote:
> 
> On Tue, 25 Nov 1997, Craig Jackson wrote:
> 
> > >     max(length($colname)+2, $colsize+1)
> 
> > Looks like it's actually defined as "The number of characters ISQL should
> > reserve for printing this column"
> 
> Thanks a lot for the information. Is there some other way in which I can
> find out the maximum number of characters that can be put in a field? I want
> to use those values to automatically limit the length of input boxes on a
> web form - so, without having to hardcode these values into the program.

You can query the system tables.

Something like


my $ret = $dbh->ct_sql("
select c.name, t.name, c.length, c.prec, c.scale, 
       identity = convert(bit, (c.status & 0x80)) 
from   $physdb.dbo.syscolumns c, $physdb.dbo.systypes t 
where  c.id = object_id('$physdb.dbo.$table')
and    c.usertype *= t.usertype");

should give you all the info you need.

Michael
-- 
Michael Peppler       -||-  Data Migrations Inc.
mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler