Inverse Data Type Mapping ?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Anachronox
Posts: 11
Joined: Sun 30 Mar 2014 11:53

Inverse Data Type Mapping ?

Post by Anachronox » Sun 19 Oct 2014 22:07

Hello,

I'm looking for some function for inverse data type mapping.

Instead of sql-type-to-field-type, I need to use field-type-to-sql-type function/mapping for specific provider.

I normally use parameters in query, but in case of "keyset paging” method on SQL Server I found that emitting of parameters as DECLARE is much faster way (in terms of query speed).

Is there some way to do that in UniDAC ?

Many thanks.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Inverse Data Type Mapping ?

Post by AlexP » Mon 20 Oct 2014 08:59

Hello,

Please describe the required functionality in more details and provide a small sample.

Anachronox
Posts: 11
Joined: Sun 30 Mar 2014 11:53

Re: Inverse Data Type Mapping ?

Post by Anachronox » Mon 20 Oct 2014 10:16

Hi Alex,

here is the example:

Code: Select all

var 
  ResultType: String;
  StringField: TStringField;
  IntegerField: TIntegerField;

function FieldTypeToSQL(Field: TField; ProviderName: String): String;
begin
  // Some magic
end;

begin
  ResultType := FieldTypeToSQL(StringField, 'SQL Server'); 
//ResultType = 'varchar(10)'

  ResultType := FieldTypeToSQL(IntegerField, 'SQL Server'); 
//ResultType = 'int'
end;

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Inverse Data Type Mapping ?

Post by AlexP » Mon 20 Oct 2014 10:52

There is no "easy" way to get Server types by Delphi types. You have to implement this functionality by yourself.

Anachronox
Posts: 11
Joined: Sun 30 Mar 2014 11:53

Re: Inverse Data Type Mapping ?

Post by Anachronox » Mon 20 Oct 2014 11:01

I'm sad, Alex :?

Does not help I've UniDAC source ?

Thank you.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Inverse Data Type Mapping ?

Post by AlexP » Tue 21 Oct 2014 07:40

We obtain types from the server as number constants and map them to internal types in the ConvertOLEDBTypeToInternalFormat method. Then, basing on the internal types, the Delphi types are generated. Therefore, there is no "simple" way to get real text names of server fields using Delphi field types.

CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

Re: Inverse Data Type Mapping ?

Post by CristianP » Tue 21 Oct 2014 12:01

I have something like this for SQL Server, MySQL, PostgreSQL and SQLite.
And I am sure there is not "one size fits all".

Post Reply