Click to See Complete Forum and Search --> : A Noob's PL/SQL Problem


pyrocks
11-18-2005, 06:09 PM
Heya all,

I'm kinda new to pl/sql and while going through some trial-and-error period I encountered the following problem:

I can execute the following pl/sql code and get a result (pasted from sqlplus):

SQL> DECLARE
2 V_ENAME EMP.ENAME%TYPE;
3 BEGIN
4 SELECT ENAME
5 INTO V_ENAME
6 FROM EMP
7 WHERE EMPNO=7900;
8 DBMS_OUTPUT.PUT_LINE(V_ENAME);
9 END;
10 /
JAMES

PL/SQL procedure successfully completed.

BUT, Whenever I try to put this code as a procedure in a package I get "Warning: Package Body created with compilation errors."
This is the pl/sql code for the package:

CREATE OR REPLACE PACKAGE testing AS
PROCEDURE test;
END testing;
/
--comment: the above code completes successfuly

CREATE OR REPLACE PACKAGE BODY testing AS
PROCEDURE test IS
DECLARE
V_ENAME EMP.ENAME%TYPE;
BEGIN
SELECT ENAME
INTO V_ENAME
FROM EMP
WHERE EMPNO=7900;
DBMS_OUTPUT.PUT_LINE(V_ENAME);
END test;
END testing;
/
--comment: the above code returns Warning.
I also tried to "SHOW ERRORS PROCEDURE test" and got "No Errors".

Does anyone have an idea of why as a pl/sql the code works but as a procedure within a package it doesn't?

Thanks in advance!
-Pyrocks

slimdave
11-18-2005, 08:23 PM
Drop the DECLARE

WilliamR
11-18-2005, 08:28 PM
Also it's the package body that has the errors, not "PROCEDURE TEST". The default SHOW ERRORS will report on the last thing you compiled.