Oracle 10G: ORA-06575: 函数处于无效状态
我创建了一个这样的函数
CREATE OR REPLACE FUNCTION tax
(p_sal IN NUMBER(4))
RETURN NUMBER
AS
v_tax NUMBER(4);
BEGIN
v_tax:= CASE
WHEN p_sal> 4000 THEN
p_sal*0.33
WHEN p_sal >2500 THEN
p_sal*0.25
WHEN p_sal >1500 THEN
p_sal*0.20
ELSE 0
END;
RETURN v_tax;
END;
/
当我在插入 stmt 中使用这个税收函数时,
INSERT INTO employees(eno, ename, job, join_date, sal, comm)
VALUES (7784,'allen','salesman',sysdate, 5000, tax(5000));
,就像它显示错误一样,
ERROR: ORA-O6575: package or function tax is in invalid state.
有人可以建议我如何使这个函数处于有效状态吗? 提前致谢。
I created a funcion like this
CREATE OR REPLACE FUNCTION tax
(p_sal IN NUMBER(4))
RETURN NUMBER
AS
v_tax NUMBER(4);
BEGIN
v_tax:= CASE
WHEN p_sal> 4000 THEN
p_sal*0.33
WHEN p_sal >2500 THEN
p_sal*0.25
WHEN p_sal >1500 THEN
p_sal*0.20
ELSE 0
END;
RETURN v_tax;
END;
/
when i used this tax function in insert stmt like
INSERT INTO employees(eno, ename, job, join_date, sal, comm)
VALUES (7784,'allen','salesman',sysdate, 5000, tax(5000));
it shows the error like
ERROR: ORA-O6575: package or function tax is in invalid state.
can anyone suggest me how to make this function is in valid state?
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用此命令检查错误:
Check errors with this command:
函数的编译如下:
然后,检查编译错误:
Oracle 中的对象无效时有两个主要原因:
当您尝试时出现错误消息
编译它)。解决办法是
当然要修复错误,然后
重新编译它。
改变了。解决办法是
重新编译无效对象。
此外,某些数据库连接驱动程序保留对数据库中对象的引用。如果数据库中这些对象的状态发生变化,引用就会过时,您将收到类似于上述错误的错误。
A function is compiled like this:
Then, check for compilation errors with:
There are two main reasons while an object in Oracle is invalid:
error message when you tried to
compile it). The solution is of
course to fix the error and then
recompile it.
changed. The solution is to
recompile the invalid object.
Also, some database connection drivers keep references to objects in the database. If the state of those object change in the database the references go stale and you will get an error similar to the one above.
您可以使用
SHOW ERROR
命令检查错误You can check error(s) with
SHOW ERROR
command确保您的函数编译没有错误。这就是 Oracle 通过
ERROR: ORA-06575
告诉您的内容。使用以下语句创建函数:
在参数中声明
NUMBER
时,不需要参数列表中的(4)
。Make sure your function compiled without errors. That's what Oracle's telling you with
ERROR: ORA-06575
.Create your function with this statement:
You don't need the
(4)
on the parameter list when declaring aNUMBER
in parameter.表示该函数需要编译。该语句
应该编译该函数,但在某些情况下,它完成时没有错误,但实际上没有执行任何操作。 (dBeaver 就是这种情况)。
在这种情况下,请在 SQL 客户端中找到该函数,然后从菜单或工具栏中选择“编译”函数。
means the function needs to be compiled. This statement
should compile the function, but in some cases it completes without errors, but without actually doing anything. (This is the case in dBeaver).
In that case, locate the function in your SQL client and select the Compile function from a menu or toolbar.