Subject Re: [IBO] Bug or Newbie issue: DataSetProvider not updating properly
Author Helen Borrie
At 08:29 PM 25/08/2003 +0000, you wrote:
>I do not know whether this is a bug in IBO or because I am so new
>using IBO (acutally evaulating) that I am doing something wrong.

You're a good enough newbie that you found the SQL Monitor! :-))

>I
>am connecting a TIBOQuery to a TDataSetProvider to a TClientDataSet.
>1. Open the TClientDataSet
>2. TClientDataSet.Edit and change the key value from XXX to WWW
>3. TClientDataSet.Post and TClientDataSet.ApplyUpdates(0)
>
>Problem: The DataSetProvider creates the following statement seem via
>TIB_Monitor:
>
>UPDATE SALESPERSON
> SET SALESPERSON_ID = ? /* SALESPERSON_ID */
> , NAME = ? /* NAME */
> , ISACTIVE = ? /* ISACTIVE */
> , GROUP_ID = ? /* GROUP_ID */
> , COMMISSION = ? /* COMMISSION */
>WHERE SALESPERSON.SALESPERSON_ID = ? /* OLD.SALESPERSON_ID */
>
>PARAMS = [ Version 1 SQLd 6 SQLn 6
> [SALESPERSON_ID] = 'XXX'
> [NAME] = 'Test Customer2'
> [ISACTIVE] = 'Y'
> [GROUP_ID] = 'YYY'
> [COMMISSION] = 0.15
> OLD.[SALESPERSON_ID] = 'XXX' ]
>
>Update suceeds, fails to process correctly, because the SALESPERSON_ID
>should be WWW instead of XXX, so SALESPERSON_ID has not changed. The
>only way that I can make this work is to change the following:
>
>TIBOQuery.RequestLive = True;

You need this True if you want to depend on the query to create the update
statement automatically (as you do here). If it is False, the IBOQuery
just ignores the request to post.

The other way to get a live dataset in IBO is leave RequestLive false and
instead use the xxxxSQL properties to set up your own custom DML statements
to be used when Edit, Insert and Delete are called.

(Alternatively, you could use a TIBOUpdateSQL and hook it to the
UpdateObject property. That's extra, unneeded overhead in IBO - it's only
there for compatibility with converted BDE apps...)

>TIBOQuery.Unidirectional = False;
>TDataSetProvider.ResolveToDataSet := True;
>
>But if I do this, I am using both the TIBOQuery and TClientDataSet to
>cache data (due to Unidirectional),
>so I know this can't be the
>correct procedure. Please Help.

You won't have a cache for the iboquery unless you set CachedUpdates
true (which you don't need!!) AFAIK, this is how the
TClientDataset/Provider pair are meant to work.

But Unidirectional doesn't determine whether or not you have a cache. It
determines whether or not the dataset is buffered. iboquery (like tquery)
is by default buffered (scrollable). When Unidirectional true, the
iboquery behaves like the native tib_cursor and fetches rows one by one
into a single row buffer.

>I am using D7, Interbase 6.01 OS, IBO 4.2

I guess what I'm curious about is why you are using TClientDataset at
all...that would help to discover what (if any) problem needs solving.

Helen