Sunday, February 16, 2020

Calling JAVA class using Oracle database


--1) JAVA Class use in PLSQL block using Function:

       Using PLSQL you can run Java stored procedures in the same way as PLSQL stored procedures.
       In oracle database, Java is usually invoked through PLSQL interface.
     
       -- 1) Create Java class

              CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Technical" AS
              public class Technical
             {
                public static String test007()
               {
                return "Oracle Technical";
               }
            };
            /

       -- 2) Create PLSQL Function to call Java class

             CREATE OR REPLACE FUNCTION Technicaltest007
             RETURN VARCHAR2 AS
                LANGUAGE JAVA NAME 'Technical.test007 () return java.lang.String';
             /

      -- 3) Write PLSQL Block to call created Function
     
             SET SERVEROUTPUT ON;
             DECLARE
                   lc_string VARCHAR2(300);
             BEGIN
                   lc_string := Technicaltest007();
                   dbms_output.put_line('The value of the string is:'||lc_string);
             END;
           /

No comments:

Post a Comment

Steps to get ZPL code output using Zebra viewer - Online

Introduction ZPL is a print language used by many label printers. A print language is a set of commands that can be used to draw elements li...