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>
I see the error but object cis605 is valid. Any ideas what I am missing?
Using the ORD table create a stored function called custord that will use a customer id (CUSTID) that will return the sum of the specified customer id TOTAL field. When your function has been stored run the following SQL: begin dbms_output.put_line('customer 102 total is ' || custord(102)); end;
Your output should look like: Results Explain Describe Saved SQL History
customer 102 total is开发者_开发问答 27775.5
Statement processed.
Try
SHOW ERRORS FUNCTION custord
Your custord
function was created with compilation errors, so there is something wrong with it. This is why you're getting the object CIS605.CUSTORD is invalid
error.
精彩评论