What is the preferred format to save a GUID in Firebird 2.5 using UniDAC?
Is there a format that will return fields of type "ftGuid" or do I need my own Data Type Mapping?
How should the Data Type Mapping look like?
cu Christian
GUID in Firebird
Re: GUID in Firebird
To store GUID in Firebird, you can use the varchar data type. To retrieve fields of the "ftGuid" type, you can use Data Type Mapping.
For instance, to set mapping of a field with "GUID" name to the ftGUID type, use the following code:
More details about Data Type Mapping can be found at: http://www.devart.com/unidac/docs/index ... apping.htm
For instance, to set mapping of a field with "GUID" name to the ftGUID type, use the following code:
Code: Select all
UniTable1.DataTypeMap.AddFieldNameRule('GUID',ftGuid);-
chkaufmann
- Posts: 82
- Joined: Sat 01 Jul 2006 11:42
Re: GUID in Firebird
Meanwhile I tried to setup a guid for Oracle. The common data type here seems to be RAW(16).
There are different problems now:
Same question for Firebird because the default TGuidField class is based on TStringField and uses a 38 character representation. 32 characters would be far enough.
Or did already somebody "unify" the GUID handling for all databases (Firebird, Oracle, MySql, PostgreSQL, MS SQL Server)?
cu Christian
There are different problems now:
- The column type RAW(16) is returned as TVarBinaryField and I did not succeed to make a mapping to ftGuid.
- Even if I read this column using "AsBytes" it's converted to a variant "array of byte" and I remember from an earlier project that this is terrible slow.
Same question for Firebird because the default TGuidField class is based on TStringField and uses a 38 character representation. 32 characters would be far enough.
Or did already somebody "unify" the GUID handling for all databases (Firebird, Oracle, MySql, PostgreSQL, MS SQL Server)?
cu Christian
Re: GUID in Firebird
Hello,
Currently, you can map the type in the query using the RAWTOHEX Oracle function:
In this case, in Delphi the field will be mapped as ftString. We have added mapping from Raw to ftGuid, This feature will be included in the next version.
Yes, TGuidField uses 38 symbols, therefore use varchar(38) fields for storing GUID in Firebird.
Currently, you can map the type in the query using the RAWTOHEX Oracle function:
Code: Select all
SELECT RAWTOHEX(f_fuid) FROM t_tableYes, TGuidField uses 38 symbols, therefore use varchar(38) fields for storing GUID in Firebird.
-
chkaufmann
- Posts: 82
- Joined: Sat 01 Jul 2006 11:42
Re: GUID in Firebird
I did some more research and tests. Finally I use the following data types for GUID's:
MS SQL Server: UNIQUEIDENTIFIER
Oracle: RAW(16)
Firebird: CHAR(16) CHARACTER SET OCTETS
For Firebird I found a post in the dev newsgroups where this was described as the data type that will be used, if native support for guid will be added to Firebird.
Performance with "AsBytes" (Firebird, Oracle) isn't that bad at all. For now I handle the "unification" in my own wrapper classes, but of course it would be nice to have this in UniDac. But for real full integration I see limitations coming from Delphi:
- TVarRec.VType doesn't have/support a "vtGuid"
- The base class TField has no AsGuid property
cu Christian
MS SQL Server: UNIQUEIDENTIFIER
Oracle: RAW(16)
Firebird: CHAR(16) CHARACTER SET OCTETS
For Firebird I found a post in the dev newsgroups where this was described as the data type that will be used, if native support for guid will be added to Firebird.
Performance with "AsBytes" (Firebird, Oracle) isn't that bad at all. For now I handle the "unification" in my own wrapper classes, but of course it would be nice to have this in UniDac. But for real full integration I see limitations coming from Delphi:
- TVarRec.VType doesn't have/support a "vtGuid"
- The base class TField has no AsGuid property
cu Christian