使用to_date创建函数索引的时候经常会遇到ORA-01743错误
2009-01-14 17:33
916 查看
在使用to_date创建函数索引的时候经常会遇到ORA-01743错误。示例如下:
SQL> create table sunwg as select to_char(created,’yyyy’) yyyy,to_char(created,’mm’) mm from dba_objects;
表已创建。
SQL> create index ind_sunwg on sunwg(to_date(yyyy,’yyyy’));
create index ind_sunwg on sunwg(to_date(yyyy,’yyyy’))
*
第 1 行出现错误:
ORA-01743: 仅能编制纯函数的索引
SQL> create index ind_sunwg on sunwg(to_date(mm,’mm’));
create index ind_sunwg on sunwg(to_date(mm,’mm’))
*
第 1 行出现错误:
ORA-01743: 仅能编制纯函数的索引
SQL> create index ind_sunwg on sunwg(to_date(yyyy||mm,’yyyymm’));
索引已创建。
结果看起来有些奇怪吧。
ORA-01743: only pure functions can be indexed
Cause: The indexed function uses SYSDATE or the user environment.
Action: PL/SQL functions must be pure (RNDS, RNPS, WNDS, WNPS). SQL expressions must not use SYSDATE, USER, USERENV(), or anything else dependent on the session state. NLS-dependent functions are OK.
错误的提示看起来并不那么清晰。实际上这样的,to_date(yyyy,’yyyy’)和to_date(mm,’mm’)的结果和系统当前的sysdate有关系的。如果现在是5月份,那么to_date(yyyy,’yyyy’)的结果就是2008-05-01,如果现在是6月份,那么to_date(yyyy,’yyyy’)的结果就是2008-06-01。对于这样的有歧义结果的函数,函数索引是无法创建的。
转自:http://www.oratea.cn/2008/05/29/120.html
解决方法是自己实现一个to_date的外壳!!!!!!
SQL> create table sunwg as select to_char(created,’yyyy’) yyyy,to_char(created,’mm’) mm from dba_objects;
表已创建。
SQL> create index ind_sunwg on sunwg(to_date(yyyy,’yyyy’));
create index ind_sunwg on sunwg(to_date(yyyy,’yyyy’))
*
第 1 行出现错误:
ORA-01743: 仅能编制纯函数的索引
SQL> create index ind_sunwg on sunwg(to_date(mm,’mm’));
create index ind_sunwg on sunwg(to_date(mm,’mm’))
*
第 1 行出现错误:
ORA-01743: 仅能编制纯函数的索引
SQL> create index ind_sunwg on sunwg(to_date(yyyy||mm,’yyyymm’));
索引已创建。
结果看起来有些奇怪吧。
ORA-01743: only pure functions can be indexed
Cause: The indexed function uses SYSDATE or the user environment.
Action: PL/SQL functions must be pure (RNDS, RNPS, WNDS, WNPS). SQL expressions must not use SYSDATE, USER, USERENV(), or anything else dependent on the session state. NLS-dependent functions are OK.
错误的提示看起来并不那么清晰。实际上这样的,to_date(yyyy,’yyyy’)和to_date(mm,’mm’)的结果和系统当前的sysdate有关系的。如果现在是5月份,那么to_date(yyyy,’yyyy’)的结果就是2008-05-01,如果现在是6月份,那么to_date(yyyy,’yyyy’)的结果就是2008-06-01。对于这样的有歧义结果的函数,函数索引是无法创建的。
转自:http://www.oratea.cn/2008/05/29/120.html
解决方法是自己实现一个to_date的外壳!!!!!!
相关文章推荐
- ORA-14452: 试图创建, 更改或删除正在使用的临时表中的索引
- mysql 自带时间函数date_format和str_to_date使用总结
- spool命令、创建一个表,创建并且copy表,查看别的用户下的表,rowid行地址 索引的时候使用,表的增删改查,删除表,oracle的回收站
- oracle的to_date()与concat()函数使用实例
- 某些时候使用date(\'Z\')类的函数需要设置date.timezone = PRC
- 物化视图,索引视图,函数索引,创建索引时使用DESC
- 文件磁盘相关函数[14]-获取文件的创建时间 FileAge; FileDateToDateTime
- [代码]使用函数构造创建XML树(LINQ to XML)
- 创建唯一索引的时候遇到问题,提示“唯一索引的分区依据列必须是索引键的子集”
- 在使用composer下载TP5的时候遇到 Your configuration does not allow connections to http://packagist.phpcomposer.
- to_date()函数使用方法
- spool命令、创建一个表,创建而且copy表,查看别的用户下的表,rowid行地址 索引的时候使用,表的增删改查,删除表,oracle的回收站
- ora-14452 试图创建,更改或删除正在使用的临时表中的索引
- DB2 DATE类型在显示的时候,带有00:00:00,去掉的方法,使用VARCHAR()函数
- oralce的to_date()和to_char()函数使用
- Windows环境下Oracle10g使用DBCA创建数据库时遇到ORA-12560协议适配器错误
- (转载)ORA-14452:试图创建,更改或删除正在使用的临时表中的索引
- 使用sunspot创建索引时遇到的坑
- 使用Ajax经常用到的创建请求函数
- 在oracle 数据库中插入 时间类型的值,使用 to_date 函数