EDatabaseError, expecting: FMTBcdField actual: BCD

EDatabaseError, expecting: FMTBcdField actual: BCD

Postby Francesco » Tue 08 Feb 2011 12:05

Hello,

I am using dbexpoda.dll 4.70.0.23 (trial version), cppbuilder 6, Oracle11g.
I have a TSQLQuery, a DataSetProvider and a ClientDataSet. TSQLQuery implements a simple query on a table. The table has a field, AFIELD, which is type "NUMBER(6)". The ClientDataSet has some persistent fields, one of them refer to AFIELD and is FMTBCD type.
When I open the ClientDataSet I got the error "EDatabaseError with message 'myClientDataSet: Type mismatch for field 'AFIELD', expecting: FMTBcdField actual: BCD'.". With no persistent fields in 'myClientDataSet' I get no error. What am I doing wrong? Thanks in advance.

Francesco
Last edited by Francesco on Tue 08 Feb 2011 16:03, edited 1 time in total.
Francesco
 
Posts: 9
Joined: Thu 20 Jan 2011 16:33

Postby Francesco » Tue 08 Feb 2011 15:59

If I try to change AFIELD type from FMTBCD to BCD I get the following error:
Size mismatch for field 'AFIELD', expecting: 4 actual: 0.

Francesco
Francesco
 
Posts: 9
Joined: Thu 20 Jan 2011 16:33

Postby bork » Wed 09 Feb 2011 14:00

Hello

Try removing all persistent fields from DataSetProvider and ClientDataSet, and then try opening your query again. This problem can occur if the type of your persistent field is not equal to the data type of the fields in the database.
bork
Devart Team
 
Posts: 643
Joined: Fri 12 Mar 2010 07:55

Postby Francesco » Wed 09 Feb 2011 16:21

I did it. I remove all the persistent fields (they were in the clientdataset). When I open the clientdataset it works.
I also disabled BCD feature and changed fields type in float and integer. With the feature disabled it works with persistent fields (float and integer instead of FMTBCD and BCD) too.

Francesco
Francesco
 
Posts: 9
Joined: Thu 20 Jan 2011 16:33

Postby bork » Fri 11 Feb 2011 10:15

Hello

If you want to use BCD fields you cannot replace a TFloatField persistent field by a TBCDField persistent field or a TFMTBCDField persistent field. Any field only displays data that is stored inside a DataSet. If format of stored data and your persistent field is not equal then you will get an error on attempt to open DataSet.

To define how database data will stored inside a DataSet you should use the following parameters (they are described in the ReadMe.html file that is located in the folder, where your dbExpress driver was installed):
EnableBCD - enable or disable BCD using
BCDPrecision - define format Oracle NUMBER in the DataSet: BCD or Float

I created a new table with a NUMBER(6) field. With default params (I specify Server, UserName and Password only) TBCDField was created for a field with NUMBER(6) data type:

Code: Select all
begin
  SQLConnection1.Open;

  try
    SQLConnection1.Execute('DROP TABLE test_table', nil);
  except
  end;

  SQLConnection1.Execute('CREATE TABLE test_table ( ' +
                         '  ID NUMBER, ' + #13 +
                         '  NAME VARCHAR2(50) NOT NULL, ' + #13 +
                         '  VALUE NUMBER(6), ' + #13 +
                         '  CONSTRAINT PK_test_table PRIMARY KEY (ID))', nil);

  SQLQuery1.SQL.Text := 'select * from test_table';
  SQLQuery1.Open;
  ClientDataSet1.Open;
  ShowMessage(ClientDataSet1.FieldByname('VALUE').ClassName);
end;


Please try this code with a new TSQLConnection where any parameters wasn't changed from default values.
bork
Devart Team
 
Posts: 643
Joined: Fri 12 Mar 2010 07:55


Return to dbExpress driver for Oracle