我的問題是因爲我是新的與oracle和pl/sql可以檢查插入期間通過使用自我構造函數的值。 根據另一個屬性值檢查變量項目的數量的示例?Oracle自身構造函數與if語句
Create or Replace Type test_arr as Varray(20) of number;
Create or Replace Type test_typ as Object(
tID number(5),
tType varchar2(1),
tArray test_arr
);
我想測試時TTYPE =「A」然後tArray.count應小於2,並且如果所述TTYPE =「B」,那麼tArray.count應在5和20之間 我想在插入過程中測試如下:
Create Table test_tbl of test_typ;
Insert Into test_tbl Values(187,'A',test_arr(1,6,7)); /*This should give an error and not insert the record as the tType is 'A' and the tArray has 3 values!*/
我不知道我是否可以用自我回報做到這一點。這裏最主要的是我需要在插入過程中檢查!
我會適當的任何幫助。謝謝!
一個類型構造函數在這裏沒有幫助。首先,你只能添加構造函數,而不能改變默認構造函數,所以你的自定義驗證構造函數必須具有除'(tID,tType,tArray)'以外的簽名。其次,在對象表的關係表示中插入「insert」不會調用其類型的構造函數。 –