Subject | RE: [IBO] Row Cloning ? |
---|---|
Author | Alan McDonald |
Post date | 2006-06-22T08:36:38Z |
> Maybe someone can help on that:I use a variant - the result is similar
>
> I have an application where a person creates some kind of
> 'master-record' which will then be used by other users as
> a base to create variations from it.
>
> Most of the time the approx. 100 columns per row just
> differ in one or two fields.
>
> Besides of further de-normalization, which should not be
> an issue here, I'd like to know if IBO have something
> like a clone/copy function to easily duplicate a row.
>
> For now I do it like this, works fine but I feel like there
> is room for improvement ;-) :
>
> // Read the source row's values
> vFieldData := VarArrayCreate([0,1,0,fParts.iqParts.FieldCount -1],
> varVariant);
> for i := 0 to fParts.iqParts.FieldCount -1 do
> begin
> vFieldData[0,i] := fParts.iqParts.Fields[i].FieldName;
> vFieldData[1,i] := fParts.iqParts.Fields[i].Value;
> end;
>
> // created a similar copy of this row
> for i := 0 to fParts.iqParts.FieldCount -1 do
> begin
> // the auto-id comes from the fb-generator, so we omit it
> if vFieldData[0,i] <> 'AUTO_ID' then
> begin
> // all other fields will be copied 1:1
> fParts.iqParts.Fields[i].Value := vFieldData[1,i] ;
> end;
> end;
> fParts.iqParts.Post ;
>
FormCreate
ItemRow := VarArrayCreate([0,6], varVariant);
procedure TfrmSawLogItems.CopyDown1Click(Sender: TObject);
begin
itemRow :=
dmLocalStore.IB_QGSList['GLEN;GWID;GHT;LINKTOPROJ;LUPROJECT;LINKTOWO;LUWORKO
RDER'];
dmLocalStore.IB_QGSList.Next;
if ((dmLocalStore.IB_QGSList.FieldByName('GLEN').AsInteger=0)
and (dmLocalStore.IB_QGSList.FieldByName('GWID').AsInteger=0)
and (dmLocalStore.IB_QGSList.FieldByName('GHT').AsInteger=0)
and (dmLocalStore.IB_QGSList.FieldByName('LINKTOPROJ').AsInteger=0)
and (dmLocalStore.IB_QGSList.FieldByName('LINKTOWO').AsInteger=0)) then
dmLocalStore.IB_QGSList['GLEN;GWID;GHT;LINKTOPROJ;LUPROJECT;LINKTOWO;LUWOR
KORDER'] := ItemRow;
RecalcBlockSawLog(self);
end;
Alan