【问题标题】:ORA-00911 error with to_date functionto_date 函数出现 ORA-00911 错误
【发布时间】:2011-10-22 23:42:33
【问题描述】:

此请求按预期工作:

select dit_in.id data_item_in, dit_out.id data_item_out, alg.id algo_id 

from algorithm_run arun

join algorithm_run_of arof on
arof.algorithm_run_id = arun.id

join algorithm_run_input arin on
arin.algorithm_run_id = arun.id

join data_item dit_in on
dit_in.id = arin.data_item_id

join algorithm alg on
alg.id = arof.algorithm_id

join algorithm_run_output arout on
arout.algorithm_run_id = arun.id

join data_item dit_out on
dit_out.id = arout.data_item_id

where alg.id in (182,183,143,162,125,222)

不幸的是,我在末尾添加时出现错误:

 and arun.start_time >= to_date(’01/jun/2011’,’dd/mm/yyyy’) 
 and arun.start_time < to_date(’01/jul/2011’,’dd/mm/yyyy') 

我使用的是网页界面,错误信息是:

警告:oci_execute() [function.oci-execute]:ORA-00911:/opt/csw/apache2/share/htdocs/DAE/sites/default/modules/data_repository/data_repository.inc 第 117 行的无效字符.

警告:oci_fetch_row() [function.oci-fetch-row]:ORA-24374:在 /opt/csw/apache2/share/htdocs/DAE/sites/default/modules 中获取或执行和获取之前定义未完成/daedatabase/daedatabase_db.inc 在第 852 行。

【问题讨论】:

  • 解释“开始失败”。如果它给出错误消息,请发布错误消息。如果返回错误数据,请描述应该返回的数据与返回的数据。
  • 用错误信息编辑帖子。

标签: sql oracle oracle-call-interface


【解决方案1】:
and arun.start_time < to_date(’01/jul/2011’,’dd/mm/yyyy') 

我是否在最后一位周围看到了两种不同类型的引号字符?单引号和反引号?还是只是剪切/粘贴或翻译问题?

【讨论】:

    【解决方案2】:

    试试这个:

     and arun.start_time >= to_date(’01/06/2011’,’dd/mm/yyyy’) 
     and arun.start_time < to_date(’01/07/2011’,’dd/mm/yyyy’) 
    

     and arun.start_time >= to_date(’01/jun/2011’,’dd/mon/yyyy’) 
     and arun.start_time < to_date(’01/jul/2011’,’dd/mon/yyyy’) 
    

    问题是您的日期字符串 (01/jun/2011) 与格式说明符 (dd/mm/yyyy) 不匹配。如上例所示,您需要更改日期或说明符。

    【讨论】:

    • 不,没关系。 JUN 的值自动为 06。当我输入 06 时,我仍然得到同样的错误。
    【解决方案3】:

    作为Phil points out,您的字符串用两个不同的引号括起来。看起来您主要使用来自文字处理器的花哨的引号。这是一个问题,因为 Oracle 需要纯 ASCII 撇号 (ASCII 39)。

    这肯定会解释为什么您会收到 ORA-00911 错误。

    要解决此问题,您只需将所有 替换为 ' 即可。

    为避免将来出现这种情况,您应该在编写代码时使用文本编辑器或 IDE。

    【讨论】:

    • 非常感谢。我从 pdf 的研究论文中查询,不够仔细。
    猜你喜欢
    • 1970-01-01
    • 2011-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-18
    • 1970-01-01
    • 1970-01-01
    • 2014-09-20
    相关资源
    最近更新 更多