Skip to Main Content
  • Questions
  • Returning Java String[] array to database

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, HARI PRASAD.

Asked: April 23, 2020 - 11:01 am UTC

Last updated: April 28, 2020 - 5:59 am UTC

Version: 11GR2

Viewed 1000+ times

You Asked

Hi Tom,

Below are the code snippets.

Created as DB object:
CREATE OR REPLACE TYPE "COLUMN_VALUE_TYPE" AS TABLE OF VARCHAR2(4000);

FUNCTION test_java(IN_MESSAGE_FORMAT IN VARCHAR2)
RETURN COLUMN_VALUE_TYPE
AS LANGUAGE JAVA
NAME 'com.vault.decodeCreditCard_1( java.lang.String) return java.lang.String[]';

Below is code in Java:
Public static String[] decodeCreditCard_1(String messageType)
{
//Code in java
//Returning array of strings here
}

We have loaded the .jar into DB using loadjava. When we are calling this fron DB, anonymous block we are getting error.
declare
v_out column_value_type:=int_java_xml.test_java('TPI');
begin
dbms_output.put_line('Test');
-- dbms_output.put_line(v_out);
end;

Error:
ORA-00932: inconsistent datatypes: expected a java return value type that is convertible to an Oracle value got something else.

Can you please help me in fixing this issue.

and Connor said...


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library