Keywords: TOAD, PL/SQL , SQLPLUS, Oracle Java Object, Convert Oracle code to use as Oracle Functions.
You might have seen Java in Oracle TOAD, But wonder how to use Java there?
Yes you can write simple java code in Toad or sqlplus.
Please refer to the below steps and you can write some nice java code to use in PL/SQL.
Examples why you might have to use Java:
Some complex String manipulations or might have to make decision on reading some data from files. You probably could call web services and get some data and return inside pl/sql
I did not try calling WS, but since you can write java code, I don’t think you will be limited to any java extensibility.
Below is a sample Hello World and imagination is only your limit to extend your java skills when using oracle.
-- Step 1 DROP Java Source DROP JAVA SOURCE "HelloRayudu"; |
-- Step 2 Create Java Source and Class and a static method CREATE JAVA SOURCE NAMED "HelloRayudu" AS public class HelloRayudu { public static String hello() { return "Hello Rayudu"; } }; |
-- Step 3 Create equivalent Oracle Package and function CREATE OR REPLACE PACKAGE APPIAN_TMS.JAVATEST AS FUNCTION hello return VARCHAR2 AS LANGUAGE java NAME 'HelloRayudu.hello() return java.lang.String'; end; |
-- Step 4 Execute the function created above SELECT JAVATEST.hello FROM DUAL; |
Once this steps are done, you will be able to see the class in Schema browser as above and details like below.
Rayudu Addagarla
No comments:
Post a Comment