2011-05-25 53 views
1

當我使用Ruby的續集庫將我的應用程序遷移到Access 2007時。我得到的錯誤如下。有誰知道如何正確遷移?謝謝。如何在Access 2007上正確遷移續集

C:\ContractManagement>rackup 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/adapters/ado.rb:63: 
in `method_missing': WIN32OLERuntimeError: (in OLE method `Execute':) (Sequel:: 
DatabaseError) 
    OLE error code:80040E14 in Microsoft Office Access Database Engine 
    Syntax error (missing operator) in query expression 'LIMIT 1 1'. 
    HRESULT error code:0x80020009 
    Exception occurred. 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/adapte 
rs/ado.rb:63:in `block (2 levels) in execute' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/databa 
se/logging.rb:28:in `log_yield' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/adapte 
rs/ado.rb:63:in `block in execute' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/connec 
tion_pool/threaded.rb:84:in `hold' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/databa 
se/connecting.rb:226:in `synchronize' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/adapte 
rs/ado.rb:61:in `execute' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase 
t/actions.rb:541:in `execute' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/adapte 
rs/ado.rb:97:in `fetch_rows' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase 
t/actions.rb:123:in `each' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase 
t/actions.rb:449:in `single_record' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase 
t/actions.rb:457:in `single_value' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase 
t/actions.rb:200:in `get' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase 
t/actions.rb:133:in `empty?' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens 
ions/migration.rb:499:in `schema_dataset' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens 
ions/migration.rb:381:in `initialize' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens 
ions/migration.rb:422:in `initialize' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens 
ions/migration.rb:332:in `new' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens 
ions/migration.rb:332:in `run' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens 
ions/migration.rb:316:in `apply' 
     from C:/ContractManagement/config.ru:12:in `block in <main>' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/builder.rb: 
51:in `instance_eval' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/builder.rb: 
51:in `initialize' 
     from C:/ContractManagement/config.ru:1:in `new' 
     from C:/ContractManagement/config.ru:1:in `<main>' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/builder.rb: 
40:in `eval' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/builder.rb: 
40:in `parse_file' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/server.rb:2 
00:in `app' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/server.rb:3 
01:in `wrapped_app' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/server.rb:2 
52:in `start' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/server.rb:1 
37:in `start' 
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/bin/rackup:4:in `<to 
p (required)>' 
     from C:/Ruby192/bin/rackup:19:in `load' 
     from C:/Ruby192/bin/rackup:19:in `<main>' 

這是連接配置。 DB = Sequel.ado(:conn_string =>'Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\ ContractManagement1.accdb')

這裏是遷移步驟。所有的都在PostgreSQL 8.4上傳遞。

Sequel.migration do 
    up do 
    create_table :people do 
     primary_key :id 
     String :name, :size => 20, :unique => true, :null => false 
     String :password, :size => 30, :null => false 
     String :role, :size => 20, :null => false 
    end 
    end 

    down do 
    drop_table :people 
    end 
end 

Sequel.migration do 
    up do 
    create_table :currencies do 
     primary_key :id 
     String :name, :size => 10, :null => false 
    end 
    end 

    down do 
    drop_table :currencies 
    end 
end 

Sequel.migration do 
    up do 
    create_table :statuses do 
     primary_key :id 
     String :name, :size => 10, :null => false 
    end 
    end 

    down do 
    drop_table :statuses 
    end 
end 

# encoding: utf-8 

Sequel.migration do 
    up do 
    create_table :contracts do 
     primary_key :id 
     String :contract_id, :size => 36, :unique => true, :null => false 
     String :content, :size => 150 
     String :supplier, :size => 30 
     Date :created_on 
     Date :expired_on 
     BigDecimal :amount, :size => [10, 2], :null => false 
     Fixnum :debt_days 
     Fixnum :guarantee_period 
     String :order_id, :size => 50 # 訂單號 
     String :supplier_contract_id, :size => 36 
     String :operator, :size => 30 
     foreign_key :currency_id, :currencies, :on_delete => :cascade, :on_update => :cascade, :null => false 
     foreign_key :status_id, :statuses, :on_delete => :cascade, :on_update => :cascade, :null => false 
     constraint(:min_amount) { amount >= 0.01 } 
    end 
    end 

    down do 
    drop_table :contracts 
    end 
end 

# encoding: utf-8 

Sequel.migration do 
    up do 
    self[:currencies].insert(:name => "人民幣") 
    self[:currencies].insert(:name => "歐元") 
    self[:currencies].insert(:name => "美元") 
    end 

    down do 
    self[:currencies].delete 
    end 
end 

# encoding: utf-8 

Sequel.migration do 
    up do 
    self[:statuses].insert(:name => "執行中") 
    self[:statuses].insert(:name => "關閉") 
    self[:statuses].insert(:name => "作廢") 
    end 

    down do 
    self[:statuses].delete 
    end 
end 

# encoding: utf-8 

Sequel.migration do 
    up do 
    create_table :payments do 
     primary_key :id 
     BigDecimal :prepayment, :size => [10, 2], :default => 0 # 預付金額(元) 
     BigDecimal :offset_prepayment, :size => [10, 2], :default => 0 # 衝預付 
     BigDecimal :guarantee_price, :size => [10, 2], :default => 0 # 質保金 
     BigDecimal :request_amount, :size => [10, 2], :default => 0 # 申請付款額 
     foreign_key :contract_id, :contracts, :on_delete => :cascade, :on_update => :cascade 
     foreign_key :person_id, :people, :on_delete => :cascade, :on_update => :cascade 
     constraint(:offset_prepayment_is_not_greater_than_prepayment) { prepayment >= offset_prepayment } # offset_prepayment不能大於prepayment 
    end 
    end 

    down do 
    drop_table :payments 
    end 
end 

Sequel.migration do 
    up do 
    {"admin" => "Admin", "contract" => "ContractOperator", "payment" => "PaymentOperator", "report" => "ReportReviewer"}.each do |n, r| 
     self[:people].insert(:name => n, :password => n, :role => r) 
    end 
    self[:people].insert(:name => "payment1", :password => "payment1", :role => "PaymentOperator") 
    end 

    down do 
    self[:people].delete 
    end 
end 

回答

1

這是固定在續集的主分支,版本3.24.0(這將在下週公佈)的替代品會有錯誤修正。

1

我覺得你得到這個錯誤信息...

OLE error code:80040E14 in Microsoft Office Access Database Engine 
    Syntax error (missing operator) in query expression 'LIMIT 1 1'. 

...因爲訪問SQL不支持限制。看到this reply相關的堆棧溢出問題。

看你是否可以使用SQL訪問TOP N爲LIMIT N.

SELECT TOP 1 m.id, m.paid_in_full, m.date_field 
FROM MyTable AS m 
ORDER BY m.date_field DESC;