Firebird infos

This page provides information about the "specialities" when using NEO with Firebird.

Datatypes:

BIT
Firbird doesn't have the BIT datatype which SQL Server provides. If one wants to use BIT with Firebird you have to create SMALLINT (INTEGER should work too) in the Firebird database. Therefore it's a good idea to modify the SQL creation template to "map" BIT to SMALLINT.

DATE, DATETIME
Firebird doesn't have the DATETIME datatype. If date and time must be stored one should therefore use TIMESTAMP in Firebird. Here again it's a good idea to modify the SQL creation template to do the "mapping". If one only wants to store the date, it is obviously also possible to use DATE datatype of Firebird.

Mimic IDENTITY columns:

The NEO Firebird provider has an inbuilt "feature" to mimic the IDENTITY columns of SQL Server. Thererfore one has to create a trigger for each table that use "native" as idMethod.
The needed triggers can be created automatically via templates.
For example the following code can be added to the SQL creation template:

#foreach($entity in $Neo.Model.Entities)
#if($entity.IdMethod.ToString == "Native" && $entity.PkColumns.Count == 1)
#foreach($PkColumn in $entity.PkColumns)
#set ($autoIDColumnName = $PkColumn.ColumnName)
#end
CREATE TRIGGER ${entity.TableName}_trigger FOR "$entity.TableName" BEFORE INSERT
AS
BEGIN
  IF (NEW."$autoIDColumnName" IS NULL) THEN
      NEW."$autoIDColumnName" = GEN_ID(id_generator, 1);
END!!

#end
#end
Be Careful

The important thing to remember when one uses native idMethod, is that the Firebird provider relies on a generator named "ID_GENERATOR". Because only then it can determine the generated primary key after saving to the database.

Labels

 
(None)