bug 893: fixed some sql statements