can't understand warnings in simple Pl/SQL function
I am using Oracle 10g with SqlDeveloper. When I execute the follow开发者_如何学运维ing code, it says
"FUNCTION wafadar compiled Warning: execution completed with warning"
create or replace function wafadar
return varchar2(10)
is
cursor c1 is
SELECT employee_id,first_name FROM employees where department_id=50 ;
begin
for i in c1
loop
dbms_output.put_line(i.first_name);
end loop;
return 'hello';
end;
SHOW ERRORS at the end is also not showing the warnings. Why are the warnings there ?
Errors!
At first, you should care about errors, and I bet you have one on the return clause of your function (you can't specify the size of the "varchar2".
Warnings
Did you look for "warning" in the manuals? http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/errors.htm#LNPLS00711
How to see warnings(enable categories you need)
alter function wafadar compile plsql_warnings='ENABLE:ALL' reuse settings
Check:
select plsql_warnings
from user_plsql_object_settings ps
where ps.name = 'WAFADAR'
Your warnings:
Client tools like sql*plus or Sql Developer(if supported):
show errors
or
select *
from user_errors ur
where ur.name = 'WAFADAR'
NAME TYPE SEQUENCE LINE POSITION TEXT ATTRIBUTE MESSAGE_NUMBER
------------------------------ ------------ ---------- ---------- ---------- -------------------------------------------------------------------------------- --------- --------------
WAFADAR FUNCTION 1 1 1 PLW-05018: unit WAFADAR omitted optional AUTHID clause; default value DEFINER us WARNING 5018
Finally, I suggest you to read a little bit of:
- How to ask: http://www.catb.org/~esr/faqs/smart-questions.html#before
- http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/toc.htm
- All the "oracles" are here: http://tahiti.oracle.com/
- Sql developer oracles(if you want to use it!): http://download.oracle.com/docs/cd/E11882_01/doc.112/e12152/toc.htm
精彩评论