External java function that should return String array

Hi everyone,
I have a split function in plsql that takes 10 times longer a java tokenizer function that i was written. So, i want to use java external function to split my plsql strings into pieces.
I can write a java external procedure that returns types like int, float and String types. I have no problem about it.
My problem is returning an array of strings. I found a book that has an example about how can we get directory list in plsql with java external procedure.
(code)
import java.io.File;
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.*;
public class JFile {
public static oracle.sql.ARRAY dirlist (String dir)
throws java.sql.SQLException
Connection conn = new OracleDriver().defaultConnection( );
ArrayDescriptor arraydesc =
ArrayDescriptor.createDescriptor ("DIRLIST_T", conn);
File myDir = new File (dir);
String[] filesList = myDir.list( );
ARRAY dirArray = new ARRAY(arraydesc, conn, filesList);
return dirArray;
CREATE OR REPLACE FUNCTION dirlist (dir IN VARCHAR2)
RETURN dirlist_t
AS
LANGUAGE JAVA
NAME 'myFile.dirlist(java.lang.String) return oracle.sql.ARRARY';
(code)
I could compile this source file in localhost but not remotehost. There are jar files ( import oracle.sql.*; import oracle.jdbc.*; ) that should be added to remote classpath. ( others have already added java classpath ). But, which classpath i should add? Oracle has own JVM and Classpath, probably i should upload these jar files to oracle classpath. Am i wrong? How can i do? Can you explain in detail? How can i return string array from java external function in Oracle ?
I am using Oracle 11.1.0.7 on Solaris Sparc Machine.

Hi,
What do you mean "compile in remote host"
Aren't you using the loadjava tool? - that should be enough, the RDBMS already "has" the jars needed.
[A must read|http://download.oracle.com/docs/cd/B28359_01/java.111/b31225/chone.htm#BABCFIIF]
Regards
Peter

Similar Messages

  • Return String array in server side

    i wrote a bean which contains a function return String array (
    String[] ). It shows no error on compile time, and also in
    generate jar file. However, when i generate it to an ear file,
    the syntax of the wsdl file is not correct so the client can't
    call this function becuase the xml can't parse the wsdl.
    When i change the return type to String, everything is ok. Does
    anybody know what's happen? I really have no idea on it, thx.

    This is why I wanted to see some code. I wanted to see how you are trying to move the array from one class to another.
    This should work... provided that the array is initialised correctly in ClassA. If you are doing it like this, please post some code and I'll help you fix it.
    class ClassA{
    public String[] getMyArray(){
    return myArray;
    class ClassB{
    public void myMethod(){
    ClassA myA = new ClassA();
    String[] newArray = myA.getMyArray();
    }

  • Please Help regard function that will return values of each JComboBox items

    I'd like to create a function that will return values of each item on the JComboBox at a time when
    I click on each item of a comboBox. I had this following codes, but didn't work.
    Please help me !!!Please correct it... thanks a million
    String wp;
    String text;
    String A[] = {"WARNIGNS","CAUTIONS","NOTES"};
    JComboBox ABC = new JComboBox();
    for (int i=0;i<A.length;i++) {
    ABC.addItem (A);
    text = Get_It(); //assigns each value of JComboBox's item to variable text when clicks at each item
    //of a comboBOx
    private String Get_It(){
    ABC.addActionListener(new ActionListener (){
    public void actionPerformed(ActionEvent e){
    wp = (String)CBweapon.getSelectedItem() ;
    return wp;

    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class AlertFrame extends JFrame {
    String s_alert[] ={"WARNIGNS","CAUTIONS","NOTES"};
    JComboBox CBweapon;
    String wpText;
    public AlertFrame() {
    super("Alerts");
    Container contentPane = getContentPane();
    contentPane.setLayout(null);
    setSize(600,600);
    CBweapon = new JComboBox();
    for (int i=0;i<s_weapon.length;i++) {
    CBweapon.addItem (s_weapon);
    contentPane.add(CBweapon);
    CBweapon.setActionCommand("");
    //set position for components
    CBweapon.setBounds(370 + insets.left,295+ insets.top, 150,30);
    System.out.println(getit()); //calling getit() function
    //this function will be return a String of JcomboBOx value if click on each item of combobox
    private String getit(){
    CBweapon.addActionListener( new ActionListener (){
    public void actionPerformed(ActionEvent e){
    wpText = (String)CBweapon.getSelectedItem() ;
    return wpText;
    public static void main(String args[]) {
    AlertFrame af = new AlertFrame();
    af.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    **I have no errors on compile or run, but it didn't return a string value to System.out.println(getit());
    It maybe because of the "void" of public void actionPerformed(ActionEvent e){
    wpText = (String)CBweapon.getSelectedItem() ;
    Please help me

  • Customized java class for an external Java function activity

    Hi,
    how can i customize my jdeveloper in order to build my own classes for external Java function activities ?
    because any time i try to build my class the compiler tells me that it doesn't know WFFunctionAPI! And i do not have any idea neither which libraries i have to reference nor where i can find them. i tried to reference the *.jar file from my <ORACLE_HOME>.Wf.Java\Oracle\Apps\Fnd\Wf path, but the compiler still was mocking at me!
    Thanks for your help
         abi

    In the "Project" menu, select "Project Properties";
    In the "Libraries" tab, click the "Add" button;
    Click "New";
    Type "Oracle Workflow" (or any other name) in the Name field;
    In the "Class path" field, click the "..." button;
    Click "Add path" and select <ORACLE_HOME>/wf/java;
    Click "Add ZIP/Jar" and select wfjava.jar and wfapi.jar from the <ORACLE_HOME>/wf/java/oracle/apps/fnd/wf/jar directory.
    Click "Ok" in all those windows and compile your class.
    Regards,
    Daniel Viero - [email protected]
    iProcess Solugues em Tecnologia
    Porto Alegre, RS - Brasil

  • Exception - Trying to invoke an External Java Function

    Hi,
    Can any one Please Help me out am Stuck up with the following Exception While trying to invoke a External java Function.
    Step 1: Written the attached Java Class from "Oracle WorkFlow's Developers's" guide.
    Ref: http://www.stanford.edu/dept/itss/docs/oracle/10g/workflow.101/b10284/deffa02.htm#stdjfa
    Step 2: In builder created a process and created a Java Function
    <package-name>.<class-name>
    Step 3: Compiled the Java Class,and Created a jar file and included the jar and the required .jar files [which are required to make that class compile free] in the class path.
    Step 4: We modified the wfjvlsnr.bat by including the custom jar file which was created and the dependent jar files in the classpath and ran the Java Agent.
    Step 5: Invoked the Process from client, once the process is invoked we are getting
    Unable to load class gov.oracle.apps.fnd.wf.SampleWF
    java.lang.ClassNotFoundException: gov.oracle.apps.fnd.wf.SampleWF
    Tue Oct 10 14:33:38 GMT+05:30 2006 Enqueuing VAC02/VAC02 gov.oracle.apps.fnd.wf.SampleWF
    null
    Unable to load class gov.oracle.apps.fnd.wf.SampleWF
    : java.lang.ClassNotFoundEx
    ception: gov.oracle.apps.fnd.wf.SampleWF
    Regards
    Varma

    The engine doesn't see your jar file,
    try to change the path where you put your jar file, or try to call it for first in the set classpath

  • SSAS- DAX expression : Is there any DAX function that can return multiple values ?

    Hi,
    Iam in search of a DAX function that can return multiple values as result. please find below scenario where i want to implement the same.
    I have three  Tables: Table A (typeid, Cost, Qty ) ,Table B (typeid, Cost, Qty ) , Table C ( typeid,Typename ) .
    Table A                                       Table B                               
    Table C
    type id  cost  Qty             type id   Cost    Qty                 
    typeid  typename
    1           100    100                3         300     
    300                  1           aa
    2           200    200                4          400    
    400                  2           bb
                                                                                             3           cc
                                                                                             4          
    dd 
    i have to club cost and Qty of two tables(four measures)  as two measures in the  UI report. There are more columns in these tables that restrict the  UNION of the tables.(for the sake
    of understanding , i have not mentioned the othr columns). In the UI report(Execl 2013-power pivot) iam plotting these measures against the
    Table C.Typeid. Hence the measures drill down against each 
    Table C. Typeid as shown below:
    Typeid  Table A.cost  Table A.Qty  TableB.cost  TableB.Qty                              
    1              100             100
    2              200             200
    3                                                    
    300             300      
    4                                                    
    400             400
    My requirement is to club these measures so that the report will be as below
    Type id  cost   Qty
    1          100    100
    2          200    200
    3         300     300
    4         400      400
    Since i cannot club these in model,as a work around, i created a calculated measure in excel(Analyze tab->Calculations->olap tools->calculated measure) with the condition as below:
    new cost = IIF (ISEMPTY(TableA.cost)="TRUE",TableB.cost,TableA.cost)
    new Qty = IIF(ISEMPTY(TableA.Qty)="TRUE",TableB.Qty,TableA.Qty) and dragged these new measures into the report. It was working fine as expected.
    But  this functionality of Creating calculatedmeasure in excel report is possible only in 2013 excel version.
    Now the requirement is to get the same result in 2010 excel. Can you please help me in implementing the same in 2010 excel? or any other alternative method to bring the columns in model itself. I tried to create a measure in table A with DAX expression as
    : new cost :=CALCULATE(SUM(Table B.cost),ISBLANK(TableA.cost)) -> but this will return only 1 result .i need Sum(Table A.cost) also if it is not blank.
    Thanks in advance

    You can use SUMX ( 'Table A', 'Table A'[Cost] + 'Table B'[cost] )
    However, if you install the latest version of Power Pivot in Excel 2010, it supports the ISEMPTY function, too.
    http://support.microsoft.com/kb/2954099/en-us
    Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo

  • How Do I Call PL/SQL Stored Procedure That Returns String Array??

    I Have Problem Calling An Oracle(8i) Stored Procedure That Returns Array Type (Multi Rows)
    (As Good As String Array Type..)
    In This Fourm, I Can't Find Out Example Source.
    (Question is Exist.. But No Answer..)
    I Want An Example,, Because I'm A Beginner...
    (I Wonder...)
    If It Is Impossible, Please Told Me.. "Impossible"
    Then, I'll Give Up to Resolve This Way.....
    Please Help Me !!!
    Thanks in advance,

    // Try the following, I appologize that I have not compiled and run this ... but it is headed in the right direction
    import java.sql.*;
    class RunStoredProc
    public static void main(String args[])
    throws SQLException
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch(Exception ex)
    ex.printStackTrace();
    java.util.Properties props = new java.util.Properties();
    props.put("user", "********"); // you need to replace stars with db userid
    props.put("password", "********"); // you need to replace stars with userid db password
              // below replace machine.domain.com and DBNAME, and port address if different than 1521
    Connection conn =
    DriverManager.getConnection("jdbc:oracle:thin:@machine.domain.com:1521:DBNAME", props);
    // replace "Your Stored Procedure" with your stored procedure
    CallableStatement stmt = conn.prepareCall("Your Stored Procedure");
    ResultSet rset = stmt.execute();
    while(rset.next())
    System.out.println(rset.getString(1));

  • JavaFX : How to call java function that returns hashtable and manipulate

    I have a requirement to {color:#0000ff}create a java object in JavaFX script code{color}. Then call a java function using the created java object. The java function returns hashtable. Then traverse through each element of hashtable. Finally I need to create a similar structure in JavaFX.

    If you need to use a Java class that uses generics you need to take special steps. Since JavaFX does not support generics you need to create a java wrapper to hide the calls that use generics and call the wrapper class from FX.

  • External Java Function with a Result Type

    Dear all,
    I have created a workflow process which use a Function Activity of type "External Java" without a result type and it works fine, but i have created another with the result type of boolean (WFSTD_BOOLEAN) and it doesn't work properly. I will explain what is happening.
    I start a process and it stops in that function activity, then the oracle Function Activity Agent executes the class associated to that function and it works fine. Then i review the workflow process and check that the status of the activity is "Deferred". I execute the wf_engine.background process, and then the status of the activity is "Complete" but the result field is blank, thus the process is stopped and did not go through the "True" branch of the process. I have follow the Oracle Workflow and Java Technical White Paper to build the class associated to the function activity, and i return true in the execute method and don't put anything in the errorStack variable.
    The documentation says:
    resultOut If a result type is specified in the Activities properties page for the activity in the Oracle Workflow Builder, this parameter represents the expected result that is returned when the procedure completes.
    Note: Unlike the resultout for a PL/SQL procedure called by a function activity, the resultOut for a Java procedure does not include a status code. In the Java API, only the result type value is required. The status of the activity will be set automatically by the Workflow Engine depending on whether there is a value in the errorStack variable.
    am I doing something wrong? could anyone help me?
    Thanks in advance.

    Hi Allison,
    I've found the solution to the problem. If i set the variable resultOut to "T" or "F" before finnishing the execute method it works.
    I think that you have to set the variable resultOut with the internal value of the lookup type that you are using as the result type of the function activity.
    Bye!

  • Returning String Array

    I'm trying to create a function (method?) for parsing some log files. The first index of the string array I want returned will contain a 'key' on what I'm doing with the log files (since they'll be formatted in several different ways depending on what's happening) and the rest will just return tokens from the logs. Here's what I have so far:
        public static String[] parseLog(String inString){
            StringTokenizer st = new StringTokenizer(inString, "\"<>");
            int stNum = st.countTokens();
            String[] parsedOut = new String[stNum + 1];
            if (inString.contains("disconnected")) {
                parsedOut[0] = "read";
            for (int x = 1; st.hasMoreTokens() ; x++){
                parsedOut[x] = st.nextToken().trim();
            return parsedOut;
        public static void main(String[] args) {
            String line = "????log L 08/15/2008 - 20:28:37: \"underTHEinfluence johnRAMBO<16><STEAM_0:0:204495><>\" disconnected";
            System.out.println("Parsed: " + parseLog(line));
        }{code}
    It compiles with no errors, but I'm getting this: Parsed: [Ljava.lang.String;@e09713
    Edited by: mr0ldie on Aug 16, 2008 1:37 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    prometheuzz wrote:
    A String representation of the array is given, while you want to display the individual items from the array.
    Try this:
    System.out.println(java.util.Arrays.toString(yourArray));
    Need closures - want to do mapchar(yourarray, System.out.println);
    :)

  • How to call a Function that will return me boolean value

    Hi all ,
    I am try to call a function that is included in my ApplictionModule the following is my method code
    public boolean callUpdateDepartmentNameFunction(int deptNo,String newName)
    boolean result=false;
    System.out.println("first");
    CallableStatement plsqlBlock =null;
    System.out.println("sec");
    String statement="BEGIN :3 = update_dname_func(:1,:2); END;";
    System.out.println("third");
    plsqlBlock=getDBTransaction().createCallableStatement(statement,0);
    try{
    System.out.println("forth");
    plsqlBlock.registerOutParameter(3,OracleTypes.BOOLEAN);
    plsqlBlock.setInt(1,deptNo);
    plsqlBlock.setString(2,newName);
    plsqlBlock.execute();
    result=plsqlBlock.getBoolean(0);
    catch(SQLException sqlException)
    throw new SQLStmtException(CSMessageBundle.class,CSMessageBundle.EXC_SQL_EXECUTE_COMMAND,statement,sqlException);
    finally
    try{
    plsqlBlock.close();
    catch(SQLException e)
    e.printStackTrace();
    } return result;
    while am runing my page is am getting error like
    Error
    1. JBO-29000: Unexpected exception caught: oracle.jbo.SQLStmtException, msg=JBO-27121: SQL error during statement execution. Statement: BEGIN :3 = update_dname_func(:1,:2); END;
    2. JBO-27121: SQL error during statement execution. Statement: BEGIN :3 = update_dname_func(:1,:2); END;
    3. Invalid column type
    callUpdateDepartmentNameFunction_deptNO          
    callUpdateDepartmentNameFunction_newName          
    callUpdateDepartmentNameFunction
    regards,
    Prabeethsoy P

    Hi,
    http://download-uk.oracle.com/docs/html/B25947_01/bcadvgen005.htm#sm0297
    has an example of how to call a stored procedure with out parameters. Please correct your code accordingly
    Frank

  • Function that will return fee description for a given folderrsn

    Could someone help me make this function work. I am not sure how to add the else clause and when it is done how to call it. I know to call it I will need to input a folderrsn e.g 158744 and then that should show the fee description for that folder.
    Reson for the function is to be used by other users instead of a select statement everytime. I will save it in a package.
    FUNCTION F_GETFEEDESC (folderrsn_in IN NUMBER)
    RETURN varchar2
    IS
    v_feedesc varchar2(2000);
    cursor c1
    is
    SELECT vaf.feedesc
    INTO v_feedesc
    FROM folder f, accountbillfee abf, validaccountfee vaf
    WHERE f.folderrsn = abf.folderrsn
    AND vaf.feecode = abf.feecode
    and f.folderrsn = folderrsn_in;
    begin
    open c1;
    fetch c1 into v_feedesc;
    if c1%notfound then
    v_feedesc := 'Not found';
    else
    end if;
    close c1;
    return v_feedesc;
    END;
    this function when called using a folderrsn like 158744, it should return the fee description for that folder.

    In the event that your table may have more than one record for any given value of folderrsn_in the open, fetch, close method will not suffer any difficulties, however using the select into method without adding a rownum = 1 clause to your where statement is setting the function up for sporatic failures.
    Try this code instead:
    FUNCTION F_GETFEEDESC (folderrsn_in IN NUMBER)
    RETURN varchar2
    IS
    begin
        SELECT  vaf.feedesc
        INTO    v_feedesc
        FROM    folder f, accountbillfee abf, validaccountfee vaf
        WHERE   f.folderrsn = abf.folderrsn
        AND     vaf.feecode = abf.feecode
        and     f.folderrsn = folderrsn_in
        and     rownum = 1;
        return v_feedesc;
    EXCEPTION
        WHEN  NO_DATA_FOUND  THEN
            RETURN  'Not found';
    END;

  • Error  Stack 1 when running external java function

    Hello,
    I defined 1 item that contains an external java program.
    When I launch the process, i receive following error on the
    Java agent listener screen :
    Thu Mar 07 10:25:10 CET 2002 Executing TST_JAVA/22 xx.yyyy.workflow.UpdateWorkflowAttribute
    Thu Mar 07 10:25:11 CET 2002 Enqueuing TST_JAVA/22 xx.yyyy.workflow.UpdateWorkflowAttribute
    Error Stack: 1
    WF_FN_ERROR (MODULE=xx.yyyy.workflow.UpdateWorkflowAttribute) (ITEMTY
    PE=TST_JAVA) (ITEMKEY=22) (ACTID=739) (FUNCMODE=RUN) (ERRMESSAGE=null)
    and the status remains deferred.
    Running the background engine does not change the status of the item. It remains deferred. Anybody has any idea of what is happening ?
    grtz,
    Chris.

    I remember rec. similar errors.
    If you are writing a simple code based on the code shown in the workflow guide, looks like you have included some statements which are invalid at run time. examine your code and try to remove all unnecessary statements. write a very simple piece of code by just inserting only the required statements and the error will vanish.
    hope this helps
    satish paul
    Hello,
    I defined 1 item that contains an external java program.
    When I launch the process, i receive following error on the
    Java agent listener screen :
    Thu Mar 07 10:25:10 CET 2002 Executing TST_JAVA/22 xx.yyyy.workflow.UpdateWorkflowAttribute
    Thu Mar 07 10:25:11 CET 2002 Enqueuing TST_JAVA/22 xx.yyyy.workflow.UpdateWorkflowAttribute
    Error Stack: 1
    WF_FN_ERROR (MODULE=xx.yyyy.workflow.UpdateWorkflowAttribute) (ITEMTY
    PE=TST_JAVA) (ITEMKEY=22) (ACTID=739) (FUNCMODE=RUN) (ERRMESSAGE=null)
    and the status remains deferred.
    Running the background engine does not change the status of the item. It remains deferred. Anybody has any idea of what is happening ?
    grtz,
    Chris.

  • Problems with PL/SQL Calling Java Function that returns String []

    Hi,
    I have written the following code. It's not compiling OK.
    DECLARE
    TYPE Tokens_Type IS VARYING ARRAY(20) OF VARCHAR2(20);
    s1 Tokens_Type DEFAULT NULL;
    SQL_STR VARCHAR2(2000) DEFAULT NULL;
    BEGIN
    SQL_STR := 'CREATE OR REPLACE FUNCTION Schema1.SPLIT_STR (S2 VARCHAR2(20)) ' ||
    'RETURN s1 ' ||
    'AS LANGUAGE JAVA ' ||
    'NAME ''String_Mani.split_it (String) return java.lang.String []''';
    EXECUTE IMMEDIATE SQL_STR;
    END;
    What's the problem with this?

    You cannot create a function with a locally defined return type. As soon as this script is executed, Oracle no longer knows what the TOKEN_TYPE type is any more, so the function will be invalid.
    You need to use a collection type defined at the database level or defined in a package - somewhere where it will persist.

  • I need a java function that convert string to ASCII,

    I have a string like "test123"
    I want to convert this string to ascii code?how could I do this

    It is not compeltely clear, what you need, but String has this method:
    public byte[] getBytes(String charsetName)  throws UnsupportedEncodingException

Maybe you are looking for

  • Migrating and Backing up Schemas (complex database structures)

    Hey guys, I need to figure out a way to back up and also migrate our Oracle database from our production schema to the dev schema and the other way around. We have bunch of config tables that drive how systems on our platform run, and when setting up

  • Installing Adobe Photoshop Elements 11

    im trying to download photoshop but it keeps saying,  to make changes to this computer you have to type in your password.    I forgot that password,    and i tried to use the password i use when i log in,     but it said that that password is incorec

  • How do I update camera raw plugin on photoshop cs4 for mac?

    I've just reinstalled PS cs4 on a new macbook pro - my camera raw files from a canon 5d mark 2 are not being recognized... I found out that I need to update the camera raw plugin to version 5.2.  I downloaded the plug in and the computer said it succ

  • Sub Templates and Watermarks

    Hi, I need to do a BI Publisher report that uses different images for different companies. So, i though i would use sub templates. The main template is the fields, etc... and the sub templates are just the different company logos, images, etc.... But

  • How do I keep my attachments from showing in Mail?

    When I compose a new message and add an attachment, the file opens as if it's within the message itself. I don't like this because it's conflicting when I type the message. The cursor goes around the attachment and it's annoying. How do I attach with