Copy Data without SQL

Hi

I would like to copy a datarow completly amd change the ID.
Since there are many rows i am looking for a way without the complete SQL.

In SQL i would do it like this:

INSERT INTO `MEMBER`( `ID`,`C_NO`, `U_NO`, `GIDEON_NO`, `AUX_NO`, `TITLE_G`, `SALUT`, `FN_G`, `FN_G_SEC`, `TITLE_A`, `FN_A`, `FN_A_SEC`, `F_NAME`, `STR`, `POBOX`, `PLZ`, `CITY`, `POS_LAT`, `POS_LNG`, `FIRMA`, `JOB`, `TELB`, `TELP`, `TELM_G`, `TELM_A`, `FAXP`, `FAXB`, `C_C`, `C_C_CITY`, `B_DAY_G`, `EMAIL_G`, `CERT_G`, `LTM_G`, `G_ED`, `CHAIRMEN_G`, `CABINET_G`, `CABINET_G_S`, `NAT_C_G`, `NAT_C_G_S`, `CS_S_T`, `CS_S_T_DAT`, `CS_LANG`, `CS_S_T_AUX`, `CS_S_T_DAT_AUX`, `CS_LANG_AUX`, `NMDM_G`, `NMDM_A`, `PAB_G`, `PAB_A`, `B_DAY_A`, `EMAIL_A`, `CERT_A`, `LTM_A`, `A_ED`, `CHAIRMEN_A`, `CABINET_A`, `CABINET_A_S`, `NAT_C_A`, `NAT_C_A_S`, `NOTE`, `CRSP`, `INFO`, `OPT`, `L_UPDATE`, `STAT_UPDATE`, `STAT_DEL`, `RPL$LOCAL` ) 
    SELECT '{F61166D5-7A2C-4528-9694-0209F712D1C8}',`C_NO`, `U_NO`, `GIDEON_NO`, `AUX_NO`, `TITLE_G`, `SALUT`, `FN_G`, `FN_G_SEC`, `TITLE_A`, `FN_A`, `FN_A_SEC`, `F_NAME`, `STR`, `POBOX`, `PLZ`, `CITY`, `POS_LAT`, `POS_LNG`, `FIRMA`, `JOB`, `TELB`, `TELP`, `TELM_G`, `TELM_A`, `FAXP`, `FAXB`, `C_C`, `C_C_CITY`, `B_DAY_G`, `EMAIL_G`, `CERT_G`, `LTM_G`, `G_ED`, `CHAIRMEN_G`, `CABINET_G`, `CABINET_G_S`, `NAT_C_G`, `NAT_C_G_S`, `CS_S_T`, `CS_S_T_DAT`, `CS_LANG`, `CS_S_T_AUX`, `CS_S_T_DAT_AUX`, `CS_LANG_AUX`, `NMDM_G`, `NMDM_A`, `PAB_G`, `PAB_A`, `B_DAY_A`, `EMAIL_A`, `CERT_A`, `LTM_A`, `A_ED`, `CHAIRMEN_A`, `CABINET_A`, `CABINET_A_S`, `NAT_C_A`, `NAT_C_A_S`, `NOTE`, `CRSP`, `INFO`, `OPT`, `L_UPDATE`, `STAT_UPDATE`, `STAT_DEL`, `RPL$LOCAL` 
    FROM `MEMBER`
    WHERE `ID` LIKE '{63FB46AF-4158-4585-8913-A676B10A3AF9}'

Hello

Sorry, ir is not quite clear what you want to achieve, which server platform is used etc.

Hi antonk

I use:

Relativity Server: v9.1.100.1267 
Data Abstract: v9.1.100.1267 
RemObjects SDK: v9.1.100.1267 

Framework: v4.0.30319.42000 
Operating System: Unix 3.13.0.42 
Platform: Unix 

I wanna copy only one record with changed ID, not a update of a record.
i did find this CopyRecordSet in the manual, but it is not quit clear to me how i can change the id of the new record.

What is your client platform?

Windows

Is it .NET, JavaScript, Delphi, something else?

Sorry,…

Windows with Lazarus 1.62 on the Client Side

On the Server:
Relativity Server: v9.1.100.1267
Data Abstract: v9.1.100.1267
RemObjects SDK: v9.1.100.1267

Framework: v4.0.30319.42000
Operating System: Unix 3.13.0.42
Platform: Unix

Sorry for the Missunderstanding.

why you can’t do something like:

// better to insert into cloned table so location of main table won't be changed

clonedtable.Insert;
for i := 0 to clonedtable.Fields.Count-1 do
  clonedtable.Fields[i].Value := Maintable.Fields[i].Value;
clonedtable.FieldbyName('myid').Value := myID;
clonedtable.Post;

Hi
I would like to duplicate a record in the same Table just without ( if possible ) to assign all Fields.
The SQL in the first Post works in phpmyadmin. I just taught there is maybe a more elegant way…

why it wont work for you?

clonedtable.Insert;
clonedtable.FieldbyName('myid').Value := myID;
clonedtable.Fields[1].Value := Maintable.Fields[1].Value;
clonedtable.Fields[5].Value := Maintable.Fields[5].Value;
clonedtable.Fields[10].Value := Maintable.Fields[10].Value;
clonedtable.Post;

by other hand, you can create stored procedure at DB server that will do this for you.

Ok, here i have also to define every Field.
But this looks better, have to try it.

Thank you.

for cloned table, you shouldn’t define any field, except case when you want to insert into different table.

Sorry, for the late response… was in Vacation…
I always get Dataset: Duplicate fieldname: “RecID”

can you create a simple testcase, that reproduces this issue, pls?
you can attach it here or send directly to support@

Ok did send the Testcase.

update uDAMemDataset.pas as

procedure TDAMemoryDataset.InternalOpen;
var  i: integer; //added
begin
..
  {$IFNDEF DELPHIXE6UP}if DefaultFields then {$ENDIF}   //code below was changed
    for I := 0 to FieldDefs.Count-1 do
      if Fields.FindField(FieldDefs[i].Name) = nil then
        FieldDefs[i].CreateField(Self);   

differences in Delphi and FPC implementations :frowning:
in Delphi, if field is present, a new one wasn’t created from FieldDefs.
in FPC, field is created always.

Thanks, logged as bugs://77535

bugs://77535 got closed with status fixed.

Thank you for the Fast and nice Support :wink:
Shalom
Manfred

Logged as bugs://i65226.