Recent

Author Topic: Insert autoincerement field into Firebird 3 using ZeosLib 8.0  (Read 2644 times)

krzynio

  • Full Member
  • ***
  • Posts: 103
    • Krzynio's home page
Hi!
After upgrade from Lazarus 2.4 to 3.0 and ZeosLib from 7.14 to 8.0 my application cannot insert a new record.
I have the select TZQuery. Select is from one, simple table only. So, I do not use TZUpdateSQL but I also tried with it and result was the same.
Table has 3 fields: IDDOC, NAZDOC, DATA.
ID is integer, not null and autoicremented by trigger.
When I try to insert the new record, I assign only NAZDOC and DATA fields, next after Post data should be inserted to DB and it was under Zeod 7.14
After upgrade I receive the error: Field IDDOC is required, but not supported.
The only thing I changed in the code was db driver in ZConnection. I changed it from Firebird 3 to Firebird becuse drivers for Firebird and Oracle in in Zeos 8.0 are without version number.
BTW after upgrade I also noticed similar error while updating complex queries containing required fields from joined table i.e.
Code: SQL  [Select][+][-]
  1. SELECT a.id, a.name, b.name FROM a LEFT JOIN b ON a.id=b.id
id and name are requied fields in both tables.
I connected TZUpdateSQL with queries updating only table a but while updating I received the error that b.name is required.
Any reasons, solutions?
Ubuntu 23.10 x64, / Windows 11 PL - latest updates
Lazarus 2.2.6, FPC 3.2.2

krzynio

  • Full Member
  • ***
  • Posts: 103
    • Krzynio's home page
Re: Insert autoincerement field into Firebird 3 using ZeosLib 8.0
« Reply #1 on: July 16, 2024, 12:22:35 pm »
It seems I found the solution.
Code: Pascal  [Select][+][-]
  1. TZQuery.Options.doCheckRequired = False
does the trick.
I'll leave it here, maybe it will be useful to someone.
Ubuntu 23.10 x64, / Windows 11 PL - latest updates
Lazarus 2.2.6, FPC 3.2.2

fjabouley

  • Full Member
  • ***
  • Posts: 129
Re: Insert autoincerement field into Firebird 3 using ZeosLib 8.0
« Reply #2 on: September 05, 2024, 08:48:22 pm »
I had the same issue (with Insert (Ids are handled by a trigger by the database itself)) and in Zdataset unit you can also remove"doCheckRequired" in the options, so that when you dynamically create a bunch of TzQueries it should be fine !


Code: Pascal  [Select][+][-]
  1.  
  2.   {** Implements an universal SQL query for read/write data access. }
  3.   TZQuery = class (TZAbstractRWTxnUpdateObjDataSet)
  4.   published
  5.     property Active;
  6.     property ReadOnly default False;
  7.     property SQL;
  8.     property ParamCheck;
  9.     property ParamChar;
  10.     property Params;
  11.     property FetchRow;      // added by Patyi
  12.     property ShowRecordTypes;
  13.     property Properties;
  14.     property DataSource;
  15.     property MasterFields;
  16.     property MasterSource;
  17.     property LinkedFields; {renamed by bangfauzan}
  18.     property IndexFieldNames; {bangfauzan addition}
  19.     property Upda]"]>Blockedde;
  20.     property WhereMode;
  21.     property Sequence;
  22.     property SequenceField;
  23.     property TryKeepDataOnDisconnect default False;
  24.     property Options default [doCalcDefaults, doPreferPrepared];
  25.   end;
  26.  
  27.  

 

TinyPortal © 2005-2018