Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sql

oracle

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

like image 408
Adam Bilinski Avatar asked Dec 12 '22 02:12

Adam Bilinski


1 Answers

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;
like image 134
Justin Cave Avatar answered May 21 '23 23:05

Justin Cave