Subject | Row Cloning ? |
---|---|
Author | Frank |
Post date | 2006-06-22T08:07:48Z |
Maybe someone can help on that:
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 ;
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 ;