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.
Inverse Data Type Mapping ?
Re: Inverse Data Type Mapping ?
Hello,
Please describe the required functionality in more details and provide a small sample.
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 ?
Hi Alex,
here is the example:
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;
Re: Inverse Data Type Mapping ?
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 ?
I'm sad, Alex 
Does not help I've UniDAC source ?
Thank you.
Does not help I've UniDAC source ?
Thank you.
Re: Inverse Data Type Mapping ?
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.
Re: Inverse Data Type Mapping ?
I have something like this for SQL Server, MySQL, PostgreSQL and SQLite.
And I am sure there is not "one size fits all".
And I am sure there is not "one size fits all".