I came across an interesting error recently. I had a very simple data model with 1 fact table and 1 dimension, both coming from a SQL Server 2008 database. When querying the model through Answers I would get ODBC driver errors like the ones below.
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000]
[nQSError: 10058] A general error has occurred.
[nQSError: 43113] Message returned from OBIS.
[nQSError: 43119] Query Failed:
[nQSError: 16001] ODBC error state: 37000 code: 8180 message: [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared..
[nQSError: 16001] ODBC error state: 37000 code: 145 message: [Microsoft][ODBC SQL Server Driver][SQL Server]ORDER BY items must appear in the select list if SELECT DISTINCT is specified..
[nQSError: 16002] Cannot obtain number of columns for the query result. (HY000)
The funny thing was that hitting refresh would bring back the data at the second attempt. Very strange.
After a bit of detective work I narrowed the cause down to the fact that OBIEE adds an extra column (s_0) to the logical request order by clause but BI Server probably doesn’t issue it in the group by clause of the physical request. Why it should work on the second attempt I can’t figure out.
Anyhow, I found 2 workarounds:
1. Untick the checkbox for EXPRESSIONS_IN_ORDERBY_SUPPORTED in the features tab of the database properties in the physical layer.
2. For a single report, go to the advanced tab and select the ‘Issue an explicit distinct’ checkbox.
Oracle have confirmed this is a bug in OBIEE 11g (11786576) and it will be fixed in a later release.