Subject Re: [IBO] New user - IB_Query help
Author emgfyah2002
--- In IBObjects@y..., "Helen Borrie (TeamIBO)" <helebor@t...> wrote:
> At 12:55 AM 08-04-02 +0000, you wrote:
> >Hi. I am just starting to use IBO. I am converting an application
> >from IBExpress for the IBO ( using Firebird and IBO last releases).
> >I had no problems at all with the select SQL operations, ( I
started
> >the conversion by consulting and report units ), but I need some
help
> >for insert and update operations with the IB_Query. If I use the
> >IB_updatebar everything works beautifully. But I need to command
> >insertions and updates by code. It is really very usefull the way
> >IBO creates the insert, delete and update SQL strings, but how to
use
> >then ? How to "ask" to IB_Query to use the insert or the delete SQL
> >string ?
>
> Edison,
> If your insert, update and deletes simply work with the fields in
the
> current row of the select, you don't need to use the InsertSQL,
EditSQL and
> DeleteSQL strings at all - IBO will construct them automatically
when you post.
>
> If you have custom statements to perform any of these operations,
that is
> when you use the xxxxxSQL properties.
>
> Always with IBO, you need to have correct KeyLinks for your
datasets. If
> the dataset is unusual (e.g. a join, or doesn't contain the primary
key)
> it's safest to set them yourself. If the primary key is in the
dataset and
> is unique, you can just set KeylinksAutodefine to True.
>
> Set the RequestLive property to True.
>
> In all cases, all you have to do is call the Insert, Edit or Delete
> method. In the case of custom SQL, e.g. calling a stored
procedure, you
> may need to pass input parameters yourself. However, if the
parameter
> names of the xxxxSQL statements match the field names of the
dataset, IBO
> will take care of these, too.
>
>
> regards,
> Helen Borrie (TeamIBO Support)
>
> ** Please don't email your support questions privately **
> Ask on the list and everyone benefits
> Don't forget the IB Objects online FAQ - link from any page at
> www.ibobjects.com

Dear Helen

I followed your instructions and it is almost working. I used as a
test the following code:

Ib_transaction1.StartTransaction;
ib_query1.insert;
ib_query1.fieldbyname('MyField1').value := '1111111'; {PK}
ib_query1.fieldbyname('MyTime').value := Now; {PK}
ib_query1.fieldbyname('MyValue').Value := 'Test value';
ib_query1.Post;
ib_Transaction1.CommitRetaining;

In the form I have the IB_Datasource1, IB_Query1, IB_Transaction1 and
a IB_Grid1 components. IB_Query1 with KeylinksAutodefine = True.
After the execution, the new record apears in the grid but if I close
the application, and re-opens it, the new inserted record is not
present. I tryed also with the transaction autocomit set to true. In
the real application, I will need to have complete control of
transaction controlling simultaneous insertions in 3 different tables.
Thank You for your attention, best regards
Edison