Hi all,

I apologize for the length of this post, but there is a lot of example code necessary to display the bad behavior.

I have the following types:

Code:
CREATE OR REPLACE TYPE OSimple AS OBJECT
(
	m_spork		VARCHAR2(42),
	m_blancmanged	DATE,
	m_wibbles	NUMBER ,

	CONSTRUCTOR FUNCTION OSimple (
		spork		VARCHAR2
	) RETURN SELF AS RESULT,

	CONSTRUCTOR FUNCTION OSimple (
		clone		OSimple
	) RETURN SELF AS RESULT
);
/
SHOW ERRORS

CREATE OR REPLACE TYPE BODY OSimple AS
	CONSTRUCTOR FUNCTION OSimple (
		spork		VARCHAR2
	) RETURN SELF AS RESULT AS
	BEGIN
		m_spork := spork;
		m_blancmanged := sysdate;
		m_wibbles := 42;
		RETURN;
	END;

	CONSTRUCTOR FUNCTION OSimple (
		clone		OSimple
	) RETURN SELF AS RESULT AS
	BEGIN
		m_spork := clone.m_spork;
		m_blancmanged := clone.m_blancmanged;
		m_wibbles := clone.m_wibbles;
		RETURN;
	END;
END;
/
SHOW ERRORS
And:

Code:
CREATE OR REPLACE TYPE OComposite AS OBJECT
(
	m_goomba	VARCHAR2(42),
	m_frobbed	DATE,
	m_schlubs	NUMBER,
	m_thing1	OSimple,
	m_thing2	OSimple
);
/
SHOW ERRORS

Now, if I try to make an object view like this:

Code:
CREATE OR REPLACE VIEW composites OF OComposite WITH OBJECT IDENTIFIER (m_goomba) AS
SELECT goomba, frobbed, schlubs,
       OSimple(spork1, blancmanged2, wibbles2) AS thing1,
       OSimple(spork2, blancmanged2, wibbles2) AS thing2
  FROM composite;

I get the following error:

Code:
SQL> @plsql/vew_composites
                                                                                                                                         
View created.
                                                                                                                                         
       OSimple(spork1, blancmanged2, wibbles2) AS thing1,
       *
ERROR at line 3:
ORA-00932: inconsistent datatypes: expected UDT got -

If I remove all of the user-defined constructors for the OSimple object (this is similar to the example in the Oracle documentation):

Code:
CREATE OR REPLACE TYPE OSimple AS OBJECT
(
	m_spork		VARCHAR2(42),
	m_blancmanged	DATE,
	m_wibbles	NUMBER
);
/
SHOW ERRORS
Then I don't get the error, and the view compiles. I can also get the view to compile by using a constructor other than the default attribute constructor, like this:

Code:
CREATE OR REPLACE VIEW composites OF OComposite WITH OBJECT IDENTIFIER (m_goomba) AS
SELECT goomba, frobbed, schlubs,
       OSimple(spork1) AS thing1,
       OSimple(spork2) AS thing2
  FROM composite;
I can also create a pseudo-object view like this:

Code:
CREATE OR REPLACE VIEW composites1 AS
SELECT OComposite(goomba, frobbed, schlubs,
       OSimple(spork1, blancmanged1, wibbles1),
       OSimple(spork2, blancmanged2, wibbles2)) as thing
  FROM composite;
But you can't put a WHERE clause on a SELECT from a view created in this fashion.

So the question is (finally), how do I create nested object views using the default attribute constructor for the nested objects, where the nested objects have user-defined constructors as well?

As a side note, I attempted to override the default attribute constructor in OSimple with one of my own:

Code:
	CONSTRUCTOR FUNCTION OSimple (
		SELF		IN OUT OSimple,
		spork		IN VARCHAR2,
		blancmanged	IN DATE,
		wibbles		IN NUMBER
	) RETURN SELF AS RESULT AS
	BEGIN
		m_spork := spork;
		m_blancmanged := NVL(blancmanged, sysdate);
		m_wibbles := NVL(wibbles, 42);
		RETURN;
	END;

but using the constructor in other code:

Code:
	CONSTRUCTOR FUNCTION OComposite (
		goomba		VARCHAR2,
		frobbed		DATE,
		schlubs		NUMBER
	) RETURN SELF AS RESULT AS
	BEGIN
		m_goomba := goomba;
		m_frobbed := frobbed;
		m_schlubs := schlubs;
		m_thing1 := OSimple('feh', sysdate, 1);
		m_thing2 := OSimple('bleh', sysdate, 2);
		RETURN;
	END;
gave me the old "too many declarations of 'OSIMPLE' match this call" error:

Warning: Type Body created with compilation errors.

Code:
Errors for TYPE BODY OCOMPOSITE:
                                                                                                                                         
LINE/COL ERROR
-------- -----------------------------------------------------------------
45/3     PL/SQL: Statement ignored
45/15    PLS-00307: too many declarations of 'OSIMPLE' match this call
46/3     PL/SQL: Statement ignored
46/15    PLS-00307: too many declarations of 'OSIMPLE' match this call

SQL> desc osimple;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 M_SPORK                                            VARCHAR2(42)
 M_BLANCMANGED                                      DATE
 M_WIBBLES                                          NUMBER
                                                                                                                                         
METHOD
------
 FINAL CONSTRUCTOR FUNCTION OSIMPLE RETURNS SELF AS RESULT
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 SPORK                          VARCHAR2                IN
 BLANCMANGED                    DATE                    IN
 WIBBLES                        NUMBER                  IN
So, any ideas?

Regards,
-scott anderson