Reputation: 307
I've been trying to write more queries by hand rather than use the built in SQL Query Generator found in SAP Business one, and found a weird issue when I try to use IIF
.
When I try to run this, I get a syntax error "SQL Syntax error: incorrect syntax near "=" ... 'User-Defined Values'"
IIF(T0."ItemCode" = 'Shipping Charges', T0."PriceBefDi", T0."Quantity" * T4."AvgPrice") As "TotalLineCost"
A CASE
statement (shown here) works, but not the IIF
.
CASE
WHEN T0."ItemCode" = 'Shipping Charges'
THEN T0."PriceBefDi"
ELSE T0."Quantity" * T4."AvgPrice"
END AS "TotalLineCost"
Is the IIF function not supported in SAP Business one/HANA database? Or is it just my syntax?
Thank you!
Upvotes: 1
Views: 2198
Reputation: 307
Edward is correct. IFF is not available on this specific SQL server. CASE
is portable across all SQL platforms whereas IIF
is SQL SERVER 2012+ specific.
Replacing the IIF
with a CASE
is the correct solution and functions mostly the same.
Upvotes: 4