lmsurprenant lmsurprenant - 1 month ago 4
Node.js Question

Unable to select from SQL Database tables using node-ibm_db

I created a new table in the Bluemix SQL Database service by uploading a csv (baseball.csv) and took the default table name of "baseball".

I created a simple app in Node.js which is just trying to select data from the table with

select * from baseball
, but I keep getting the following error:

[IBM][CLI Driver][DB2/NT] SQL0204N "USERxxxx.BASEBALL" in an undefined name

Why can't it find my database table?


I created the table from SQL Database web UI in bluemix and took the default name of baseball. It looks like this creates a case-sensitive table name.

Unfortunately for me, the sql_db libary (and all db2 clients I believe) auto-capitalizes the SQL query into "SELECT * FROM BASEBALL"

The solution was to either

A. Explicitly name my table BASEBALL in the web UI; or

B. Modify my sql query by quoting the table name:

select * from "baseball"

More info at http://www.ibm.com/developerworks/data/library/techarticle/0203adamache/0203adamache.html#N10121