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

Home -> Community -> Usenet -> c.d.o.server -> Re: Call Specification Example in Java Developers Guide Does Not Compile

Re: Call Specification Example in Java Developers Guide Does Not Compile

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Mon, 03 Jan 2000 17:09:27 -0500
Message-ID: <id727s4i73h57be9bf9f9ktp33im68k5oo@4ax.com>


A copy of this was sent to "Tim Romano" <tim_at_ot.com> (if that email address didn't require changing) On Mon, 3 Jan 2000 16:31:48 -0500, you wrote:

>In the 8i Java Developers Guide (p.44), there's a Call Specification for a
>java sample which does not compile. Here it is typed, just as it appears in
>the Guide:
>
>SQL> create or replace function HELLOWORLD return VARCHAR2 as
> 2 language java name 'Hello.world () return java.lang.String';
> 3 myString varchar2();
> 4 call HELLOWORLD() into :myString;
> 5 print myString;
> 6 /
>Warning: Function created with compilation errors.
>
>SQL> show errors;
>Errors for FUNCTION HELLOWORLD:
>
>LINE/COL ERROR
>-------- -----------------------------------------------------------------
>3/1 PLS-00103: Encountered the symbol "MYSTRING"
>
>
>What should this call specification look like? Declaring myString with a
>size [varchar2(20)]does not help. Putting a slash after the semicolon ending
>line 2 does not help.
>

you need a slash after line 2 in column 1. it should be "variable mystring varchar2(N)" on line 3 (N is some integer)

Here is a direct cut and paste on Win NT using 8.1.5. I compile, load, type on the screen, and run the java subroutine:

C:\WINNT\Profiles\tkyte\Desktop\test>sqlplus tkyte/tkyte

SQL*Plus: Release 8.1.5.0.0 - Production on Fri Dec 31 09:43:47 1999

(c) Copyright 1999 Oracle Corporation. All rights reserved.

Connected to:
Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production

tkyte_at_ORACLE> @a
tkyte_at_ORACLE>
tkyte_at_ORACLE> host "C:\Program Files\Oracle\JDeveloper 3.0\java\bin\javac"
Hello.java

tkyte_at_ORACLE>
tkyte_at_ORACLE> host loadjava -user tkyte/tkyte Hello.class

tkyte_at_ORACLE>
tkyte_at_ORACLE> host type Hello.java
import java.lang.*;
import java.lang.Throwable;

class Hello {
static public String World()
{

        return "Hello World";
}
}

tkyte_at_ORACLE>
tkyte_at_ORACLE> create or replace function HELLOWORLD return   2 varchar2 as
  3 language java name 'Hello.World() return   4 java.lang.string';
  5 /

Function created.

tkyte_at_ORACLE>
tkyte_at_ORACLE> variable myString varchar2(25);
tkyte_at_ORACLE> call HelloWorld() into :myString
  2 /

Call completed.

tkyte_at_ORACLE>
tkyte_at_ORACLE> print myString

MYSTRING



Hello World

tkyte_at_ORACLE>

>Thanks!
>
>

--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Mon Jan 03 2000 - 16:09:27 CST

Original text of this message

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