Oracle: specifying default value for object type column Oracle: specifying default value for object type column oracle oracle

Oracle: specifying default value for object type column


Looks like this is not possible.

One workaround would be to use a trigger:

CREATE OR REPLACE TRIGGER test_trigger  BEFORE INSERT OR UPDATEON test_table  FOR EACH ROWWHEN ( new.test_attr IS NULL )BEGIN  :new.test_attr := NEW test_t();END test_trigger;/

It does not completely ignore non-default constructors by the way, overriding the default constructor

CONSTRUCTOR FUNCTION test_t(in_val NUMBER)RETURN SELF AS RESULT

leads to an exception when trying to define the table with DEFAULT NEW test_t(1):

ORA-06553: PLS-307: too many declarations of 'TEST_T' match this call