Subject | Re: [IBO] Trouble posting changes to a multirecord dataset |
---|---|
Author | Helen Borrie |
Post date | 2006-11-01T13:48:06Z |
At 12:44 PM 1/11/2006, you wrote:
your transaction can see. You have to commit the transaction to
change the database state.
This is an SQL database, dear boy! Why are you performing this
update in this fashion? Is there some hidden reason you haven't mentioned?
All you need is an ib_cursor or ib_dsql with a parameterised update
statement as its SQL:
update aTable
set WS_REPEAT_REASON = :aReason
where activity_id = :activity_id
In the BeforeExecute, assign values to the params of *this* statement.
if not statement.Prepared then
statement.Prepare;
statement.Params[0].AsString := RepeatReason;
statement.Params[1].AsInteger := <wherever you're getting it from>;
Call Execute on the statement (not Open!!) and WHOOOOSH! it's done,
all on the server. One little request instead of 12,000. Commit the
transaction and take the rest of the afternoon off. :-)
Helen
>Hi,Post doesn't change the state of the database - it only updates what
>
>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?
your transaction can see. You have to commit the transaction to
change the database state.
This is an SQL database, dear boy! Why are you performing this
update in this fashion? Is there some hidden reason you haven't mentioned?
All you need is an ib_cursor or ib_dsql with a parameterised update
statement as its SQL:
update aTable
set WS_REPEAT_REASON = :aReason
where activity_id = :activity_id
In the BeforeExecute, assign values to the params of *this* statement.
if not statement.Prepared then
statement.Prepare;
statement.Params[0].AsString := RepeatReason;
statement.Params[1].AsInteger := <wherever you're getting it from>;
Call Execute on the statement (not Open!!) and WHOOOOSH! it's done,
all on the server. One little request instead of 12,000. Commit the
transaction and take the rest of the afternoon off. :-)
Helen