问题描述
|
当我使用Ruby的续集库将应用程序迁移到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;数据源= 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,: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,: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,: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,: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,:default => 0 # 预付金额(元)
BigDecimal :offset_prepayment,:default => 0 # 冲预付
BigDecimal :guarantee_price,:default => 0 # 质保金
BigDecimal :request_amount,:default => 0 # 申请付款额
foreign_key :contract_id,:contracts,:on_update => :cascade
foreign_key :person_id,:people,: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
解决方法
这已在Sequel的master分支中修复,版本3.24.0(将在下周发布)将具有错误修复。
,我认为您收到此错误消息...
OLE error code:80040E14 in Microsoft Office Access Database Engine
Syntax error (missing operator) in query expression \'LIMIT 1 1\'.
...因为Access SQL不支持LIMIT。请参阅对相关的堆栈溢出问题的答复。
查看是否可以使用Access SQL TOP N替代LIMITN。
SELECT TOP 1 m.id,m.paid_in_full,m.date_field
FROM MyTable AS m
ORDER BY m.date_field DESC;