IIF Function for FoxPro

Posted by Denis on 30-Sep-2019 14:05

Hello,

Using DD driver to connect an old FoxPro.dbf files from PHP with the odbc_connect function. It connects well to the files but the old PHP code uses a SQL function (iif) and this function doesn't seem to work. Do you know if the DataDirect driver supports this kind of function? See below an example of request :

 $current_year_query = "select sum(iif(nt_period = 1, nt_value, 0)) as period_1,
  sum(iif(nt_period = 2, nt_value, 0)) as period_2,
  sum(iif(nt_period = 3, nt_value, 0)) as period_3,
  sum(iif(nt_period = 4, nt_value, 0)) as period_4,
  sum(iif(nt_period = 5, nt_value, 0)) as period_5,
  sum(iif(nt_period = 6, nt_value, 0)) as period_6,
  sum(iif(nt_period = 7, nt_value, 0)) as period_7,
  sum(iif(nt_period = 8, nt_value, 0)) as period_8,
  sum(iif(nt_period = 9, nt_value, 0)) as period_9,
  sum(iif(nt_period = 10, nt_value, 0)) as period_10,
  sum(iif(nt_period = 11, nt_value, 0)) as period_11,
  sum(iif(nt_period = 12, nt_value, 0)) as period_12,
  sum(iif(nt_year = $current_year, nt_value, 0)) as period_total
   from a_ntran WHERE nt_year = $current_year AND nt_type ='IN'";

All Replies

Posted by Thomas Dixon on 30-Sep-2019 17:12

According to our ODBC driver documentation, the IIF function is supported by our flat-file drivers. Are you getting an error when trying to use it?

This thread is closed