Subject | Re: After posting the previous record is located |
---|---|
Author | DanyM |
Post date | 2012-11-29T11:19:15Z |
--- In IBObjects@yahoogroups.com, "patrick_marten" <patrick_marten@...> wrote:
HTH,
/Dany
>The first thing I'd try (under the prerequisite that ID is the actual PK field) is to set KeyLinksAutoDefine to false and manually set KeyLinks to "TABLENAME_OR_ALIAS.ID". Replace TABLENAME_OR_ALIAS with what applies.
> Hello,
>
> I'm pumping data from one database into another using two connections with appropriate character sets, two queries etc.
>
> IBOQuerySource.First;
> while not IBOQuerySource.Eof do begin
> IBOQueryTarget.Append;
>
> for FieldCounter := 0 to IBOQueryTarget.FieldCount - 1 do begin
> CurrentFeldname := IBOQueryTarget.Fields.Fields[FieldCounter].FieldName;
>
> if <some checks for certain fields> then begin
> <some actions for certain fields>
> end
> else begin
> IBOQueryTarget.FieldByName(CurrentFeldname).Value := IBOQuerySource.FieldByName(CurrentFeldname).Value;
> end;
> end;
>
> IBOQueryTarget.Post;
>
> IBOQuerySource.Next;
> end;
>
> Now I've discovered a problem. Let's assume the fields of the record #10 have these values in the source database:
>
> ID | NUMBER1 | NUMBER2
> -----------------------
> 10 | AAAAAAA | BBBBBBB
>
> For this record everything works.
>
> Next we have the record #11. The values in the source database are:
>
> ID | NUMBER1 | NUMBER2
> -----------------------
> 11 | null | null
>
> Before "IBOQueryTarget.Post;" the values in the target query are the same as in the source query. Once I post the new record in this case, the target query seems to locate the record #10 for some reason. For all other records the correct one, i.e. the new one, seems to remain located after posting. The new record is being saved with correct values, so it's "just" the wrongly located record afterwards in the second case.
>
> What is wrong here?
>
> The only thing I still can add: the field NUMBER1 (varchar(100)) is defined as unique, i.e. has a unique constraint. Don't know if that matters.
>
> Best regards,
> Patrick
>
HTH,
/Dany