DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: A Noob's PL/SQL Problem

  1. #1
    Join Date
    Nov 2005
    Posts
    3

    A Noob's PL/SQL Problem

    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

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Drop the DECLARE
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  3. #3
    Join Date
    Jun 2005
    Location
    London, UK
    Posts
    159
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width