Es funktioniert
Da mir doch mehrere Personen dabei geholfen haben möchte ich hier die Lösung bereitstellen.
Delphi-Quellcode:
var
theOldId : String;
theNewId : String;
icount : Integer;
function CreateClassID: String;
var
guidWork: TGUID;
begin
CoCreateGuid(guidWork);
Result := GUIDToString(guidWork);
end;
procedure TSDIAppForm.Button1Click(Sender: TObject);
begin
DM.pFIBDB_Gideons.Open;
DM.pFIBTrans.StartTransaction;
DM.pFIBQ_NursingH.ExecQuery;
icount:=0;
while not DM.pFIBQ_NursingH.eof do
begin
theOldId := DM.pFIBQ_NursingH.fields[0].AsString; // there is only one field in here
theNewId:= CreateClassID;
DM.pFIBQ_NursingH_UPDATE.ParamByName('new_id').AsString:=theNewId;
DM.pFIBQ_NursingH_UPDATE.ParamByName('old_id').AsString:=theOldId;
DM.pFIBQ_NursingH_UPDATE.ExecQuery;
inc(icount);
DM.pFIBQ_NursingH.Next;
end;
DM.pFIBTrans.Commit;
DM.pFIBDB_Gideons.Close;
caption:=intToStr(icount);
end;
pFIBQ_NursingH:
SQL-Code:
select id from Nursing_H
order by name
pFIBQ_NursingH_UPDATE:
SQL-Code:
UPDATE Nursing_H
SET ID = :new_id
WHERE id = :old_id
und dies sind die Tabellen
SQL-Code:
/******************************************************************************/
/** Tables **/
/******************************************************************************/
CREATE TABLE NURSING_H (
ID ID /* ID = CHAR(38) NOT NULL */,
C_NR T30 NOT NULL /* T30 = VARCHAR(30) */,
U_NR T30 NOT NULL /* T30 = VARCHAR(30) */,
NAME T130 /* T130 = VARCHAR(130) */,
STR T130 /* T130 = VARCHAR(130) */,
PLZ PLZ /* PLZ = VARCHAR(10) */,
);
/******************************************************************************/
/** Primary Keys **/
/******************************************************************************/
ALTER TABLE NURSING_H ADD PRIMARY KEY (ID);
/******************************************************************************/
/** Foreign Keys **/
/******************************************************************************/
ALTER TABLE NURSING_H ADD FOREIGN KEY (C_NR) REFERENCES CAMPS (C_NR) ON UPDATE CASCADE;
SQL-Code:
******************************************************************************/
/** Tables **/
/******************************************************************************/
CREATE TABLE NURSING_H_D (
ID ID /* ID = CHAR(38) NOT NULL */,
C_NR T30 NOT NULL /* T30 = VARCHAR(30) */,
U_NR T30 NOT NULL /* T30 = VARCHAR(30) */,
ID_AREA ID /* ID = CHAR(38) NOT NULL */,
D_DATE "DATE" /* "DATE" = DATE */,
D_C_PERSON T50 /* T50 = VARCHAR(50) */,
);
/******************************************************************************/
/** Primary Keys **/
/******************************************************************************/
ALTER TABLE NURSING_H_D ADD PRIMARY KEY (ID);
/******************************************************************************/
/** Foreign Keys **/
/******************************************************************************/
ALTER TABLE NURSING_H_D ADD CONSTRAINT FK_NURSING_H_D1 FOREIGN KEY (ID_AREA) REFERENCES NURSING_H (ID) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE NURSING_H_D ADD FOREIGN KEY (C_NR) REFERENCES CAMPS (C_NR) ON UPDATE CASCADE;
Besten dank für Eure Hilfe.
Manfred