logic problem

swakoo

Member²
i got a logic problem here.
i need to read from a file line by line.
loop
begin
utl_file.get_line(v_file_ptr, v_Line);
exception
when NO_DATA_FOUND then
exit;
end;
end loop;

how do i change the code so that it check with the other record to c if there is duplicated data?
for eg:
record 1 will match with record 2,3,4,5
record 2 will match with 3,4,5
record 3 will match with 4,5
so on...

i was thinking of using 2 pointer. 1 will point to the actual record the other will loop and do the checking. possible?
can 2 pointer point to the same file?
 
I think you should be able to open the same file twice in read mode, using 2 different file handles (utl_file.file_type instances). You could even do this with 1 file handle if you use fgetpos and seek.

If the file is large, performance will be poor of course. In that case you could consider to use a temporary table with appropriate indexes to store the file contents before processing it.
 
Take a look at external tables. Maybe that's an option: then you can do it with SQL...

Regards,
Martien van den Akker
 
This sounds like homework.

Set up variables and read the first record into them. Read the second record in and compare its fields to those saved from the previous record. If they match they are dups, if not, reset the variables to the values of the current record.

I want my name cited when you turn in.
 
Back
Top