PL/SQL Calling Java Program with Return as 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?

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?

Similar Messages

  • Calling Java Function with Return as 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?

    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?

  • 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.

  • Java program with return value, what is the best way?

    I was thinking something like this:
    public class A {
    public static int intMain(String... argv) {
    ///real program here
    public static void main(String... argv) {
    System.exit(intMain(argv));
    But System.exit does not await user threads and I use a library which creates threads where I do not have control.
    Is there a way to await every user thread without explicitly knowing them?

    I just want to return a value to the OS... zero in case of normal quit, non-zero in case of abnormal termination. I do not see anything complex in that. Actually it I think is crazy that Java mains are only void.
    About threads I use rabbitmq and it uses threads for its messaging. I noticed the problem because if I forget to correctly close rabbitmq objects the ``void main'' does not terminate while the ``int main'' does since system.exit does not wait.
    At the moment the question is more about curiosity, really there is no simple way to say ``await all users threads''?

  • How to call a dialog program with return value in another dialog program

    Dear All,
    How can I call a dialog program with return value from another dialog program?
    Regards,
    Alok.

    Hi Alok,
    You can you SET/GET parameters to do this.
    This is some information about this.
    To fill the input fields of a called transaction with data from the calling program, you can use the SPA/GPA technique. SPA/GPA parameters are values that the system stores in the global, user-specific SAP memory. SAP memory allows you to pass values between programs. A user can access the values stored in the SAP memory during one terminal session for all parallel sessions. Each SPA/GPA parameter is identified by a 20-character code. You can maintain them in the Repository Browser in the ABAP Workbench. The values in SPA/GPA parameters are user-specific.
    ABAP programs can access the parameters using the SET PARAMETER and GET PARAMETERstatements.
    To fill one, use:
    SET PARAMETER ID pid FIELD f.
    This statement saves the contents of field f under the ID pid in the SAP memory. The ID pid can be up to 20 characters long. If there was already a value stored under pid, this statement overwrites it. If you double-click pid in the ABAP Editor, parameters that do not exist can be created as a Repository object.
    To read an SPA/GPA parameter, use:
    GET PARAMETER ID pid FIELD f.
    This statement places the value stored under the pid ID into the variable f. If the system does not find any value for pid in the SAP memory, sy-subrc is set to 4. Otherwise, it sets the value to 0.
    Thanks,
    SriRatna

  • How to call java program by HTML page

    Hi guys,
    I'm new java programer and want to build an HTML page to access to ORACLE database on NT server by JDBC, Can anyone give me a sample?
    I already know how to access database by JDBC, but I don't know how to call java program by HTML page.
    If you have small sample,pls send to me. [email protected], thanks in advance
    Jian

    This code goes with the tutorial from this web page
    http://java.sun.com/docs/books/tutorial/jdbc/basics/applet.html
    good luck.
    * This is a demonstration JDBC applet.
    * It displays some simple standard output from the Coffee database.
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.util.Vector;
    import java.sql.*;
    public class OutputApplet extends Applet implements Runnable {
    private Thread worker;
    private Vector queryResults;
    private String message = "Initializing";
    public synchronized void start() {
         // Every time "start" is called we create a worker thread to
         // re-evaluate the database query.
         if (worker == null) {     
         message = "Connecting to database";
    worker = new Thread(this);
         worker.start();
    * The "run" method is called from the worker thread. Notice that
    * because this method is doing potentially slow databases accesses
    * we avoid making it a synchronized method.
    public void run() {
         String url = "jdbc:mySubprotocol:myDataSource";
         String query = "select COF_NAME, PRICE from COFFEES";
         try {
         Class.forName("myDriver.ClassName");
         } catch(Exception ex) {
         setError("Can't find Database driver class: " + ex);
         return;
         try {
         Vector results = new Vector();
         Connection con = DriverManager.getConnection(url,
                                  "myLogin", "myPassword");
         Statement stmt = con.createStatement();
         ResultSet rs = stmt.executeQuery(query);
         while (rs.next()) {
              String s = rs.getString("COF_NAME");
              float f = rs.getFloat("PRICE");
              String text = s + " " + f;
              results.addElement(text);
         stmt.close();
         con.close();
         setResults(results);
         } catch(SQLException ex) {
         setError("SQLException: " + ex);
    * The "paint" method is called by AWT when it wants us to
    * display our current state on the screen.
    public synchronized void paint(Graphics g) {
         // If there are no results available, display the current message.
         if (queryResults == null) {
         g.drawString(message, 5, 50);
         return;
         // Display the results.
         g.drawString("Prices of coffee per pound: ", 5, 10);
         int y = 30;
         java.util.Enumeration enum = queryResults.elements();
         while (enum.hasMoreElements()) {
         String text = (String)enum.nextElement();
         g.drawString(text, 5, y);
         y = y + 15;
    * This private method is used to record an error message for
    * later display.
    private synchronized void setError(String mess) {
         queryResults = null;     
         message = mess;     
         worker = null;
         // And ask AWT to repaint this applet.
         repaint();
    * This private method is used to record the results of a query, for
    * later display.
    private synchronized void setResults(Vector results) {
         queryResults = results;
         worker = null;
         // And ask AWT to repaint this applet.
         repaint();

  • Calling Java programs from Oracle Stored Procedure

    Is it possible to call Java programs from Oracle stored procs? If possible Can this be used to exchange data from other applications? Is there a better method/feature in oracle for doing data exchange with other apps?

    If what you mean by Oracle stored procedures is pl/sql then yes.
    You can create a "wrapper" this way:
    CREATE OR REPLACE FUNCTION xmlXform
    in_mapUrl IN VARCHAR2,
    in_inputUrl IN VARCHAR2
    RETURN VARCHAR2
    AS
    LANGUAGE JAVA NAME
    'com.yourcompany.xml2any.xform(java.lang.String,java.lang.String)
    RETURN java.lang.String';
    Then load the java as:
    loadjava -user youruser/youruserpasswd -resolve -verbose lib/xmlparserv2.jar classes/com/yourcompany/xform.class classes/com/yourcompany/xml2any.class
    The java, given the correct permissions, can do anything java can do including communicate with outside applications.
    Is this the "best" way... depends on what you are trying to accomplish.

  • How i can call java program in VB2005 ?

    Hi members...
    Please...please...please...
    If any one now how i can call java program in VB.net program and open it ,please i want now the way to do it by details and by examples and step step to do it ,,..
    thanks ...

    If your server does not return to the command prompt, write a java programm which starts your server and returns to the command prompt.
    An example for an application like this:
    import java.io.IOException;
    public class StartApp
    public static void main(String[] args)
    if (args.length > 0)
    StringBuffer cmd = new StringBuffer();
    for (int index = 0; index < args.length; index++)
    cmd.append(args[index] + " ");
    try
    Runtime.getRuntime().exec(cmd.toString());
    catch (IOException ioe)
    System.out.println("Error: command not found: " + cmd.toString());
    else
    System.out.println("Error: missing arguments");
    An example for starting your server with that programm:
    /usr/bin/java -jar ./StartApp.jar /usr/bin/java -jar ./myServer.jar
    It works. Have fun.

  • Error while calling java program from ABAP

    Hi Experts,
    We are trying for RFC inbound scenario.
    We followed the below blog
    /people/gregor.wolf3/blog/2004/08/26/setup-and-test-sap-java-connector-outbound-connection
    We are working with SAP JCO 3.0.2
    We are getting the error : 'STFC_CONNECTION' could not be found in the server repository.
    After I run the Java server program if I execute the RFC destination directly from SM 59 it is showing successful messages.
    If I stop the java program then this RFC is failing. Based on this we concluded that RFC to Java connection is working fine.
    But as mentioned in blog if we call the RFC Destination from ABAP program it is giving the below error,
    'STFC_CONNECTION' could not be found in the server repository.
    If we test the RFC destination using RFC_TRUSTED_CHECK standard FM we are getting the below error.
    'RFCPING' could not be found in the server repository.
    We create the RFC destination of Type : TCP/IP as exactly mention in the blog.
    Please help us in resolving this issue.
    Thanks
    Prince

    Pabi,
    Using the RFC connection,we can establish a link between Java and SAP.
    Afterwards,hope we can call Java program from ABAP.
    Below is the sample piece of code to establish RFC connection(link) between Java and SAP.
    DATA: REQUTEXT LIKE SY-LISEL,
          RESPTEXT LIKE SY-LISEL,
          ECHOTEXT LIKE SY-LISEL.
    DATA: RFCDEST like rfcdes-rfcdest VALUE 'NONE'.
    DATA: RFC_MESS(128).
    REQUTEXT = 'HELLO WORLD'.
    RFCDEST = 'JCOSERVER01'. "corresponds to the destination name defined in the SM59
    CALL FUNCTION 'STFC_CONNECTION'
       DESTINATION RFCDEST
       EXPORTING
         REQUTEXT = REQUTEXT
       IMPORTING
         RESPTEXT = RESPTEXT
         ECHOTEXT = ECHOTEXT
       EXCEPTIONS
         SYSTEM_FAILURE        = 1 MESSAGE RFC_MESS
         COMMUNICATION_FAILURE = 2 MESSAGE RFC_MESS.
    IF SY-SUBRC NE 0.
        WRITE: / 'Call STFC_CONNECTION         SY-SUBRC = ', SY-SUBRC.
        WRITE: / RFC_MESS.
    ENDIF.
    Regards,
    Sree

  • Calling java program in bipublisher

    Hi,
    Like we have datamodel types in BIPublisher as SQL Query, Webservice, Answers, File etc,, Can we call java program through bipublisher.
    The requirement is:
    A java program will generate BARCODE image based on the customer number given.
    We need to create a template in bipublisher which shows the customer name and that barcode image and other details.
    We have calling javaprograms in ibots in analytics, is there any such thing in bipublisher.
    Thanks.

    You can call PL/SQL programs from OWB either by defining transformations or as expressions. From PL/SQL you can call a java stored procedures in the database as follows:
    1. Define the java stored procedure. For example, let's suppose that you store the following Java class in the database:
    import java.sql.*;
    import oracle.jdbc.driver.*;
    public class Adjuster {
    public static void raiseSalary (int empNo, float percent)
    throws SQLException {
    Connection conn = new OracleDriver().defaultConnection();
    String sql = "UPDATE emp SET sal = sal * ? WHERE empno = ?";
    try {
    PreparedStatement pstmt = conn.prepareStatement(sql);
    pstmt.setFloat(1, (1 + percent / 100));
    pstmt.setInt(2, empNo);
    pstmt.executeUpdate();
    pstmt.close();
    } catch (SQLException e) {System.err.println(e.getMessage());}
    2. The class Adjuster has one method, which raises the salary of an employee by a given percentage. Because raiseSalary is a void method, you publish it as a procedure using this call spec:
    CREATE PROCEDURE raise_salary (empno NUMBER, pct NUMBER)
    AS LANGUAGE JAVA
    NAME 'Adjuster.raiseSalary(int, float)';
    3. Call procedure raise_salary from an anonymous PL/SQL block, as follows:Long postings are being truncated to ~1 kB at this time.

  • How to call  java program from ABAP

    Hi Experts,
         My requirement is to call java programs from ABAP. For that i have set up SAP JCO connection by using this link http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/739. [original link is broken] [original link is broken] [original link is broken] Connection gets sucessfully. After this how to call java program from ABAP as per our requirement. Please help me out.
      Also i tried this way also.. but while executing the DOS Command line appear & disappear in few seconds. So couldnt see the JAVA output. Please help me out to call java programs in ABAP..
    DATA:command TYPE string VALUE 'D:Javajdk1.6.0_20 injavac',
    parameter TYPE string VALUE 'D:java MyFirstProgram'.
    CALL METHOD cl_gui_frontend_services=>execute
    EXPORTING
    application = command
    parameter = parameter
    OPERATION = 'OPEN'
    EXCEPTIONS
    cntl_error = 1
    error_no_gui = 2
    bad_parameter = 3
    file_not_found = 4
    path_not_found = 5
    file_extension_unknown = 6
    error_execute_failed = 7
    OTHERS = 8.
    Thanks.

    This depends on the version of your Netweaver Java AS. If you are running 7.0, you will have to use the Jco framework. The Jco framework is deprecated since 7.1 though. If you want to build a RFC server in 7.1 or higher, it is adviced that you set it up through JRA.
    Implement an RFC server in 7.0:
    http://help.sap.com/saphelp_nw04/helpdata/en/6a/82343ecc7f892ee10000000a114084/frameset.htm
    Implement an RFC server in 7.1 or higher:
    http://help.sap.com/saphelp_nwce72/helpdata/en/43/fd063b1f497063e10000000a1553f6/frameset.htm

  • Calling Java program from ABAP

    Hi All,
    my ABAP program downloads one file to one folder. Then one Java program is running to Encrypt the file.
    Now , they want to call the JAVA program in ABAP, so that they can encrypt the file before downloading.
    Is it possible to call a Java program from ABAP ? If Yes, please give me the detailed procedure.
    Thanks
    pabi

    Pabi,
    Using the RFC connection,we can establish a link between Java and SAP.
    Afterwards,hope we can call Java program from ABAP.
    Below is the sample piece of code to establish RFC connection(link) between Java and SAP.
    DATA: REQUTEXT LIKE SY-LISEL,
          RESPTEXT LIKE SY-LISEL,
          ECHOTEXT LIKE SY-LISEL.
    DATA: RFCDEST like rfcdes-rfcdest VALUE 'NONE'.
    DATA: RFC_MESS(128).
    REQUTEXT = 'HELLO WORLD'.
    RFCDEST = 'JCOSERVER01'. "corresponds to the destination name defined in the SM59
    CALL FUNCTION 'STFC_CONNECTION'
       DESTINATION RFCDEST
       EXPORTING
         REQUTEXT = REQUTEXT
       IMPORTING
         RESPTEXT = RESPTEXT
         ECHOTEXT = ECHOTEXT
       EXCEPTIONS
         SYSTEM_FAILURE        = 1 MESSAGE RFC_MESS
         COMMUNICATION_FAILURE = 2 MESSAGE RFC_MESS.
    IF SY-SUBRC NE 0.
        WRITE: / 'Call STFC_CONNECTION         SY-SUBRC = ', SY-SUBRC.
        WRITE: / RFC_MESS.
    ENDIF.
    Regards,
    Sree

  • How do i call c++ programs(with visual c++)in oracle?

    how do i call c++ programs(with visual c++)in oracle?
    how do i store results which produced by c++ programs to oracle?
    results include picture(*.gif,*.bmp,*.jpg)and some variables.
    please tell me a way.hurry!!!

    You would have to write your C++ programs as DLLs and then use something like the following:-
    CREATE OR REPLACE PROCEDURE messagebeep
         (p_uint IN BINARY_INTEGER)
         AS EXTERNAL LIBRARY user32 NAME "MessageBeep"
         CALLING STANDARD PASCAL;
    Within your C++ code you would then access the database to update your tables etc.
    The way I see it is that you want processing to go Oracle --> C++ --> Oracle.
    Do you really need the C++ layer ?
    Hope this helps.
    Adrian

  • Interfacing a java program with hardware

    I need to be able to interface a java program
    with data in the parallel or serial ports of the computer.
    I have no idea how to go about this, could someone please help me.
    Thanks

    http://java.sun.com/products/javacomm/

  • Is there any way to call java program whenever i login to R3 System.?

    Hi Experts
    Is there any way to call java program whenever i login to R3 System.
    Means Whenever the user login to R3 system i should trigger one java program.. Is there any way
    Please help me
    Thanks & Regards
    Ravi Shankar B

    If you want to access to the Windows Taskbar, you should call some Win32 APIs and JNI. Refer to Win32 references.

Maybe you are looking for

  • How do I find how a particular dameon is getting started?

    This is a new question prompted by discovering a Canon Scanner process that is getting started on my MacPro. To summarize, I have a Canon Pixma MP800R All-In-One printer. Everything has been working fine but today I've gotten 4 kernel panics in a row

  • Material Master tax Category Issue

    Hi all, I have some doubt in Material Master sales view. I want to know the Database Table name in which the field Tax Category (TATYP) and tax classification(TAXKN) stored. I know that these tables are stored in the stucture during creation of mater

  • SNOTE related

    All, I have snote to be going to apply. My question is how we can find whether the same SNOTE correction already in the system thru some service patch updation. in that i need not to reapply the note again. I think thru SNOTE transaction we cannot fi

  • Business Packages EP 7.0

    Hi Experts, Im currently involved in EP 6.0 to EP 7.0 Upgrade. Im new to Portal. Can you please help me which are the business pacakages needs to be activated. We dont have LSO, E Rec rest we have in Portal. Thanks Priya

  • I just installed Lion, and I find my Mail inbox quite incomplete.

    I just installed Lion, and I find my Mail inbox quite incomplete. Yet when I look in my "Smart Mailboxes" I can find the new emails that I was looking for, so they are getting here, just not to my "Inbox". Help!