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: Java program in Oracle

Re: Java program in Oracle

From: M <someone_at_microsoft.com>
Date: Sun, 31 Aug 2003 00:00:20 +0800
Message-ID: <biqin1$1m8h$1@news.hgc.com.hk>


Thanks Harald.

I followed your steps and so far it's alright except that I have error in the statement
"call helloworld() into :res" !

I tried "select helloworld() into :res from dual" but still not work!

Any hint for me?
Thanks again.

"Harald Maier" <maierh_at_myself.com> wrote in message news:m3fzjjednu.fsf_at_ate.maierh...
> "M" <someone_at_microsoft.com> writes:
>
> > Any example to "write" java code in PL/SQL? I have experience in
> > writing PL/SQL but with just little experience in Java. Any example
> > will be helpful.
>
> The following three files work for me. You need to compile the
> Hello.java file and then load it with the loadjava command.
>
> $ javac Hello.java
> $ loadjava -user scott/tiger Hello.class
>
> Hello.sql publishes the java class as PL/SQL function. And
> HelloTest.sql invokes the function.
>
> Harald
>
> ,----[ Hello.java ]
> | /* Note: this class is not executable because the class specification
> | * does not have a main function.
> | */
> |
> | public class Hello{
> | public static String world (){
> | return "Hello world";
> | }
> | }
> `----
>
> ,----[ Hello.sql ]
> | connect scott/tiger;
> | create or replace function HELLOWORLD return VARCHAR2 as
> | language java name 'Hello.world () return java.lang.String';
> | /
> `----
>
> ,----[ HelloTest.sql ]
> | connect scott/tiger;
> | variable res varchar2(20);
> | call helloworld() into :res;
> | print res;
> `----
Received on Sat Aug 30 2003 - 11:00:20 CDT

Original text of this message

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