sql cache function advanced and sql error test added