[DUG] TIBDataset

Matthew Comb matt at ferndigital.com
Wed Mar 15 15:20:07 NZDT 2006


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
>




More information about the Delphi mailing list