简体   繁体   English

使用 Ruby 从 MySQL 迁移到 DB2

[英]Migration from MySQL to DB2 with Ruby

I want to change the database of my ruby on rails application from MySQL to DB2.我想将我的 ruby​​ on rails 应用程序的数据库从 MySQL 更改为 DB2。 and I have the next problem:我有下一个问题:

ActiveRecord::StatementInvalid in WelcomeController#index ActiveRecord::StatementInvalid in WelcomeController#index

RuntimeError: Failed to execute statement due to: [IBM][CLI Driver][DB2/LINUXX8664] SQL0401N The data types of the operands for the operation "=" are not compatible or comparable. RuntimeError: Failed to execute statement due to: [IBM][CLI Driver][DB2/LINUXX8664] SQL0401N 操作“=”的操作数的数据类型不兼容或不可比较。 SQLSTATE=42818 SQLCODE=-401: SELECT customer_accounts.* FROM customer_accounts WHERE (status=true) AND (etl_exec=true) AND (customerAccountServer in (select tsmserver from users_accounts where user_id=90)) ORDER BY customerAccountName asc SQLSTATE=42818 SQLCODE=-401: SELECT customer_accounts.* FROM customer_accounts WHERE (status=true) AND (etl_exec=true) AND (customerAccountServer in (select tsmserver from users_accounts where user_id=90)) ORDER BY customerAccountName asc

If I point the application back to the MySQL database, the application runs fine.如果我将应用程序指向 MySQL 数据库,则应用程序运行良好。

if I make a query in mysql of the columns status and etl_exec I only have 1 and 0如果我在 mysql 中查询列 status 和 etl_exec 我只有 1 和 0

I think that 1= true and 0=false.我认为1=真,0=假。

but in db2 don't works但在 db2 中不起作用

I forget to say it, if I replace true by literal 1 I have the next problem:我忘了说,如果我用文字 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 

here the specifications:这里的规格:

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

and columns in db2:和 db2 中的列:

Column name----Data type name列名----数据类型名

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

in Mysql在 MySQL 中

status----------tinyint(1)状态-----------tinyint(1)
etl_exec--------tinyint(1) etl_exec--------tinyint(1)

Present versions of Db2 LUW do not alias literals like TRUE/FALSE to 1/0. Db2 LUW 的当前版本不会将 TRUE/FALSE 之类的文字别名为 1/0。 Either use host-variables of the correct datatype (with values 1 or 0 as appropriate for numeric datatypes) or replace the TRUE literal value by 1 in the query.要么使用正确数据类型的主机变量(对于数值数据类型,值为 1 或 0),要么在查询中用 1 替换 TRUE 文字值。

If you still get the same exception, then edit your question to specify the Db2 column-datypes for each of the columns in the query如果您仍然遇到相同的异常,请编辑您的问题,为查询中的每一列指定 Db2 列数据类型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM