Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Trigger syntax
>Please clarify: how can you increment a sequence in table 1 (and obviously
>you need a record for that!) if the corresponding record doesn't exist?
Apologies if my description was unclear.
tab1
===
P_ID NOT NULL NUMBER(10) SEQ VARCHAR2(9)
tab2
ID NOT NULL NUMBER(10) P_ID NOT NULL NUMBER(10) FIELD1 VARCHAR2(9 FIELD2 VARCHAR2(9
tab1 and tab2 are joined on P_ID. A person can only appear once in tab1 but may appear many times in tab2.
So, if a new row is interted in tab2, I want the trigger to do something like:
(where tab1.p_id = tab2.p_id)
if tab1.seq is null
populate tab1.seq with a value from a sequnce else
do nothing (i.e. it already has a value in seq from an earlier insert into tab2)
end if
regards
Chris