Page 1 of 1

DML automatic creation for TIBCDataset

Posted: Wed 11 Feb 2009 09:53
by pwatel
hi everyone,
1) is it possible to know when the DML queries are created (update,insert etc) at query.prepare or .open or ???
2) is possible to disable the creation (by setting up readonly ?)
3) to actualy at run time regenerate those DML queries with a method call
if you have submited a new updating table for ex - I could not find it
4) I do not understand why one has to provide a keyfields value once the updating table is set, a simple query to system table would find it
the same for generator name if it is linked to the key field again system tables

I come from the FIB plus world, but their components are not ready for D2009/Unicode in spite of what they say - and all this stuff was available
easily.
I am sure the devart are comparable in features it is just one has to learn new ways to do things and it is not always easy to find them
thanks
PW

Posted: Thu 12 Feb 2009 11:39
by Plash
The update queries are generated on TIBCQuery.Post method call. If you change the UpdatingTable property, the update queries with the new updating table will be generated on the next post. So you don't need to call any method.

It is not required to set the KeyFields and GeneratorName properties. You need to set these properties if you want to IBDAC select the next value from a generator and assign it to the field specified in the KeyField property when you insert new record. If a generator is used on the database level (in a table trigger, for example), you don't need to set these properies.

Posted: Thu 12 Feb 2009 12:04
by pwatel
thanks for the query.post
however for the generator if I have a dbgrid and do not fill up generator infos on the TIBCquery (generator name,etc)
although I have a trigger and generator on the Database it crashes on data entry when I post saying I have to provide a value for the field
it seems as if the trigger was not executed
I should put a value in it at the insert stage automaticaly even if I have to refresh the grid to see the value taken (although it would be nice if it refreshed it automaticaly)
May be I am missing something given I am a begginner with IDAC
PW

Posted: Tue 17 Feb 2009 12:26
by Plash
You should do the following:

1. The Required property of the corresponding TField object must be set to False. You can do it in two ways:
a) set the RequiredFields option of TIBCQuery to False;
b) create all fields in Fields Editor and set the Required property of the corresponding field to False.

After that you can post a record to the database without setting the key field.

2. You need to refresh record to get value generated by trigger back to your application.
If you use Firebird server 2.0 or higher, set the DMLRefresh property of TIBCQuery to True. In this case the TIBCQuery component uses an INSERT statement with RETURNING clause, and new values are returned back when executing this statement.

For other version of Firebird/InterBase you need to call the Refresh method to refresh data. This method refetches all data from your table. You can call this method from the AfterPost event.