I've got 2 tables:
create table CUSTOMERS
(CUSTOMER_ID NUMBER(20,0),
SP_ID NUMBER(20,0),
UPDATED_ON TIMESTAMP);
create table CUST_DATA
(CUST_DATA_ID NUMBER(20,0),
CUSTOMER_ID NUMBER(20,0),
SP_ID NUMBER(20,0),
UPDATED_ON TIMESTAMP);
I've got a trigger on insert into the CUST_DATA table as follows that updates 2 columns (SP_ID and UPDATED_ON) from the CUSTOMERS table:
create or replace trigger CUST_DATA_AI
for insert on CUST_DATA
compound trigger
cust_id number(20,0);
after each row is
begin
cust_id := :new.CUSTOMER_ID;
end after each row;
after statement is
begin
update CUST_DATA set (CU.SP_ID, CU.CREATED_ON) = (select CI.SP_ID, CI.CREATED_ON from CUSTOMERS CI where CI.CUSTOMER_ID=cust_id) where CU.CUSTOMER_ID=cust_id;
end after statement;
end;
/
I have a java based application that is completing a number of inserts into the CUST_DATA table in a batch and then is submitted to the database all together. I'm seeing that the trigger seems to be only firing for the last inserted entry. Any ideas?