Question

I have a database table in which I need to insert records. I'm using a updatable TClientDataset and everything works just fine.

Now, I need to add a dummy field; not a calculated one. One field where I can write the row state (just some information I will use before ApplyUpdates) but that is not part of the database table.

I've seen this illuminating post, but the added field is calculated and it is not possible to update and keep informations. It is not ok for me.

I've tried to add a 'dummy field' from the database select and fix the ProviderFlags to remove the pfUpdate.

cds.CommandText := 'SELECT 1 AS DUMMY , CUSTOMERS.* FROM CUSTOMERS';
cds.Open;
cds.FieldByName('DUMMY').ProviderFlags := [];

I've seen in the Provider.pas that before building the insert sql, the ProviderFlags is checked. This should work indeed, the problem is it seems that ProviderFlags is not updated from my statement above.

Please, do you know how to add a Field on the fly, that is writable but then ignored by the delphi database update process?

I'm using delphi 7.

Thanks for you help.

Was it helpful?

Solution

Make the field an InternalCalc field and set its ProviderFlags to []. This makes the field writable to your application, but skips the field when updating the underlying database.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top