Skip to Content.
Sympa Menu

freetds - Re: [freetds] dbcoltype() , char and nchar

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: LacaK <lacak AT zoznam.sk>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] dbcoltype() , char and nchar
  • Date: Tue, 21 Sep 2010 12:29:32 +0200


Only for explanation:
In FreePascal there are different Database Field Types
TStringField and TWideStringField, so my attempt was map
char, varchar to TStringField
nchar, nvarchar to TWideStringField (see http://docwiki.embarcadero.com/VCL/en/DB.TWideStringField )
(text to TMemoField, ntext to TWideMemoField)

I understand what you want to do.
Fine ;-) Thanks (I am not native speaker, so sometimes I have problems explain what I want)

Unfortunately it will be quite
difficult with db-lib, because FreeTDS intentionally conceals the server
column definition. It was a design decision -- maybe not the right one!
-- but it's very deep in the library.
As soon as UCS-2 data arrive from the server, they are immediately
converted to the client's encoding. The UCS-2 form is discarded.[1] To
provide UCS-2 data to FreePascall, you'll have to re-convert!
Yes, I can re-convert easy (UTF8 -> WideString), but as I wrote I must know original server's column type
When speaking about client encodings, there are supported: ISO-8859-1, UTF8, UCS2, arn't ?
Is there possibility obtain character data in current system Ansi (non-unicode) charset ?
(here I am speaking about Windows environment, I do not know nothing about other OS). In Windows there is for example WideCharToMultiByte(CP_ACP, ...)

Getting db-lib to report the server's type and size wouldn't be
particularly hard. The TDSCOLUMN structure has a nested on_server
structure with exactly that information. That structure could be
harmlessly added to the DBCOL structure filled by dbcolinfo(). I think if
you look at dbcolinfo() and dbcoltype(), you'll see what to do. Look at
tds_set_column_type() too.
Thanks. I understand, and I can do it for my own needs, but as I wrote, my FreePascal component will link to dblib.dll.
And I do not want provide specialized/modified/customized version of dblib.dll (so everybody can use=download and compile FreeTDS dblib.dll from www.freetds.org)
So if this functionality will not be included in main stream version of dblib, then I can not use it.

If you agree, that we can add this functionality in some way then I can try do it and post patch ... then please give me direction, which is the preffered method
(for example: extending DBCOL structure by adding:
SHORT ServerType (wType);
DBINT ServerMaxLength (wMaxLength);
-or-
adding new function dbcolwtype()?
-or-
modify existing FreeTDS-only function dbtablecolinfo() which will provide original server's column types?
)

TIA
-Laco.





Archive powered by MHonArc 2.6.24.

Top of Page