#1 2012-08-31 13:47:39

Bascy
Member
From: The Netherlands
Registered: 2012-06-22
Posts: 108

"Unknown type 101" error when declaring a double property with Oracle

I have declared the following class:

  TSQLUnitTestSampleRecord = class(TSQLRecord)
  private
    fQuestion: string;
    fName: string;
    fTime: TModTime;
    FAddress: string;
    fPostal: string;
    FCity: string;
    FDatum: TDatetime;
    FFloatNumber: double;
    FIntNumber: Int64;
    FCurNumber: Currency;
  published
    property ModTime: TModTime read fTime write fTime;
    property Name: string index 50 read fName write fName;
    property Question: string index 50 read fQuestion write fQuestion;
    property Address_: string index 50 read FAddress write fAddress;
    property PostalCode: string index 12 read fPostal write fPostal;
    property City: string index 50 read FCity write FCity;
    property Datum: TDatetime read FDatum write FDatum;
    property FloatNumber: double read FFloatNumber write FFloatNumber;
    property IntNumber: Int64 read FIntNumber write FIntNumber;
    property CurrencyNumber: Currency read FCurNumber write FCurNumber;
  end;

When i use this class in an oracle 11g environment, executing CresateMissingTables results in the following error:

ESQLDBOracle exception, with message 'Column "FLOATNUMBER": unknown type 101'

If i change the DB_FIELDS definition for Oracle to contain FLOAT in stead of BINARY_DOUBLE everything works find:

const
  /// the known column data types corresponding to our TSQLDBFieldType types
  // - will be used e.g. for TSQLDBConnectionProperties.SQLFieldCreate()
  DB_FIELDS: array[TSQLDBDefinition] of TSQLDBFieldTypeDefinition = (
  // ftNull, ftInt64, ftDouble, ftCurrency, ftDate, ftUTF8, ftBlob
  (' NVARCHAR(%)',' BIGINT',' DOUBLE',' NUMERIC(19,4)',' TIMESTAMP',' CLOB',' BLOB'),
  (' NVARCHAR(%)',' BIGINT',' DOUBLE',' NUMERIC(19,4)',' TIMESTAMP',' CLOB',' BLOB'),
  (' NVARCHAR2(%)',' NUMBER(22,0)',' FLOAT',' NUMBER(19,4)',' DATE',' NCLOB',' BLOB'),  //Oracle , changed BINARY_DOUBLE into FLOAT

Offline

#2 2012-08-31 15:22:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: "Unknown type 101" error when declaring a double property with Oracle

BINARY_DOUBLE is available since Oracle 10g, and is better to be used than FLOAT.
See http://www.oracle-base.com/articles/10g … oint_types
This type uses machine arithmetic and requires less storage space, both of which make them more efficient than the NUMBER type.

There was an issue when retrieving the column type.
Should be fixed by http://synopse.info/fossil/info/0405d6e3fb and http://synopse.info/fossil/info/0405d6e3fb

By the way, in your code, especially in your TSQLRecord field definition, you should better use RawUTF8 instead of String, unless you have an Unicode version of Delphi.
RawUTF8 is the native data type for TEXT for the ORM.
Using RawUTF8 will avoid most invisible conversions added by the compiler when working with plain string type in your code.
See the corresponding paragraphs in the framework documentation.

Thanks for the feedback.

Offline

Board footer

Powered by FluxBB