activerecord-jdbc-adapter DB2 zOS增量ID问题

时间:2014-03-27 20:25:14

标签: activerecord db2 jruby zos

ID列不会随INSERT INTO递增。

我与:

  • JRuby 1.7.11
  • activerecord(3.2.17)
  • activerecord-jdbc-adapter(1.3.6)
  • z / OS(大型机)上的DB2 v10(驱动程序db2jcc4.jar版本4.15.99)

/config/database.yml:

production:                                                                     
  adapter: jdbc                                                                 
  driver: com.ibm.db2.jcc.DB2Driver                                             
  url: jdbc:db2://142.123.123.123:123/D2TZMSTR                                  
  connection_alive_sql: "SELECT 1 FROM SYSIBM.SYSDUMMY1 FETCH FIRST 1 ROWS ONLY"
  host: 142.123.123.123                                                          
  port: 123                                                                    
  database: ESTIPROD                                                            
  tablespace: ESTIMATE                                                          
  username: monkey                                                              
  password: business                                                            
  encoding: unicode                                                             
  Blockquote

分贝/迁移/ create_bid.rb:

class CreateBids < ActiveRecord::Migration  
  def self.up                               
    create_table :practices, :primary_key => "practice_id", :force => true do |t|
      t.string :practice_no,        :null => false, :limit => 3                  
      t.string  :practice_name,     :null => false, :limit => 50     
      t.timestamps                                                               
    end                                                                          

    # Create alternate index for practice_no                                     
    add_index :practices, :practice_no                                           

    # Populate Practice table with practices who including into BID project                                                                                  
    Practice.create(:practice_no   => '001',                                     
                    :practice_name => 'Mainframe'                                
    )                                                                            

    Practice.create(:practice_no   => '002',                                     
                   :practice_name => 'Unix'                                     
    )                                                                            
...
end

当我执行&#39; rake db:migrate&#39;时,我收到了来自我的大型机的以下消息命令:

  

ActiveRecord :: JDBCError:com.ibm.db2.jcc.am.SqlIntegrityConstraintViolationException:   DB2 SQL错误:SQLCODE = -803,SQLSTATE = 23505,SQLERRMC = PRAC19S5; 0000000201,&gt; DRIVER = 4.15.99:   INSERT INTO实践(created_at,                         practice_id,                         practice_name,                         practice_no,                         的updated_at)   价值观(&#39; 2014-03-26 19:27:31.749000&#39;,          的 0 下,          &#39; Unix的&#39 ;,          &#39; 002&#39 ;,          &#39; 2014-03-26 19:27:31.749000&#39;)

来自IBM:

  

-803   插入或更新的值是无效的,因为索引空间中的索引索引空间名称&gt;表格的约束列,因此没有两行可以包含那些&gt;列中的重复值。 RID OF EXISTING ROW是X记录ID

我们都明白,价值应该是:

VALUES ('2014-03-26 19:27:31.749000', 
        1, 
        'Unix', 
        '002', 
        '2014-03-26 19:27:31.749000')

SELECT * FROM EXACTICES:

    | PRACTICE_ID | PRACTICE_NO | PRACTICE_NAME | CREATED_AT                 | UPDATED_AT                 |  
  1_|           0 | 001         | Mainframe     | 2014-03-26-19.27.29.279000 | 2014-03-26-19.27.29.279000 |  

有什么想法吗?

0 个答案:

没有答案