使用Ruby从MySQL迁移到DB2

问题描述 投票:-2回答:1

我想将我的ruby on rails应用程序的数据库从MySQL更改为DB2。我有下一个问题:

WelcomeRetroller中的ActiveRecord :: StatementInvalid #index

RuntimeError:由于以下原因而无法执行语句:[IBM] [CLI驱动程序] [DB2 / LINUXX8664] SQL0401N操作“=”的操作数的数据类型不兼容或不具有可比性。 SQLSTATE = 42818 SQLCODE = -401:SELECT customer_accounts。* FROM customer_accounts WHERE(status = true)AND(etl_exec = true)AND(customerAccountServer in(从users_accounts中选择tsmserver,其中user_id = 90))ORDER BY customerAccountName asc

如果我将应用程序指回MySQL数据库,应用程序运行正常。

如果我在mysql的列状态和etl_exec中进行查询,我只有1和0

我认为1 =真,0 =假。

但在db2中不起作用

我忘记说了,如果我用文字1替换true我有下一个问题:

NoMethodError in WelcomeController#index undefined method `customerAccountName' for #<CustomerAccount:0x007f5724544570> Did you mean? customeraccountname customeraccountname? customeraccountname= customeraccountname_was customeraccountname_change customeraccountuser customeraccountname_changed? customeraccountuser? customeraccountuser= customeraccountserver 

这里的规格:

S.O(Red Hat 4.8.2-16)db2 v10.5 ruby​​版本2.3.1 Rails版本4.1.6

和db2中的列:

列名----数据类型名称

状态-------- SMALLINT ETL_EXEC ------ SMALLINT

在Mysql中

状态---------- TINYINT(1) etl_exec -------- TINYINT(1)

ruby-on-rails ruby db2
1个回答
1
投票

当前版本的Db2 LUW不会将文字如TRUE / FALSE别名为1/0。使用正确数据类型的主机变量(对于数值数据类型,值为1或0)或在查询中将TRUE文字值替换为1。

如果仍然得到相同的异常,则编辑您的问题以指定查询中每个列的Db2列数据类型

© www.soinside.com 2019 - 2024. All rights reserved.