我尝试在 Oracle Database 11g 中创建一个简单的函数,但它给了我以下错误。似乎找不到 oe.orders 表。请你帮忙!
谢谢!
代码:
--Create following function as SYS
CREATE OR REPLACE FUNCTION get_bal(acc_no IN NUMBER)
RETURN NUMBER
IS acc_bal NUMBER(11,2);
BEGIN
SELECT oe.orders.order_total
INTO acc_bal
FROM oe.orders
WHERE oe.orders.customer_id = acc_no;
RETURN(acc_bal);
END;
/
SELECT get_bal(170) AS Balance FROM dual;
错误:
> ORA-06575: Package or function GET_BAL is in an invalid state
> 06575. 00000 - "Package or function %s is in an invalid state"
> *Cause: A SQL statement references a PL/SQL function that is in an
> invalid state. Oracle attempted to compile the function, but
> detected errors.
> *Action: Check the SQL statement and the PL/SQL function for syntax
> errors or incorrectly assigned, or missing, privileges for a
> referenced object. Error at Line: 28 Column: 7