AS400 Statement Invalid

Hi There,
I am running an app with an AS400 for the database. in the development
environment I am getting the following error: 37000 (-104) [IBM][iSeries
Access ODBC Driver][DB2 UDB]SQL0104 - Token ` was not valid. Valid
tokens: ( TABLE LATERAL <IDENTIFIER>.

/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-odbc-adapter-2.0/lib/active_record/connection_adapters/odbc_adapter.rb:1519:in
`rescue in select'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-odbc-adapter-2.0/lib/active_record/connection_adapters/odbc_adapter.rb:1514:in
`select'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-odbc-adapter-2.0/lib/active_record/connection_adapters/odbc_adapter.rb:770:in
`select_all'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.10/lib/active_record/base.rb:665:in
`find_by_sql'
/var/www/onlineordering.coastalpet.com/app/models/item.rb:183:in
`filter_categories'
/var/www/onlineordering.coastalpet.com/app/controllers/products_controller.rb:6:in
`index'

here is the revelvant code for that above two pages:

/var/www/onlineordering.coastalpet.com/app/models/item.rb:183:in
`filter_categories' =

s = Item.find_by_sql [sql, upc_rule, query_account_number, upc_rule,
query_account_number, upc_rule, query_account_number, upc_rule,
query_account_number, upc_rule, query_account_number, upc_rule,
query_account_number, upc_rule, query_account_number]

/var/www/onlineordering.coastalpet.com/app/controllers/products_controller.rb:6:in
`index' = @categories = Item.filter_categories(session[:upc_rule],
session[:query_account_number])

I am looking for thoughts on the error Token ` was not valid. Valid
tokens: ( TABLE LATERAL <IDENTIFIER>. as I am not familiar with this
error.

Wow! never thought i’d see an as400 question in this forum. for the record, the as400 is the model name of the server, the database you are using is DB2. the message you are getting basically means you are passing an invalid table name. If I remember correctly (and it’s been a long time), it’s in the format of DDDDD.TTTTT where DDDDD is the database name and TTTTT is the table name. The problem is I have no idea where the error is popping up. It could be in the database adapter (the gem you are using to communicate with the database) or it could be in IBM’s ODBC.

I’ve never used Rails with IBM’s technology. I think the best place to look for resources on this is the rubyforge project at the following:

https://rubyforge.org/projects/rubyibm/