函数索引 ORA-30553: The function is not deterministic 解决方法
2010-04-26 18:30
513 查看
建函数索引的时候报错:ORA-30553: The function is not deterministic, 这个函数是自定义的。
SQL>create index mobileIndex on mobile(getmobilearea (callerno));
Google 一下:
解决如下:
在创建基于自定义函数时, 指定deterministic参数,在创建函数索引,就没有问题了。
CREATE OR REPLACE FUNCTION ICD.getmobilearea (mobileno VARCHAR2)
RETURN VARCHAR2 deterministic
IS
s VARCHAR2 (20);
i INTEGER;
c INTEGER;
BEGIN
FOR i IN 4 .. 11
LOOP
SELECT COUNT (*)
INTO c
FROM mobilearea
WHERE shortno LIKE SUBSTR (mobileno, 1, i) || '%';
s := '000';
IF c = 0
THEN
EXIT;
ELSE
IF c = 1
THEN
SELECT areacode
INTO s
FROM mobilearea
WHERE shortno LIKE SUBSTR (mobileno, 1, i) || '%';
EXIT;
END IF;
END IF;
END LOOP;
RETURN s;
END getmobilearea;
/
SQL>create index mobileIndex on mobile(getmobilearea (callerno));
Google 一下:
ORA-30553: | The function is not deterministic |
Cause: | The function on which the index is defined is not deterministic |
Action: | If the function is deterministic, mark it DETERMINISTIC. If it is not deterministic (it depends on package state, database state, current time, or anything other than the function inputs) then do not create the index. The values returned by a deterministic function should not change even when the function is rewritten or recompiled. |
在创建基于自定义函数时, 指定deterministic参数,在创建函数索引,就没有问题了。
CREATE OR REPLACE FUNCTION ICD.getmobilearea (mobileno VARCHAR2)
RETURN VARCHAR2 deterministic
IS
s VARCHAR2 (20);
i INTEGER;
c INTEGER;
BEGIN
FOR i IN 4 .. 11
LOOP
SELECT COUNT (*)
INTO c
FROM mobilearea
WHERE shortno LIKE SUBSTR (mobileno, 1, i) || '%';
s := '000';
IF c = 0
THEN
EXIT;
ELSE
IF c = 1
THEN
SELECT areacode
INTO s
FROM mobilearea
WHERE shortno LIKE SUBSTR (mobileno, 1, i) || '%';
EXIT;
END IF;
END IF;
END LOOP;
RETURN s;
END getmobilearea;
/
相关文章推荐
- 函数索引 ORA-30553: The function is not deterministic 解决方法
- 函数索引 ORA-30553: The function is not deterministic 解决方法
- 函数索引 ORA-30553: The function is not deterministic 解决方法
- 函数索引 ORA-30553: The function is not deterministic 解决方法
- 对自定义函数建立索引时抛异常--ORA-30553: 函数不能确定(ORA-30553: The function is not deterministic)解决方法
- 函数索引 ORA-30553: The function is not deterministic 解决方法
- ORA-30553: The function is not deterministic
- PHP Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. 解决方法:
- Enterprise Manager is not able to connect to the database instance.(ORA-28001)错误的解决方法[转载]
- xxx is not in the sudoers file解决方法
- Web项目:The requested resource is not available解决方法
- xxx is not in the sudoers file.This incident will be reported.的解决方法
- /dev/hdb1 is apparently in use by the system; will not make a filesystem here!解决方法
- PHP date()函数警告: It is not safe to rely on the system解决方法
- VS2005 出现 The OutputPath property is not set for this project. 错误的解决方法
- xxx(wsh) is not in the sudoers file.This incident will be reported.的解决方法
- The prefix "mvc" for element "mvc:annotation-driven" is not bound 的解决方法
- Ubuntu升级之后The disk drive for / is not ready yet or not present的解决方法
- MPI编译C++程序出现#error "SEEK_SET is #defined but must not be for the C++ binding of MPI" 的解决方法
- xxx is not in the sudoers file.This incident will be reported.的解决方法