Plsql Oracle 10g:在插入/更新之前使用类型构造函数验证数据

Plsql Oracle 10g:在插入/更新之前使用类型构造函数验证数据,plsql,oracle10g,user-defined-types,object-relational-model,Plsql,Oracle10g,User Defined Types,Object Relational Model,是否可以通过类型构造函数在插入/更新之前验证数据?我已经在表中使用了类型化对象。需要知道当我在同一台计算机上插入/更新数据时,是否可能在应用程序上出错 这是概念代码 -- Type Declaration: create or replace type sampleType as object ( col1 number(2), col2 number(2), col3 number(2), constructor function sampleType ret

是否可以通过类型构造函数在插入/更新之前验证数据?我已经在表中使用了类型化对象。需要知道当我在同一台计算机上插入/更新数据时,是否可能在应用程序上出错

这是概念代码

-- Type Declaration:
create or replace type sampleType as object

(
    col1 number(2),
    col2 number(2),
    col3 number(2),
    constructor function sampleType return self as result
) not final;

-- Declaring constructor body:
create or replace type body sampleType as
    constructor function sampleType return self as result is
    inconsistant_data exception;
    pragma EXCEPTION_INIT(inconsistant_data, -660);
    BEGIN
        dbms_output.put_line('Inside contrctor, before condition');
        if self.col1 + col2 != col3 then
            dbms_output.put_line('Raising exception');
            raise inconsistant_data;
        else
            dbms_output.put_line('Inside contrctor, returning...');
            return;
        end if;
        dbms_output.put_line('Inside contrctor, after condition');
        exception when inconsistant_data then
            raise_application_error(-20001, 'col3 should be equal to col1 + col2');
            raise;
    END;
end;

-- Using it in Table:
create table sampleTable (objSample sampleType);

-- Inserting values:
insert into sampleTable values (new sampleType(1, 1, 1));
这里的最后一条语句插入一条记录。它实际上应该返回一个错误。需要澄清和指示,以显示应用程序错误,并在不插入记录的情况下拖运

提前谢谢