Changes to get_next_id() stored proc and calling code.
Updates to get_next_id() stored proc