[DUG] TIBDataset

David O'Brien dave at iccs.co.nz
Thu Mar 16 15:54:33 NZDT 2006


Now have a problem where the ID field gets incremented by two, not one.

After the post, I check the field and it is correct i.e. +1, but after the
table is closed it ends up being +2.

If I don't specify the GeneratorField parameter in the TIBDataset the post
fails, same if I don't have the trigger in the db.

Why is it incrementing by two?

Dave.

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
Behalf Of David O'Brien
Sent: Wednesday, 15 March 2006 5:21 p.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: RE: [DUG] TIBDataset

Thanks, that's got it.

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
Behalf Of Matthew Comb
Sent: Wednesday, 15 March 2006 4:01 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: RE: [DUG] TIBDataset

You still need the ID field there, you just need to remove the required
field property using the object inspector.

Matt.

> Tried that, now it says "ID not found" as soon as I do the Insert.
>
> -----Original Message-----
> From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz]
> On
> Behalf Of Matthew Comb
> Sent: Wednesday, 15 March 2006 3:20 p.m.
> To: NZ Borland Developers Group - Delphi List
> Subject: Re: [DUG] TIBDataset
>
> All from memory but...
>
> If you don't define the fields in your table manually or at design time,
> then the field definitions will be auto loaded which means that your id
> field will be a necessary field, and your app will block the post client
> side before it even gets serverside if your id field is null.
>
> e.g. Go to Datamodule, double click on Dataset ? and add fields that you
> require. Click on the id field, and remove the necessary field property.
> this should allow you to post the record, and teh generator will sort out
> the id server side.
>
> Note that to get this record back again, you will have to refresh the
> dataset.
>
> Matt.
>
>> Can someone please give me an example of inserting a new record with the
>> TIBDataset?
>>
>> I have a TIBDataset, attached to a DB, with
>> SelectSQL = 'Select * from tablename'
>> RefreshSQL = 'Select * from tablename where ID = :old_ID'
>> ModifySQL = 'Update tablename Set desc = :desc where ID = :old_ID'
>> InsertSQL = 'Insert into tablename (desc) values (:desc)
>> DeleteSQL = 'Delete from tablename where ID = :old_ID
>> And
>> GeneratorField = 'TABLE_ID_GEN -> ID By 1'
>>
>> Table_ID-Gen is a valid generator in the db, there is also a valid
>> trigger
>> for that generator in AfterInsert.
>>
>> This all works fine for DB Components, how do I programmatically do an
>> Insert?
>>
>> I assumed that:
>>  Tablename.Insert ;
>>  Tablename.FieldByName('Desc').AsString := 'Fred' ;
>>  Tablename.Post ;
>> Would do the job but it fails because the ID field never gets set. I
>> thought
>> this should be dealt with by the db server, or the TIBDataset with the
>> GeneratorField.
>>
>> Dave.
>>
>>
>>
>> _______________________________________________
>> Delphi mailing list
>> Delphi at ns3.123.co.nz
>> http://ns3.123.co.nz/mailman/listinfo/delphi
>>
>
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
>


_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi


_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi




More information about the Delphi mailing list