Loading

Sunday, December 22, 2013

Java Stored Procedure in ORACLE PLSQL – A simple example















In this post, I tried the below,
  1. Create a simple class via PLSQL
  2. Verify the same in DB_OBJECTS
  3. Create a simple procedure to Invoke the member function of the class created above
  4. Test the script
  5. Drop the Java class created 

Create a simple class via PLSQL

CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "HelloWorldApp" AS
class helloworldapp {
    public static void sayhello() {
        system.out.println("hello world!!! this is www.shareoracleapps.com");
    }
};


Verify the same in DB_OBJECTS


Create a simple procedure to Invoke the member function of the class created above

CREATE OR REPLACE PROCEDURE test_hello_world
AS
   LANGUAGE JAVA
   NAME 'HelloWorldApp.sayHello()';

Test the script

SET SERVEROUTPUT ON;
CALL DBMS_JAVA.set_output(2000);
CALL test_hello_world();

Drop the Java class created 




I hope this helps for beginners.


0 Responses to “Java Stored Procedure in ORACLE PLSQL – A simple example”

Post a Comment

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.