Subject | Re: [IBO] Re: Field value required - MIDAS |
---|---|
Author | Helen Borrie |
Post date | 2001-07-06T10:33:17Z |
At 10:13 AM 06-07-01 +0100, you wrote:
Instead of setting GeneratorLinks, it is possible to call GEN_ID(GeneratorName, increment) in your own code, as a method of the IB_Connection. IB_Database and its descendant, IBODatabase, can also access this method.
If you are using TClientDataset, remember that its behaviour is not linked to the IB-specific methods and properties that TIBOQuery and TIBODatabase have access to. Possibly this can be resolved by calling Gen_ID() on the connection object at an appropriate event occurring at the row level and applying the returned value directly to the field object, e.g.
cdsCustomer.Fields['CustNo'] := IBODatabase1.Gen_ID(gen_CustNo, 1);
Regards,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
>Thanks you very much Helen for your answer.No, two inserts *to the IBOQuery* one after the other should always succeed, because the GENID() method is called at OnBeforeInsert - that is, each insert will get its own unique value from the generator.
>I changed the autogenerated value back to arNone on the server side. as you suggested
>I can now insert a row in the clientdataset, post it and apply the data.
>However, now I cannot post two rows after one another as I get a key violation. I believe
>it is because the client side is not aware of the generator/trigger on my primary key.
>the trigger BEFORE INSERT looks like this :
>if (NEW.TEST_PK IS NNULL) THEN
> NEW.TEST_PK = GEN_ID(GEN_TEST_PK,1)
>
>On the server side, on the TIBOQuery, I have set the generator link to :
>TEST_PK=GEN_TEST_PK.
>
>But it doesn't seem to be enough. I understand it makes sense since the client doesn't speak to the server
>before an apply. Therefore two inserts after one another would fail.
>Is it a design problem or is there a simple solution ?The answer is probably YES to both. The first thing to do would be to work out what the design problem is. Do have a ClientDataSet mixed up in here somewhere?
Instead of setting GeneratorLinks, it is possible to call GEN_ID(GeneratorName, increment) in your own code, as a method of the IB_Connection. IB_Database and its descendant, IBODatabase, can also access this method.
If you are using TClientDataset, remember that its behaviour is not linked to the IB-specific methods and properties that TIBOQuery and TIBODatabase have access to. Possibly this can be resolved by calling Gen_ID() on the connection object at an appropriate event occurring at the row level and applying the returned value directly to the field object, e.g.
cdsCustomer.Fields['CustNo'] := IBODatabase1.Gen_ID(gen_CustNo, 1);
Regards,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________