Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Writing PL/SQL in Java.

Re: Writing PL/SQL in Java.

From: <sybrandb_at_hccnet.nl>
Date: Thu, 31 May 2007 17:51:12 +0200
Message-ID: <3lrt531l7gh0tdsa0g8sdcla687os4idg4@4ax.com>


On Thu, 31 May 2007 18:01:31 +0300, "Mr. X." <no_spam_please_at_nospam_please.com> wrote:

>Thanks,
>I see some example on the internet.
>I didn't understand how can I publish java code,
>so I can use at the package something like :
>
>The example :
>-------------
>public class Formatter {
> public static String formatEmp (String empName, String jobTitle) {
> empName = empName.substring(0,1).toUpperCase() +
> empName.substring(1).toLowerCase();
> jobTitle = jobTitle.toLowerCase();
> if (jobTitle.equals("analyst"))
> return (new String(empName + " is an exempt analyst"));
> else
> return (new String(empName + " is a non-exempt " + jobTitle));
> }
>}
>
>The class Formatter has one method named formatEmp, which returns a
>formatted string containing a staffer's name and job status. First, you
>write the call spec for this method as follows:
>
>CREATE OR REPLACE FUNCTION format_emp (ename VARCHAR2, job VARCHAR2)
> RETURN VARCHAR2
>AS LANGUAGE JAVA
>NAME 'Formatter.formatEmp (java.lang.String, java.lang.String)
> return java.lang.String';
>
>...Should I compile java somewhere on the server ?How can I do that ?Need
>sample or link, please.Thanks :)
>

Actually there is, provided you call it in SQL, no reason at all why you should code a function: this can be done directly in SQL and neither a Java nor a PL/SQL function is required.

-- 
Sybrand Bakker
Senior Oracle DBA
Received on Thu May 31 2007 - 10:51:12 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US