DF#QCADOOMES-1984 Some fixes in sql.