user2488578
user2488578

Reputation: 916

Error: PLS-00103: Encountered the symbol ")" when expecting one of the following

When I press F8 in PL/SQL developer for Package MyPackage creation I get below error

Error: PLS-00103: Encountered the symbol ")" when expecting one of the following:

          <an identifier> <a double-quoted delimited-identifier>
          current delete exists prior
Line: 24
Text: FUNCTION MyFunction() RETURN VARCHAR;

Below is the code

CREATE OR REPLACE PACKAGE MyPackage AS
FUNCTION MyFunction() RETURN VARCHAR;
END MyPackage;

CREATE OR REPLACE PACKAGE BODY MyPackage AS

FUNCTION MyFunction RETURN VARCHAR2 IS
        l_pram mytable.param_val%TYPE;
    BEGIN
        SELECT SomeColumnVal INTO l_pram FROM mytable WHERE SomeColumn = 'SomeValue';
        RETURN l_pram;
END MyFunction; 

END MyPackageBody;

Upvotes: 1

Views: 8178

Answers (1)

pablomatico
pablomatico

Reputation: 2242

You have several errors:

First, just drop the parenthesis as you did in the package body. As the function doesn't have any params, you don't need them. Second, make sure the return type in the spec is the same you use in the body, in this case you should use VARCHAR2

CREATE OR REPLACE PACKAGE MyPackage AS
  FUNCTION MyFunction RETURN VARCHAR2;
END MyPackage;

Last, the end name in the package body should be the same you used in the spec, i.e., MyPackage instead of MyPackageBody

CREATE OR REPLACE PACKAGE BODY MyPackage AS

  FUNCTION MyFunction RETURN VARCHAR2 IS
    l_pram mytable.param_val%TYPE;
  BEGIN
    SELECT SomeColumnVal INTO l_pram FROM mytable WHERE SomeColumn = 'SomeValue';
    RETURN l_pram;
  END MyFunction; 

END MyPackage;

Upvotes: 2

Related Questions