Oracle PLS-00231 error analysis, this error is generally caused by the function access permissions, declared as a common function in the header is fully pass, if declared in the package body will die from the function will cause errors.
Create or replace function Two
Return Number
Is
Begin
Return 2;
End Two;
Create or replace procedure PrintTwo
Is
MyNum Number;
Begin
Select Two ()
Into myNum
From dual;
Dbms_output.put_line (myNum );
End PrintTwo;
The above functions and processes are declared in the functions and processes, and the call is normal. Note that the two function is called as an SQL statement by the printtwo process.
If the second program segment is put into a package, the function is private, the package body compilation error, a pls-00231 error, the function cannot be used in SQL statements and so on.
Why?
Pl SQL and SQL are two different engines for Oracle El. Therefore, for SQL engines, the private two functions in the plsql package cannot be found.
So there are two methods to use the two function in the package:
1. Declare the two function in the header declaration. The two function will be called in the form of select two into mynum from dual;. Of course, the two function cannot be hidden.
2 is called in mynum: = two; mode. Because this method is parsed by pl SQL engine, the two function declared in private mode can be used normally.
It can be seen that the two function must be exposed to the SQL or plsql engine in an appropriate way. If two is not declared as a public statement and called in the package name. two method, can the two function be located differently? Oh, of course not. You forgot that two did not make a public declaration. It is invisible no matter what it is outside the package. Haha.
For a function in the package that returns the set type, such as: FUNCTION strsplit (p_list IN VARCHAR2, p_sep IN VARCHAR2 DEFAULT '| ')
RETURN str_split
PIPELINED;
Str_split is a custom set type:
TYPE "STR_SPLIT" is table of VARCHAR2 (4000 );
In this case, no matter whether the type str_split is declared in the package in public or private mode, the SQL method cannot be called normally. Because the returned result is a set, kkk of plsql cannot be used: = str_split method call. In this case, you can only define str_split as the Custom Data Type of oracle:
Create or replace TYPE "STR_SPLIT" is table of VARCHAR2 (4000)
Remove the public or private type str_split definition in the package to call functions using SQL.