to_date 函数出现 ORA-00911 错误

发布于 2024-12-11 07:15:40 字数 1116 浏览 0 评论 0原文

此请求按预期工作:

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:第 117 行 /opt/csw/apache2/share/htdocs/DAE/sites/default/modules/data_repository/data_repository.inc 中的字符无效.

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

This request works as intended:

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)

Unfortunately I get an error when I add at the end:

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

I'm using a web interface, the error message is:

warning: oci_execute() [function.oci-execute]: ORA-00911: invalid character in /opt/csw/apache2/share/htdocs/DAE/sites/default/modules/data_repository/data_repository.inc on line 117.

warning: oci_fetch_row() [function.oci-fetch-row]: ORA-24374: define not done before fetch or execute and fetch in /opt/csw/apache2/share/htdocs/DAE/sites/default/modules/daedatabase/daedatabase_db.inc on line 852.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

∝单色的世界 2024-12-18 07:15:40
and arun.start_time < to_date(’01/jul/2011’,’dd/mm/yyyy') 

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

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

Do I see two different types of quote characters around that last bit? A single quote and a backquote? Or is that just a cut/paste or translation problem?

画骨成沙 2024-12-18 07:15:40

试试这个:

 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) 不匹配。您需要更改日期或说明符,如上面的示例所示。

Try this:

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

or

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

The problem is that your date string (01/jun/2011) doesn't match the format specifier (dd/mm/yyyy). You need to either change your date or the specifier, as the above examples show.

治碍 2024-12-18 07:15:40

正如 Phil 指出的,你的字符串是用两个不同的引号括起来。看来您主要使用文字处理程序中的精美引号。这是一个问题,因为 Oracle 需要纯 ASCII 撇号 (ASCII 39)。

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

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

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

As Phil points out, your strings are wrapped in two different quotes marks. It looks like you're mainly use fancy quote marks, from a word processor. This is a problem, because Oracle is expecting plain ASCII apostrophes (ASCII 39).

It would certainly explain why you're getting an ORA-00911 error.

To fix this, you simply need to replace all the with ' .

To avoid it in the future you should use a text editor or IDE when writing code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文