trigger has :new is a collection type [message #409224] |
Sat, 20 June 2009 13:42 |
khuatdinh
Messages: 2 Registered: June 2009
|
Junior Member |
|
|
My trouble is trigger have :new is a collection type. I can't take its value.
This is my example: the error in the trigger is at sentence: "INSERT INTO TABLE (select v.a FROM myexample v) VALUES (:new.val,:new.VT,:new.TT) ;
". :new.VT is a collection. Is there another solution, can you help me? Thank you very much for all of yours attentions.
My pl/sql:
create or replace TYPE period_typ as object
(
sta TIMESTAMP,
en TIMESTAMP);/
create or replace TYPE ELE_TYP AS VARRAY(5) OF PERIOD_TYP;/
create or replace TYPE INT_BI_PRE_TYP AS OBJECT
(
val int,
vt ELE_TYP,
tt PERIOD_TYP
);/
create or replace TYPE INT_BI_TYP AS TABLE OF INT_BI_PRE_TYP;/
create table myexample (v int,a INT_BI_TYP)
nested table a store as myexample_a;/
insert into myexample values(1,INT_BI_TYP(
INT_BI_PRE_TYP('1000',ELE_TYP(
PERIOD_TYP(SYSDATE-1,SYSDATE),
PERIOD_TYP(SYSDATE-1,SYSDATE)
),
PERIOD_TYP(SYSDATE-1,SYSDATE)
),
INT_BI_PRE_TYP('1000',ELE_TYP(
PERIOD_TYP(SYSDATE-1,SYSDATE),
PERIOD_TYP(SYSDATE-1,SYSDATE)
),
PERIOD_TYP(SYSDATE-1,SYSDATE)
)
)
);/
create view myexample_view as select * from myexample;/
select * from table(select v.a FROM myexample_view v where v=1);/
create or replace TRIGGER thunghiem_view1_tri INSTEAD OF INSERT
ON NESTED TABLE a OF myexample_view FOR EACH ROW
declare
VTtam ELE_TYP;
BEGIN
--VTtam:=ELE_TYP();
INSERT INTO TABLE (select v.a FROM myexample v) VALUES (:new.val,:new.VT,:new.TT) ;
END;
insert into table(select v.a FROM myexample_view v where v=1) values
(
INT_BI_PRE_TYP('3000',ELE_TYP(
PERIOD_TYP(SYSDATE-1,SYSDATE),
PERIOD_TYP(SYSDATE-1,SYSDATE)
),
PERIOD_TYP(SYSDATE-1,SYSDATE)
)
) ;
|
|
|
|
|
Re: trigger has :new is a collection type [message #409242 is a reply to message #409240] |
Sun, 21 June 2009 01:16 |
|
Michel Cadot
Messages: 68718 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
ORA-00600/ORA-07445/ORA-03113 = Oracle bug => search on Metalink and/or call Oracle support.
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).
Regards
Michel
|
|
|