Search code examples
oracle-databasedelphidelphi-7ora-00933

Help with ORA-00933: SQL Command nor properly ended


If I run the following SQL using Oracle's SQL Developer.

select payee_id, to_char(check_date,'d') as DOW,  
(cmcl_bank_cleared - check_date) as DateDiff from AP_Master  
where (cmcl_bank_cleared is not null) AND ((cmcl_bank_cleared - check_date) >=1)  
order by payee_address_zip, DOW, DateDiff  

It works fine, however when I try to do it using Delphi

SQL.Add('select payee_id, to_char(check_date, ' + QuotedStr('d') + ') as DOW, ');
SQL.Add('(cmcl_bank_cleared - check_date) as DateDiff from AP_Master ');
SQL.Add('where (cmcl_bank_cleared is not null) AND ((cmcl_bank_cleared - check_date) >=:DaysParam))');
SQL.Add('order by payee_id, DOW, DateDiff;');

I get the "ORA-00933: SQL Command nor properly ended" error message


Solution

  • Look at the double bracket after DayParams. You don't have it in your SQL Developer SQL. To avoid you to use StackOverflow as an Oracle SQL spell checker, you could:

    1. Use the SQL editor and paste the query text there
    2. Use a string constant and assign it in a whole, instead of line by line