UNIDAC and FireBird3

Hi,

I'm using unidac to connect to a Firebird3 Database, when inserting a row on a table with a Identity ID field I get a "List Index out of bound error" on procedure "TInserter.Insert" on Line "NewId := ResultSet.GetFieldValue(0);" 

I have tested using FireDac and it works ok.

Is this a Unidac bug or should I have to set some adittional param or setting on the unidac connection component to make it work ok with firebird3?

Thanks in advance,

Omar Zelaya
Hi,

This is the SQL generated by Aurelius:

INSERT INTO SISTEMA_EVENTOS (FECHA, EVENTO, ID_USUARIO, ID_TIPO) VALUES (:A_FECHA, :A_EVENTO, :A_ID_USUARIO, :A_ID_TIPO) RETURNING ID

I have noticed that TUniQuery returns the ID Value as a parameter not as Field Value as FireDac.

Any hint

Thanks in advance,

Omar Zelaya
Hello Omar,

Indeed, Unidac plus Firebird 3 is not a valid combination with Aurelius due to that Unidac behavior. Maybe you can contact Devart asking them if there is a configuration that returns such values as fields instead of params?

Hi,
This was DevArt response:
This is a standard behavior of our components, which our users have been using for many years and its change will affect them all. And that's why we cannot change this behavior.

Thanks in advance.

Omar Zelaya
Hi,

This was a second response form DevArt.
As TMS Aurelius specifies UniDac support: https://tmssoftware.com/site/aurelius.asp, then to solve your task, it's better to contact TMS Aurelius technical support, in order for them to fix this incompatibility. As UniDAC always automatically creates parameters with RET_ prefix for the fields specified after RETURNING

Thanks in advance,
Omar Zelaya


There is a quick and dirty workaround you can use. You can replace the following code in Aurelius.Drivers.Unidac.pas (or just copy that unit and create your own Aurelius.Drivers.MyUnidac.pas:



  TUniDacResultSetAdapter = class(TDriverResultSetAdapter<TCustomDADataset>)
  public
    function GetFieldValue(FieldIndex: Integer): Variant; override;
  end;


and then the implementation:



function TUniDacResultSetAdapter.GetFieldValue(FieldIndex: Integer): Variant;
begin
  if Dataset.FieldCount > 0 then
    Result := inherited GetFieldValue(FieldIndex)
  else
    Result := Dataset.ParamByName('RET_ID').Value;
end;

Hi,

Thanks.