Re: GetColAtrribute() with SQL_DESC_OCTET_LENGTH parameter
From: Robert Sundström (robert_at_nnoossppaamm.mimer.se)
Date: 06/04/04
- Previous message: Ryan: "Unicode text shows up as '?' in CDBVariant object"
- In reply to: Ritesh: "GetColAtrribute() with SQL_DESC_OCTET_LENGTH parameter"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 04 Jun 2004 09:53:43 +0200
On Sun, 30 May 2004 21:06:03 -0700, Ritesh <riteshp@ihatespam.webyog.com>
wrote:
> In my application, I am connecting to various RBDMS but primarily SQL
> Server and MySQL using ODBC 3.0 driver. In SQL Server, if I execute
> SQLCollAtrribute with SQL_DESC_OCTET_LENGTH, it is returning me the
> maximum number of bytes that the column can have irrespective of whether
> the column in the resultset has that much data or not.
>
> Whereas, the MySQL ODBC driver is returning the maximum data that a
> column has for that particular resultset.
>
> Why is the anomaly? Does this information differ from driver to driver.
Both products probably return correct values as long as it is the case
that no string value ever returned on the column is longer than what
SQL_DESC_OCTET_LENGTH has specified. Note that this has nothing to do with
the underlying table column. For instance, if you do:
create table A(C1 character varying(50))
select substring(C1 from 40) from A
In this particular case, no column value will ever be longer than 10
characters, and the value of SQL_DESC_OCTET_LENGTH might reflect that.
> Is there any way to know the size of a perticular row in raw-bytes
> before doing an SQLFetch(). I would like to allocate the memory before I
> do SQLFetch(). Looking into Google Groups it seems that many people have
> the same problem but not much solution has been provided.
Don't bind the column and use SQLGetData to obtain the column value.
SQLGetData always return the number bytes left to return (StrLen_or_Ind
parameter). So, start calling SQLGetData with a buffer length of 0, and
you'll get the size of the data in wherever StrLen_or_Ind is pointing at.
> What is the best way to know how much bytes the RDBMS takes in the disk
> to store that much information?
No. That cannot be done using the ODBC API.
-- Robert Sundström, Mimer SQL Development Mimer Information Technology AB, http://www.mimer.com Validate your SQL statements/procedures at http://developer.mimer.com/parser
- Previous message: Ryan: "Unicode text shows up as '?' in CDBVariant object"
- In reply to: Ritesh: "GetColAtrribute() with SQL_DESC_OCTET_LENGTH parameter"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|