Subject Re: [IBO] Trouble posting changes to a multirecord dataset
Author mspencewasunavailable
--- In IBObjects@yahoogroups.com, Ramil <khabibr@...> wrote:
>
> Check IB_Cursor1.RequestLive is True
> and don't forget about Transactions.
>
> I have this working fine:
>
> IB_Transaction1.StartTransaction;
> try
> // it's necessarily for opening cursor and going to the first
record
> IB_Cursor1.First;
>
> while not IB_Cursor1.Eof do
> begin
> IB_Cursor1.Edit;
> IB_Cursor1.FieldByName('ABC').AsString:='123';
> // IB_Cursor1.Fields[1].AsString:='123'; is a little faster
> IB_Cursor1.Post;
> IB_Cursor1.Next;
> end;
> IB_Transaction1.Commit;
> except
> IB_Transaction1.RollBack;
> end;
>
> I have checked up.
>
> Ramil
>
> >
> >
> >
> >
> >
> > Hi,
> >
> > I'm working on a large application that does all of it's saving
one
> > record at a time. Basically the code is like this.
> >
> > Dataset.Close;
> > Dataset.ParamByName('ACTIVITY_ID').AsInteger := ActivityId;
> > Dataset.Open;
> >
> > Dataset.Edit;
> > Dataset.FieldByName('WS_REPEAT_REASON').AsString :=
RepeatReason;
> > Dataset.Post;
> >
> > This may be called up to 12000 times in one "Save". Hence
saving is
> > currently extremely slow. I am looking to speed this up and
have
> > tried the following
> >
> > While not Dataset.eof do begin
> > { does not load activities which have been repeated }
> > Dataset.Edit;
> > Dataset.FieldByName('WS_REPEAT_REASON').AsString :=
RepeatReason;
> > Dataset.Post;
> > Dataset.Next;
> > break;
> > end;
> >
> > In this case "Dataset" is a TIB_Cursor containing all the
records that
> > need to be modified. The trouble is this code doesn't seem to
modify
> > the records in the db. Can anyone help please?
> >

Why wouldn't the OP just let the server do it all (or am I missing
something)? From his attempt at speeding things up, WS_REPEAT_REASON
is the same for all of the records referenced by Dataset. So
wouldn't it be possible to just execute something like this:

UPDATE <table> SET WS_REPEAT_REASON = :ACTIVITY_ID
WHERE <whatever criteria were used in the first place>

using a TIB_Query or a TIB_Statement?


Michael D. Spence
Mockingbird Data Systems, Inc.