Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Object type with constructor gets PLS-00307 (10g)

600949May 20 2008 — edited May 20 2008

Hi all,

I have the following code, and I am getting the following error. I want to have a constructor that can be called without specifying the parameters by name. Is that not possible?

What am I doing wrong?

Thanks!

Error:

Error at line 50
ORA-06550: line 5, column 17:
PLS-00307: too many declarations of 'TRANSFEROBJECT_O' match this call
ORA-06550: line 5, column 5:
PL/SQL: Statement ignored

Code:

DROP TYPE TransferObject_o
/

CREATE TYPE
    TransferObject_o
AS OBJECT
(
    m_objectId  NUMBER(15)
  , m_attribute VARCHAR2(4000)
  , CONSTRUCTOR FUNCTION TransferObject_o
    (
        p_objectId  NUMBER--   := NULL
      , p_attribute VARCHAR2-- := NULL
    ) RETURN SELF AS RESULT
);
/

CREATE TYPE BODY
    TransferObject_o
AS
    CONSTRUCTOR FUNCTION TransferObject_o
    (
        p_objectId  NUMBER--   := NULL
      , p_attribute VARCHAR2-- := NULL
    ) RETURN SELF AS RESULT
    IS
    BEGIN
        SELF.m_objectId  := p_objectId;
        SELF.m_attribute := p_attribute;
        RETURN;
    END;
END;
/

DECLARE
    l_object TransferObject_o;
BEGIN
    l_object := TransferObject_o(1, 'B');
END;
/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 17 2008
Added on May 20 2008
1 comment
509 views