Dear all
How does one reference two columns in a FOR CURSOR LOOP that contain the same column name, due to the fact they are two instances of the same table?
The answer is use an alias and make sure that the alias and cursor names are spelt the same way.
I previously put an example what is correct here because I retyped it instead of copying. However it wasn't right in my code:
What I preivously wrote here was:
For example:
.....CURSOR cur_name_list
IS
SELECT COMPARE.name "COMPARE",
SEARCH.name "SEARCH"
FROM name_list COMPARE,
name_list SEARCH
.......
I did try using the an alias in the cursor for loop that didn't work. It just said: PLS-00201: identifier 'REC_NAME_LIST.COMPARE' must be declared
However if I do not use an alias, it says:
PLS-00402: alias required in SELECT list of cursor to avoid duplicate column names
If any one knows what I am doing wrong I would be grateful. I'm sure it is something very simple.
Kind regards
Tim
Edited by: user467357 on Jun 12, 2009 3:41 PM
The problem was a couple of typing errors in the names which I did not spot so I've amended the message and marked it answered.