ODBC Error on single table "No columns were bound prior to calling SQLFetch"
I am very new to IRIS. We are developing a PHP application that connects to an IRIS instance of one of our vendors. I am having trouble with a specific table. When I need to query this specific table for specific fields, I am receiving an error. However, if I change the call to get all columns (`*`), there is no error. I get 37K records returned.
Error:
PHP Fatal error: Uncaught PDOException: SQLSTATE[SL009]: <<Unknown error>>: [unixODBC][Driver Manager]No columns were bound prior to calling SQLFetch or SQLFetchScroll (SQLFetchScroll[0] at /builddir/build/BUILD/php-8.1.20/ext/pdo_odbc/odbc_stmt.c:547) in test.php:187
Stack trace:
#0 IRIS.php(187): PDOStatement->fetchAll(2)#1 test.php(20): Models\Db\AthenaIRIS::getRecords('HPA', 'FeeScheduleTxn', Array)#2 {main}
thrown in IRIS.php on line 187
Query:
SELECTIdFROM HPA.FeeScheduleTxn
Digging on the internet produced this StackOverflow question, but there are no answers. Is anyone else experiencing a similar problem or is there a known solution to this issue?
Comments
I haven't touched PHP in a bit, but are you binding your columns? I seem to remember PHP things getting a little finicky about making sure you do that before you fetch if you were specifying columns in the query, but not if you were doing a select *.
I am not binding the columns because I'm using PDO fetch mode `FETCH_ASSOC` to cast the resulting object to an array.
Also I should've made this more clear, the exact same functionality works for all other IRIS queries I have. For example, the following query returns results properly:
SELECT Id, Name, Mnemonic, Type FROM Dict.VisitTypes;
Are there settings or anything configurable that could effect this on specific tables?
Yes, security settings can get down to a columnar level. Also, if what you're querying is a view rather than a table, or if the ID column is defined to be something other than ID, that column just might not exist.
Also for clarification, when you use the select *, are you getting an Id column in the resulting data?
Thank you for telling me about the security settings. That's helpful, I'm going to check on that.
I've confirmed this is a table and when I use `select *` I am getting the Id column back. I've also confirmed through documentation that Id is a column that exists and should be queryable.