Perl 类::DBI、类::DBI::AbstractSearch和Oracle to_date
我正在尝试使用CDBI生成以下SQL:Perl 类::DBI、类::DBI::AbstractSearch和Oracle to_date,perl,Perl,我正在尝试使用CDBI生成以下SQL: select * from mytable where ref = "foo" and to_date(received_date, 'DD-MM-YYYY') < to_date('01-04-2011', 'DD-MM-YYYY') 我能想到的最接近的语法是: mycdbi->search_where({ ref => 'foo', received_date => { '<' =
select * from mytable
where ref = "foo"
and to_date(received_date, 'DD-MM-YYYY') < to_date('01-04-2011', 'DD-MM-YYYY')
我能想到的最接近的语法是:
mycdbi->search_where({
ref => 'foo',
received_date => { '<' => ["to_date(?, 'DD-MM-YYYY')", '01-04-2011'] }
});
但是,这并不是使用Oracle函数将列mytable.received_date转换为_date
那么正确的方法是什么呢
Ps:请不要说使用DBIC,因为代码需要留在CDBI中
谢谢 可能是最简单的使用和手工操作:
my @things = mycdbi->retrieve_from_sql(qq{
ref = 'foo'
AND to_date(received_date, 'DD-MM-YYYY') < to_date('01-04-2011', 'DD-MM-YYYY')
});
对于任何比我的$thing=thing->retrievex更复杂的实例化,我通常都会把ORMs推到一边,因为我已经知道SQL,所以我不需要再学习另一个试图实现SQL的API,而且通常执行得相当糟糕