Skip to Content.
Sympa Menu

freetds - Re: [freetds] Determining buffer size when retrieving data

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Michael Peppler <mpeppler AT peppler.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Determining buffer size when retrieving data
  • Date: Sun, 15 Aug 2004 08:32:00 +0200

On Sun, 2004-08-15 at 01:29, Magnus Bäck wrote:
> Is there a way to determine what destination buffer size is required
> when using dbdata()/dbconvert() or dbbind() to retrieve and convert
> column data of any type to string form? If not an exact number of bytes,
> at least a worst-case figure? Because with newer protocol versions,
> a CHAR or VARCHAR can hold >255 characters, yes? Trial-and-error with
> increasing buffer size is of course always available, but it'd be nice
> to avoid that method.

dbdatlen() should return the size of the buffer that dbdata() points to.

It of course does NOT return the size of the corresponding char buffer
needed if you convert a non char datatype to char. The DBD::Sybase and
Sybase::CTlib source has a function called display_dlen() (I think) that
I borrowed (stole ;-) from somewhere else (might be sqsh, or more likely
the Sybase samples) that returns maximum lengths for most datatypes.

Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler AT peppler.org http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or long term contract positions - http://www.peppler.org/resume.html





Archive powered by MHonArc 2.6.24.

Top of Page