1

Please check Java code of Oracle. I like to get the println() output into oracle console like DBMS_OUTPUT.PUT_LINE().

I have also created a function/procedure (without return in java) to call the java function. it executed fine and return the value (for function), BUT don't print anything into Oracle console (ServerOutput).

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "Azam/Azam_Test" as package Azam;

import java.lang.*;
public class Azam_Test {

    public static String Azam_Test_Print(String testString) {
      System.out.println(testString); // want this output into ORACLE console
      return testString;
    }
}

2 Answers 2

2

Here's a working full script.

SQL> SET SERVEROUTPUT ON
SQL> CALL dbms_java.set_output(2000);

Call completed.

SQL> 
SQL> CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "MyOutput" as
  2  
  3  import java.lang.*;
  4  public class MyOutput {
  5  
  6      public static String print(String testString) {
  7        System.out.println(testString); // want this output into ORACLE console
  8        return testString;
  9      }
 10  }
 11  /

Java Source MyOutput created

SQL> 
SQL> create or replace procedure Test_Output(testString in varchar2)
  2  as LANGUAGE JAVA
  3  NAME 'MyOutput.print(java.lang.String)';
  4  /

Procedure TEST_OUTPUT compiled

SQL> 
SQL> exec Test_Output('Hello');
Hello


PL/SQL procedure successfully completed.

SQL> 
Sign up to request clarification or add additional context in comments.

Comments

1

Documentation DBMS_JAVA and procedure DBMS_JAVA.SET_OUTPUT(2000000)

Check also DBMS_JAVA.SET_OUTPUT_TO_SQL, it is more useful

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.