Because there are two ID columns (one from TABLE1, one from TABLE2) you can't use SELECT *... in this cursor or you'll get something like
ORA-06550: line 7, column 9: PLS-00402: alias required in SELECT list of
cursor to avoid duplicate column names
(at least in Oracle 11.2).
Try the following:
PROCEDURE testproc IS
CURSOR cur1 IS
Select t1.ID, t1.COLx, t2.COLy
From table1 t1,
table2 t2
where table1.id = table2.id;
l_var cur1%ROWTYPE;
BEGIN
OPEN cur1;
LOOP
FETCH cur1 INTO l_var;
EXIT WHEN cur1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('ID=' || l_var.ID ||
'COLx=' || l_var.COLx ||
'COLy=' || l_var.COLy);
END LOOP;
CLOSE cur1;
END testproc;
I included columns COLx and COLy in the cursor SELECT list as I don't know what what columns you actually have on your tables - replace them with whatever makes sense.
Share and enjoy.