Hello
I am trying to gain some performance on a DW ETL process and would like to use Bulk Collect and/or FORALL.
I have spent quite some hours reading up but I am totally lost.
Here's what I'm trying to do:
[tt]DECLARE
CURSOR c1 IS SELECT key1, key2, value1 FROM table1@db1;
asofdt NUMBER := 20080103;
v_key1 NUMBER;
v_key2 NUMBER;
v_value1 VARCHAR2 (10);
BEGIN
OPEN c1;
LOOP
FETCH c1
INTO v_key1, v_key2,v_value1;
EXIT WHEN c1%NOTFOUND;
UPDATE table2 t2
SET t2.enddate = to_char(to_date(asofdt,'YYYYMMDD') - 1,'YYYYMMDD')-- Age off open records one day prior
WHERE t2.key1 = v_key1 AND t2.key2 = v_key2 AND t2.enddate = 99991231;
INSERT INTO table2 (key1, key2, value1, startdate, enddate)
VALUES (v_key1, v_key2, v_value1, asofdt, 99991231); -- Insert new records
END LOOP;
CLOSE c1;
END;
commit;[/tt]
Do I use BULK COLLECT for the cursor or do I use FORALL?
thanks in advance
Thanks
Kenton
(Note: I must remember to add something witty & technical for my signature)
I am trying to gain some performance on a DW ETL process and would like to use Bulk Collect and/or FORALL.
I have spent quite some hours reading up but I am totally lost.
Here's what I'm trying to do:
[tt]DECLARE
CURSOR c1 IS SELECT key1, key2, value1 FROM table1@db1;
asofdt NUMBER := 20080103;
v_key1 NUMBER;
v_key2 NUMBER;
v_value1 VARCHAR2 (10);
BEGIN
OPEN c1;
LOOP
FETCH c1
INTO v_key1, v_key2,v_value1;
EXIT WHEN c1%NOTFOUND;
UPDATE table2 t2
SET t2.enddate = to_char(to_date(asofdt,'YYYYMMDD') - 1,'YYYYMMDD')-- Age off open records one day prior
WHERE t2.key1 = v_key1 AND t2.key2 = v_key2 AND t2.enddate = 99991231;
INSERT INTO table2 (key1, key2, value1, startdate, enddate)
VALUES (v_key1, v_key2, v_value1, asofdt, 99991231); -- Insert new records
END LOOP;
CLOSE c1;
END;
commit;[/tt]
Do I use BULK COLLECT for the cursor or do I use FORALL?
thanks in advance
Thanks
Kenton
(Note: I must remember to add something witty & technical for my signature)