getnextsegment sql file