I have an object type with no-args constructor, but when I specify it as default value for a column of that type, I get ORA-00904: invalid identifier error.
Example:
CREATE OR REPLACE TYPE test_t AS OBJECT
(
val NUMBER(10),
CONSTRUCTOR FUNCTION test_t return self as result
)
CREATE OR REPLACE TYPE BODY test_t AS
CONSTRUCTOR FUNCTION test_t RETURN SELF AS RESULT IS
BEGIN
val := 1;
RETURN;
END;
END;
CREATE TABLE test_table (
test_attr test_t DEFAULT new test_t()
)
Error: ORA-00904: "INKA"."TEST_T"."TEST_T": invalid identifier
If I replace DEFAULT with e.g. test_t(1), it works, but that sort of breaks the OO encapsulation paradigm, I want all fields of same type to have same default "default values" (hope you know what I mean :-)
Am I missing something here, or is this normal and it is not possible to use non-default constructors like this?