to_date 函数出现 ORA-00911 错误
此请求按预期工作:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我是否在最后一位周围看到了两种不同类型的引号字符?单引号和反引号?或者这只是剪切/粘贴或翻译问题?
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?
试试这个:
或
问题是您的日期字符串 (01/jun/2011) 与格式说明符 (dd/mm/yyyy) 不匹配。您需要更改日期或说明符,如上面的示例所示。
Try this:
or
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.
正如 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.