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

StackOverflow https://stackoverflow.com/questions/9022093

سؤال

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.

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

Just to complement: when you do a TClientDataset setting, the updates are in the end sent to the data access component, in this case TSQLDataset, so even if the TClientdataset doesn't require the field's value, if the data access component requires it the error is raised.

It'll be the same even if data come from a TADODataset, TIbDataset, or whatever.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top