Re: functions in packages

From: DA Morgan <damorgan_at_exesolutions.com>
Date: Wed, 12 Feb 2003 21:08:15 -0800
Message-ID: <3E4B283F.2AE2DDEE_at_exesolutions.com>


Dwayne wrote:

> I am having trouble putting a function in a package body
> the problem now lies in putting the function in the package body. I
> keep getting syntax errors.
>
> let me show you:
>
> CREATE OR REPLACE PACKAGE CAP
> IS
> FUNCTION LAST_CAP RETURN VARCHAR2;
> END;
> /
>
> Package created.
>
> 1 CREATE OR REPLACE PACKAGE BODY CAP
> 2 IS
> 3 FUNCTION LAST_CAP
> 4 (NAME VARCHAR2)
> 5 RETURN VARCHAR2
> 6 IS
> 7 BEGIN
> 8 RETURN LOWER(SUBSTR(NAME,1,LENGTH(NAME)-1))||UPPER(SUBSTR(NAME,-1));
> 9 END LAST_CAP;
> 10* end;
> SQL> /
>
> Warning: Package Body created with compilation errors.
>
> SQL> show error
> Errors for PACKAGE BODY CAP:
>
> LINE/COL ERROR
> -------- -----------------------------------------------------------------
> 3/10 PLS-00323: subprogram or cursor 'LAST_CAP' is declared in a
> package specification and must be defined in the package body
>
> I spent 3 hours on this trying different combos but nothing.

There is no relationship between what you have written in the package header [Quoted] and the function in the package body. The package header does not reference [Quoted] your input parameter NAME VARCHAR2.

Daniel Morgan Received on Thu Feb 13 2003 - 06:08:15 CET

Original text of this message