Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 类::DBI、类::DBI::AbstractSearch和Oracle to_date_Perl - Fatal编程技术网

Perl 类::DBI、类::DBI::AbstractSearch和Oracle to_date

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 => { '<' =

我正在尝试使用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 => { '<' => ["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,而且通常执行得相当糟糕