Inserting sql queries into log table.