There should a loop that frequently check the database for new records.
Your code does not seem to have this loop that will iterate and check the database for the new records. Is there any other piece of code that call the code you shown above that does this?If yes, could you post that too?