Package Error
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Package Error

  1. #1
    Join Date
    Jan 2001
    Posts
    515
    I am trying to compile my package and I am getting the following error:


    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    7/1 PLS-00103: Encountered the symbol "CURSOR" when expecting one of
    the following:
    language
    the first couple lines of my code look like:

    create or replace package retention_pack as

    procedure check_retention(
    p_out out number) as

    cursor c1 is
    select * from ccfdba.retention where export = 'Y'
    and table_name = 'TODD' and owner = 'CCFDBA';

    Any ides?


  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    create or replace package retention_pack is

    procedure check_retention(
    p_out out number) is

    cursor c1 is
    select * from ccfdba.retention where export = 'Y'
    and table_name = 'TODD' and owner = 'CCFDBA';
    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

  3. #3
    Join Date
    Jan 2001
    Posts
    515

    It didn't work

    I get the same error

  4. #4
    Join Date
    Jan 2001
    Posts
    515

    found it

    I didn't have the word body in create or replace package body. Thanks for your help.

  5. #5
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Here's a quickie example to get you started:
    Code:
    SQL> create or replace package jh1 is
      2     function version return varchar2;
      3     function doit return integer;
      4  end jh1;
      5  /
    
    Package created.
    
    SQL> create or replace package body jh1 is
      2     function version return varchar2
      3     is 
      4        ver varchar2(80) := '1.01';
      5     begin
      6        return ver;
      7     end version;
      8  
      9     function doit return integer 
     10     is
     11        i number;
     12        cursor c1 is select table_name from user_tables;
     13  
     14     begin
     15        i := 0;
     16        for x in c1 loop
     17           i:=i+1;
     18        end loop;
     19        return i;
     20     end doit;
     21  end jh1;
     22  /
    
    Package body created.
    
    SQL> exec dbms_output.put_line(jh1.doit);
    32
    
    PL/SQL procedure successfully completed.
    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

  6. #6
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925

    create or replace package retention_pack as

    procedure check_retention(
    p_out out number);

    cursor c1 is
    select * from ccfdba.retention where export = 'Y'
    and table_name = 'TODD' and owner = 'CCFDBA';

    END retention_pack;


    If you are planning to use the cursor in the package then you would have somethink like this. Or you can just define things like


    create or replace package retention_pack as

    procedure check_retention(
    p_out out number);

    end retention_pack;


    and in your package body, under the procedure declaration you can write the cursor.

    Sam
    Thanx
    Sam



    Life is a journey, not a destination!


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