【发布时间】:2011-09-24 23:36:27
【问题描述】:
SQL> CREATE or REPLACE FUNCTION custord (custNo IN number)
2 RETURN NUMBER
3 IS cust_tot NUMBER(11,2);
4 BEGIN
5 SELECT sum(cust_total_field)
6 INTO cust_tot
7 FROM ord
8 WHERE cust_number_field=custNo;
9 RETURN(cust_tot);
10 END;
11 /
Warning: Function created with compilation errors.
SQL> begin
2 dbms_output.put_line('customer 102 total is ' || custord(102));
3 end;
4 /
dbms_output.put_line('customer 102 total is ' || custord(102));
*
ERROR at line 2:
ORA-06550: line 2, column 52:
PLS-00905: object CIS605.CUSTORD is invalid
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored
SQL>
我看到了错误,但对象 cis605 是有效的。有什么我想念的想法吗?
使用 ORD 表创建一个名为 custord 的存储函数,该函数将使用一个客户 ID (CUSTID),该 ID 将返回指定客户 ID TOTAL 字段的总和。 存储函数后,运行以下 SQL: 开始 dbms_output.put_line('客户 102 总共是 ' || custord(102)); 结束;
您的输出应如下所示: 结果 解释 描述 保存的 SQL 历史
客户 102 总数为 27775.5
声明已处理。
【问题讨论】:
-
你有ORD表的权限吗?