Hello Community,

we have an ERP software that is based on a Firebird 2.1 Server. With the help on the ODBC driver, I read data from the DB into Excel and create several reports with PivotTables.

On my computer (Win7 64bit, MS Office 2010 32bit) everything works fine in Excel and FlameRobin, that I use to create my code. However, on other PCs of my co-workers and customers, I once in a whole get the following error:

[ODBC firebird driver][firebird]dynamic sql error
SQL error code=-104
Line ...
Token unknown
WHEN ... could also be FROM

Everyone is using the latest ODBC driver 2.0.0.151 and has the DB connected properly.
I thought, there might be an issue with Office 2010 64bit. However, that can't be, as I have other co-workers with 32bit Office that can open and refresh my Excel files created on Office 2010 64bit.
As for the error at the word "WHEN" I thought, the ODBC driver can't handle the CASE WHEN construct in my queries. I replaced it with an IIF, leading to the error at the word "FROM".

Here's my code.

SELECT
EXTRACT(YEAR FROM an.ORDERDAT) Yr,
CASE EXTRACT(MONTH FROM an.ORDERDAT)
WHEN '1' THEN '01 - January'
WHEN '2' THEN '02 - February'
WHEN '3' THEN '03 - March'
WHEN '4' THEN '04 - April'
WHEN '5' THEN '05 - May'
WHEN '6' THEN '06 - June'
WHEN '7' THEN '07 - July'
WHEN '8' THEN '08 - August'
WHEN '9' THEN '09 - September'
WHEN '10' THEN '10 - October'
WHEN '11' THEN '11 - November'
WHEN '12' THEN '12 - Dezember'
END Mon,
COUNT(ord.ORDERNR) ORDER_AMOUNT,
SUM(a.ORDERSUM) ORDER_SUM, p.MATCHCODE SalesRep, p.MATCHCODE || " (" || ord.EMPNO || ")" SalesRep_EMPNO, ord.EMPNO,
CASE
WHEN ord.DEPTNR < 10 THEN '0' || ord.DEPTNR
ELSE ord.DEPTNR
END DEPT
FROM TABLE1 a
INNER JOIN TABLE5 ord ON a.ORDERIDNR=ord.ORDERIDNR
INNER JOIN TABLE2 an ON a.ORDERIDNR=an.ORDERIDNR
INNER JOIN TABLE3 p ON ord.EMPNO=p.TABLE3NR
INNER JOIN TABLE4 g ON ord.DEPTNR=g.DEPTNR
WHERE an.ORDERDAT>='01.01.2011'
GROUP BY
EXTRACT(YEAR FROM an.ORDERDAT),
CASE EXTRACT(MONTH FROM an.ORDERDAT)
WHEN '1' THEN '01 - January'
WHEN '2' THEN '02 - February'
WHEN '3' THEN '03 - March'
WHEN '4' THEN '04 - April'
WHEN '5' THEN '05 - May'
WHEN '6' THEN '06 - June'
WHEN '7' THEN '07 - July'
WHEN '8' THEN '08 - August'
WHEN '9' THEN '09 - September'
WHEN '10' THEN '10 - October'
WHEN '11' THEN '11 - November'
WHEN '12' THEN '12 - Dezember'
END, p.MATCHCODE, p.MATCHCODE || " (" || ord.EMPNO || ")", ord.EMPNO,
CASE
WHEN ord.DEPTNR < 10 THEN '0' || ord.DEPTNR
ELSE ord.DEPTNR
END


Does anyone have any ideas what could cause the problem only on 1% of the machines rolled out and how it can be solved? Maybe I have to change my code.
Any help is highly appreciated!

Christian