I have a program that selects the next number then links to the table to see if it exists. In the record suffix I put a while block that ends when the link returns false, then sends the next number back. I store the last number so it doesn't have to start from the beginning each time.