Reputation: 80
Trying to make Java function work from member function. I am new to this so i don't know where the mistake might be. Will copy all the relevant code.
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;
and from the select i get the following error message:
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.
All help will be appreciated.
Upvotes: 0
Views: 1225
Reputation: 3038
Can suggest just a workaround (not a prefect by working one) - use standalong function and call it in member one:
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
Upvotes: 1