I have a cursor which fetches records from table based on filename (filenames are passed from array). now if filename is present more than once in table i need to add the filename to duparray such many number of times.
For example, if test2.txt is present 2 times and test3.txt is present 3 times, i need to have duparray as {test2.txt,test2.txt,test3.txt,test3.txt,test3.txt}
But as per below code, duparray is coming as {test2.txt,test3.txt,test3.txt} since i am having ROWCOUNT>1 check.
If that check is not there, filename which is present single time in table also gets added to it. Please advise where should i correct it.
CURSOR duplicateData IS
SELECT file_name from tablename where file_name=p_filearray(i)
dupRow duplicateData%rowtype;
Inside the procedure:
OPEN duplicateData ;
loop
fetch duplicateData INTO dupRow;
EXIT WHEN duplicateData %NOTFOUND;
IF duplicateData %ROWCOUNT >1
THEN
p_duparray.EXTEND;
p_duparray(p_duparray.LAST):=dupRow.file_name;
END IF;
end loop;
CLOSE duplicateData ;