2
votes

I am trying to query the MS SQL Server database using Prolog.

Prolog Code

lemmas:-
        odbc_query('my_db',
                   'SELECT * ,case 
                   when ActualCost<EstimatedCost then 'true'
                   else 'false' 
                   end as Value
                   from Work_Order '
                   ).

It gives an error that operator is expected after 'true' .

Note: The Query works in SQL-Server but it doesn't work in Prolog

1
You need to escape your single quotes I would guess. - Anssssss
@Anssssss But it gives an error Invalid Column Name 'true' - user3402248

1 Answers

3
votes

Try:

lemmas:-
        odbc_query('my_db',
                   'SELECT * ,case                             \
                   when ActualCost<EstimatedCost then \'true\' \
                   else \'false\'                              \   
                   end as Value                                \
                   from Work_Order '
                   ).

In this manner, a lot of extra spaces are transmitted. However, practically all programming languages are not (very) sensitive to adding extra spaces at the end of a line. This is still our heritage from punched cards. You only need to know that in those days space was represented by no punched hole at all. So a fresh card was pre-filled with 80 spaces.