1 Reply Latest reply: Feb 18, 2014 11:22 AM by rp0428 RSS

    Create non static java method in pl sql

    936666

      Can we call a non static java method as stored procedure or function in pl sql statement?

      If so can you provide some examples....

       

      here is the scenario...

       

      public class test{

      test(String s1,String s2){

      .

      .

      .

       

      }

       

      String read(String  info, int record_count) throws SQLException

      {

      // reads table information and process it ....

       

      long qtime =(System.currentTimeMillis());

        System.out.println(qtime);

       

      }

       

      }

       

      how to map read non static java method  as stored procedure / function call in oracle

       

      eg:

      CREATE OR REPLACE FUNCTION fn_test RETURN VARCHAR2 AS

          LANGUAGE JAVA NAME 'test.read() return java.lang.String';

         /

       

      DECLARE

      my_string VARCHAR2(400 CHAR);

      BEGIN

      my_string := fn_test('param1');

      dbms_output.put_line( my_string);

      END;

        • 1. Re: Create non static java method in pl sql
          rp0428

          WRONG FORUM!

           

          You should have posted this question in the PL/SQL forum with your other question.

           

          Yes - you can call non-static methods. See the example in the Java Developers Guide

          http://docs.oracle.com/cd/B28359_01/java.111/b31225/chsix.htm#BABFBCBD

          Declaring Methods

          After declaring attributes, you can declare methods. MEMBER methods accept a built-in parameter known as SELF, which is an instance of the object type. Whether declared implicitly or explicitly, it is always the first parameter passed to a MEMBER method. In the method body, SELF denotes the object whose method was called. MEMBER methods are called on instances, as follows:

          instance_expression.method()  

           

          Use the 'Examples' link for an example.,