Очистка SQL от ошибок синтаксиса.
Процедура по очистке SQL по запросу SELECT от ошибок синтаксиса.
🕛 20.04.2010, 22:51
procedure SQLCleaner; var newSql:string; begin newSql:=Query1.SQL.CommaText; while (pos('WHERE AND',newSQL))0 do begin delete(newSQL,pos('WHERE AND',newSQL)+6,3); end; while (pos('WHERE Order by',newSQL))0 do begin delete(newSQL,pos('WHERE Order by',newSQL),5); end;{ASD} while (pos('WHERE AND',newSQL))0 do begin delete(newSQL,pos('WHERE AND',newSQL)+6,3); end; while (pos('Order by ,',newSQL))0 do begin delete(newSQL,pos('Order by ,',newSQL)+9,1); end; if (pos('WHERE',newSQL)+8)>(length(newSQL)) then delete(newSQL,pos('WHERE',newSQL),5); if (pos('Order by',newSQL)+11)>(length(newSQL)) then delete(newSQL,pos('Order by',newSQL),8); Query1.Clear; Query1.SQl.Add(newSql); end;