I have an implementation of the jaro-winkler algorithm in my database. I did not write this function. The function compares two values and gives the probability of match.
A little dirty but faster (untested!).
Let's assume first three characters are the same and length is also approximately the same.
DECLARE
CURSOR citynames(cp_start in varchar2, cp_length in number) IS
SELECT city FROM table_loc_master where statecode = 'PQ'
and city like cp_start||'%'
and length(city) between cp_length -2 and cp_length +2;
CURSOR leasecity IS
SELECT city FROM table_loc where State = 'PQ'
MINUS
SELECT to_char(city) city FROM table_loc_master where statecode = 'PQ';
xProb NUMBER(10,8);
BEGIN
FOR x_rec IN leasecity
LOOP
FOR y_rec IN citynames(substr(x_rec.city,1,3), length(x_rec.city))
LOOP
xProb := jwrun(x_rec.city,y_rec.city,length(y_rec.city));
If xProb > 0.97 Then
DBMS_OUTPUT.PUT_LINE('Source : ' || x_rec.city || ' Target: ' || y_rec.city );
End if;
END LOOP;
END LOOP;
END;