>orgtracnum is of type character
In this case I don't see any problem with your code. I could think only of two explanation of your incorrect results:
1. The actual code you're running is somehow different from the code you've posted.
2. You're interpreting results incorectly.
If you want, you can zip up and email table to me and I'll take a look at it.
--sb--