Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> AW: Object Types in PL/SQL

AW: Object Types in PL/SQL

From: Stefan Jahnke <Stefan.Jahnke_at_bov.de>
Date: Wed, 16 Jul 2003 09:07:51 +0200
Message-Id: <25929.337939@fatcity.com>


Thanks all. Looks like I'll have to go with the "add-an-extra-parameter" method for now as a workaround.
I don't know yet wether we're going to raise a TAR right away. The manual is a little bit unclear about overriding the default constructor. So I might contact a friend at Oracle first. I'll post any results on that. We actually don't use Object Types that much (who does anyway ;). But I have to say, that I'm a little bit disappointed by Oracle's implementation (Ever heard of information hiding and encapsulation, Larry ?). If every developer using the type will be allowed to set the attributes (to whatever value), what's the point ? How about "private" vs. "public" ?! Well, at least they give you a way to initialize Object Types somehow.

Stefan

-----Ursprüngliche Nachricht-----

Von: Pardee, Roy E [mailto:roy.e.pardee_at_lmco.com] Gesendet: Dienstag, 15. Juli 2003 16:59
An: Multiple recipients of list ORACLE-L Betreff: RE: Object Types in PL/SQL

This doesn't answer your question directly, but if you aren't able to override the constructor explicitly, you can probably create a static function that creates, initializes & returns a tVNR as you would like it.

HTH,
-Roy

Roy Pardee
Programmer/Analyst/DBA
SWFPAC Lockheed Martin IT
Extension 8487

-----Original Message-----

Sent: Tuesday, July 15, 2003 3:49 AM
To: Multiple recipients of list ORACLE-L

Hi list

I have a problem regardint PL/SQL Object Types. According to the fine manual, it should be
possible to override the default constructor (I'm on 9.2.0.3.0 Win2k). I did that, Object Type
compiles without complaints:

CREATE OR REPLACE TYPE tVNR AS OBJECT
(  

  vVNR VARCHAR2(14),   

  CONSTRUCTOR FUNCTION tVNR(piVNR VARCHAR2)   RETURN SELF AS RESULT,      MEMBER FUNCTION getVNR
  RETURN VARCHAR2    ) INSTANTIABLE FINAL; CREATE OR REPLACE TYPE BODY tVNR AS

  CONSTRUCTOR FUNCTION tVNR(piVNR VARCHAR2)   RETURN SELF AS RESULT IS
  BEGIN
    IF (LENGTH(piVNR)=11) THEN
      SELF.vVNR := SUBSTR(piVNR,1,4) || '.' || SUBSTR(piVNR,5,4) || '.' || SUBSTR(piVNR,9,3);

    ELSE
      SELF.vVNR := 'invalid';
    END IF;
    RETURN;
  END;   MEMBER FUNCTION getVNR RETURN VARCHAR2 IS   BEGIN
    RETURN SELF.vVNR;
  END;
END; Now, everytime I want to create an object like this:

declare
  vVNR tVNR;
begin
  vVNR := new tVNR('12345678901');
  dbms_output.put_line(vVNR.getVNR());
end;

I get the following error message:

ERROR at line 4:

ORA-06550: line 4, column 15:
PLS-00307: too many declarations of 'TVNR' match this call
ORA-06550: line 4, column 3:

PL/SQL: Statement ignored

Looks to me like the PL/SQL enginge isn't able to distinguish the default constructor from the
overridden (my) version, since they have the same signature (of course).

Any input ? I couldn't find ANY descenct hints in the fine manual or the Feuerstein book :(.

TIA,
Stefan  

--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Stefan Jahnke
  INET: Stefan.Jahnke_at_bov.de

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services

---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Pardee, Roy E
  INET: roy.e.pardee_at_lmco.com
Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services

---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may Received on Wed Jul 16 2003 - 02:07:51 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US