Re: Is this a bug...

From: Jusung Yang <jusungyang_at_yahoo.com>
Date: 12 Sep 2002 23:35:27 -0700
Message-ID: <42ffa8fa.0209122235.209c3cdd_at_posting.google.com>


You can create a package specification this way, but you will get error when you try to create the package body.

SQL> CREATE OR REPLACE PACKAGE testpkg AS   2

  3     TYPE foo IS REF CURSOR;
  4     foo   NUMBER;
  5     foo   VARCHAR2 (5);
  6     foo   DATE;
  7     foo   CONSTANT number := 4;
  8     foo   CONSTANT varchar2(6) := 'QWERTY';
  9     foo   CONSTANT date := SYSDATE;
 10     procedure proc1;

 11 END testpkg;
 12 /

Package created.

SQL> create or replace package body testpkg as   2 procedure proc1 is
  3 begin
  4 dbms_output.put_line(to_char(foo));   5 end;
  6 end;
  7 /

Warning: Package Body created with compilation errors.

SQL> show errors
Errors for PACKAGE BODY TESTPKG:

LINE/COL ERROR

-------- -----------------------------------------------------------------
4/1      PL/SQL: Statement ignored
4/30     PLS-00371: at most one declaration for 'FOO' is permitted in
the
         declaration section



hap_at_mikomi.org (Adam Hapworth) wrote in message news:<a6cb04db.0209121719.2bd3efac_at_posting.google.com>...
> rajXesh_at_hotmail.com (RK) wrote in message news:<548b9514.0209120544.539306df_at_posting.google.com>...
> > Is this a bug?
> >
> > I can define a package as
> >
> >
> > CREATE OR REPLACE PACKAGE testpkg AS
> >
> > TYPE foo IS REF CURSOR;
> > foo NUMBER;
> > foo VARCHAR2 (5);
> > foo DATE;
> > foo CONSTANT number := 4;
> > foo CONSTANT varchar2(6) := 'QWERTY';
> > foo CONSTANT date := SYSDATE;
> >
> > END testpkg;
>
> Actually it is doing exactly what you told it to do. Basically you
> are redefining the variable foo mutiple times. The last time you
> define it is what it will be in your program.
>
>
> try doing this after you compile you package
>
> SQL> exec dbms_output.put_line(testpkg.foo) -- since foo is a CONSTANT
> 12-SEP-02
> SQL>
>
> What happened is normal and not a bug just "sloppy" coding practices.
>
> Adam
Received on Fri Sep 13 2002 - 08:35:27 CEST

Original text of this message