Search code examples
delphifirebirdtclientdatasetdbx

Delphi won't let me insert rows with missing columns, but with triggers and generators for those fields


The problem is simple: I have triggers and generators in my Firebird 2.1.4 database to make a column auto increment on each insert.

The architecture of the system is as follows:

TSQLConnection > TSQLDataSet -> TDataSetProvider -> (DataSnap) -> TClientDataSet -> TDataSource

However, if I try to Post updates in my TClientDataSet with some missing column, Delphi will complain like this:

Field 'XXX' must have a value

If I use a SQL insert statement with those fields missing, the row gets inserted and the triggers and generators works as expected.

How do I make Delphi (DBX, DataSnap and such) understand what I'm trying to do (and allow it)?

EDIT

Providing more information based on @mj2008's comment: this TClientDataSet is being created at runtime, using the CloneCursor method. After calling the CloneCursor, I set this field's Required property to False. It does not help with this issue. Example:

myCds.CloneCursor(otherCds, True);
myCds.FieldByName('XXX').Required := False;

This results in the same exception being thrown.


Solution

  • I had to set the TSQLDataset's Required property to False too. That solved the issue.