Thanks so much Agnes for all your help, I finally got your code running and unfortunately it took just about as long as my seek, replace and delete system.
It gave me an idea though that I think might work. I'm thinking about selecting my rate tables into 13 rate tables based on the length of the rate code. Then do an inner join with the cdr on the 13 digit rates, replace them with the rate info. Next join with all the matches for 12 digit rate codes for empty(cdr.dest) , then the same for 11 digit rates, and so on.
I noticed with Dan's code that the set relation was almost instant, it was just not selecting the right matches.
Think this might be a quicker way?
If you don't understand, here's psuedocode for what I plan to do.
select rate
index on code tag code
select cdr
index on len(dnis)+dnis tag dnislength
for i=13 to 1 step -1
SELECT * FROM rate WHERE len(ALLTRIM(code))=i INTO cursor rate+(i)
set relation to rate+(i).code into cdr
set skip to cdr
replace rate table info for empty(cdr.dest) into cdr table
endfor