declare newguid VARCHAR2(50);
begin
for c in (select * from bcd_samplingrecord where recordid is null)
loop
SELECT lower(SUBSTR(GUID,1,8))||'-'||lower(SUBSTR(GUID,9,4))||'-'||lower(SUBSTR(GUID,13,4))||'-'||lower(SUBSTR(GUID,17,4))||'-'||lower(SUBSTR(GUID,20,12)) into newguid
FROM
(
SELECT SYS_GUID() GUID FROM DUAL
);
update bcd_samplingrecord set recordid=newguid,samplingtype=0 where id= c.id;
insert into bcd_samplingrecord_detail(
recordid,
samplingdate,
sampling_stime,
sampling_etime,
filter_mode,
filterid,
hasfilter)
values(newguid,c.sampling_date,c.sampling_stime,c.sampling_etime,0,c.filter_number,c.hasfilter);
end loop;
end;