Adam Bilinski
Adam Bilinski

Reputation: 1198

Error(5,3): PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: language

trying to create simple package with one procedure:

CREATE OR REPLACE 
PACKAGE PACKAGE1 AS 

procedure procHTML1 is
begin
htp.print('
<html>
 <head>
  <title>PL/SQL Example Pages</title>
 </head>
<body>');
end procHTML1;

END PACKAGE1;

but I get

Error(5,3): PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:     language 
Error(14,5): PLS-00103: Encountered the symbol "PACKAGE1" when expecting one of the following:     ; 

Any help will be appreciated

Upvotes: 6

Views: 27276

Answers (1)

Justin Cave
Justin Cave

Reputation: 231651

A package is composed of a package specification and a package body. You declare the procedure in the specification (assuming you want the procedure to be public) and you implement it in the body.

So, for example, you would create the package specification

CREATE OR REPLACE PACKAGE package1
AS
  PROCEDURE procHTML1;
END package1;

And then you would create the package body

CREATE OR REPLACE PACKAGE BODY package1
AS
  PROCEDURE procHTML1
  AS
  BEGIN
    htp.print( '<<some HTML>>' );
  END procHTML1;
END package1;

Upvotes: 16

Related Questions