尝试使用成员函数使Java函数正常工作。我是新手,所以我不知道错误可能在哪里。将复制所有相关代码。
create or replace
type sfera as object(
radius number(10,2),
member function tilpums(radius double precision) return double precision);
create or replace and compile JAVA source named "Papild" as
public class Papild {
public static double rek(double radius)
{
return 3.14*radius*radius*radius*4/3;
}
}
create or replace
type body sfera as
member function tilpums(radius double precision) return double precision as Language java
Name 'Papild.rek(double) return double';
end;
Create table sferas of sfera;
Insert into sferas values(4);
select value(a).tilpums(radius) from sferas a;
并从选择中得到以下错误消息:
Error starting at line 1 in command:
select value(a).tilpums(radius) from sferas a
Error report:
SQL Error: ORA-29531: no method rek in class Papild
29531. 00000 - "no method %s in class %s"
*Cause: An attempt was made to execute a non-existent method in a
Java class.
*Action: Adjust the call or create the specified method.
所有帮助将不胜感激。
答案 0 :(得分:1)
可以建议一个解决方法(不是一个完美的工作) - 使用standalong函数并在第一个成员中调用它:
SQL> create or replace function standalon_tilpums(radius double precision)
2 return double precision as Language java
3 Name 'Papild.rek(double) return double';
4 /
SQL> select standalon_tilpums(4) from dual;
STANDALON_TILPUMS(4)
--------------------
267,946667
SQL> create or replace
2 type sfera as object(
3 radius number(10,2),
4 member function tilpums(radius double precision) return double precision);
5 /
SQL> create or replace
2 type body sfera as
3 member function tilpums(radius double precision) return double precision
4 is begin return standalon_tilpums(radius); end;
5 end;
6 /
SQL> Create table sferas of sfera;
SQL> Insert into sferas values(4);
SQL> select value(a).tilpums(radius) from sferas a;
VALUE(A).TILPUMS(RADIUS)
------------------------
267,946667