Hi All,
I am having a situation here, I have two identical records in a table and I am writing a cursor to fetch these records.
In the 1st loop I am updating both the rows of the table with a site, but when the cursor comes for the second loop this updated record is not reflected in the cursor value.
Appreciate your time and help.
Code used:
CREATE TABLE xx_cur_test
(
name varchar2(30),
id number,
site_id number
);
INSERT INTO xx_cur_test (name) values ('SITE1');
INSERT INTO xx_cur_test (name) values ('SITE1');
Anonymous block
DECLARE
CURSOR c1
IS
SELECT * FROM xx_cur_test;
BEGIN
FOR i IN c1
LOOP
dbms_output.put_line ('site id'||NVL(i.site_id,0)); -- in the second loop the site_id value still shows null - what might be the possible cause ?
IF i.site_id IS NULL THEN
dbms_output.put_line ('Inside IF');
END IF;
UPDATE xx_cur_test SET site_id = '123';
COMMIT;
END LOOP;
END;
Thanks,
Ragul