SURJA
SURJA

Reputation: 17

Error while calling java stored procedure in oracle database

I have created a RunnableJar (a jar containing other third party jars like iText.jar, java classes, etc...) and I have upload that RunnableJar.jar in Oracle database using loadjava. In the jar i have main class GetOffer in that i have one public String getOffer(String param1) { } method and the use of this method is to create multiple pdf according to user selection and concat them.

Now I have created Stored procedure:

create or replace function getOffer(param1 in varchar2) return varchar2
    is language java name 'GetOffer.getOffer(java.lang.String) return java.lang.String';

And I have called this stored procedure using following call statement:

SQL> VARIABLE  myString  VARCHAR2(20);
SQL> CALL getOffer("XYZ") INTO :myString

When calling the procedure I am getting the below error:

SQL> VARIABLE  myString  VARCHAR2(20);
SQL> CALL getOffer("XYZ") INTO :myString
 2  ;
CALL getOffer("Any String") INTO :myString
 *
ERROR at line 1:
ORA-06576: not a valid function or procedure name

How can I solve this problem?

Upvotes: 0

Views: 728

Answers (1)

Justin Cave
Justin Cave

Reputation: 231781

The code you posted is creating a stored function, not a stored procedure. If you want to call a function

SELECT getOffer('xyz')
  INTO :myString
  FROM dual;

Remember as well that strings in SQL and PL/SQL are delimited by single quotes not double quotes.

Upvotes: 1

Related Questions