Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Need help on Trigger Oracle 11g

Avatar of sam_2012
sam_2012 asked on
Oracle Database
20 Comments1 Solution547 ViewsLast Modified:
Hi ,

I have an table called CUSTOMER_ORGANIZATION_PROFILE , When ever I insert an new record , I must get the other customer details from CUSTOMER_ORGANIZATION and CLIENT_ORGANIZATION tables and also the customer types from CUSTOMER_ORGANIZATION_PROFILE into table called TEMP_ORG_DATA.
When I update the CUSTOMER_ORGANIZATION_PROFILE  on IS_CUSTOMER , IS_CLIENT, IS_BOTH , then I need to update the IS_CUSTOMER , IS_CLIENT, IS_BOTH in TEMP_ORG_DATA.
When I delete the CUSTOMER_ORGANIZATION_PROFILE for an organization_profile_id , then I need to delete the entry in TEMP_ORG_DATA.

Below is the trigger code , the issue is whenever I insert the data , no records are inserted into temp_orgdata table , the same is with update and delete. Any help is really appreciated.


CREATE OR REPLACE TRIGGER CRM_ORG_PROFILE_TEST_TRG
AFTER INSERT OR  DELETE OR UPDATE OF IS_CUSTOMER,IS_CLIENT,IS_BOTH ,PRODUCT_GROUP_ID
ON CUSTOMER_ORGANIZATION_PROFILE
FOR EACH ROW
BEGIN      
       
         IF INSERTING THEN
         INSERT  INTO TEMP_ORGDATA
         Select
                              co.CST_ORGANIZATION_ID,
                    co.ORGANIZATION_ID,
                    co.PARENT_ORGANIZATION_ID,
                    :NEW.PRODUCT_GROUP_ID,
                              co.IS_INTERNAL,
                    co.OWNER_USER_ID,  
                    co.STATUS_ID,
                    ilo.CLIENT_ORG_NAME,
                    NULL DOMAIN,
                    co.LOCK_VERSION,
                    co.NAME_EN,
                    co.TAX_ID,
                    co.ADDRESS1,
                    co.ADDRESS2,
                    co.STATE,
                    co.CITY,
                    co.ZIP,
                    co.SUMMARY,
                    co.COUNTRY_ID,
                    co.REGION_ID,
                    :NEW.IS_CUSTOMER,
                              :NEW.IS_CLIENT,
                              :NEW.IS_BOTH                    
       FROM CST_ORGANIZATION co LEFT OUTER JOIN CLIENT_ORGANIZATION ilo on (co.ORGANIZATION_ID=Ilo.ORGANIZATION_ID)
       Where co.organization_id=:NEW.organization_id;
       
         ELSIF UPDATING THEN
        
         UPDATE TEMP_ORGDATA
         SET IS_CUSTOMER=:NEW.IS_CUSTOMER,
         IS_CLIENT =:NEW.IS_CLIENT,
         IS_BOTH=:NEW.IS_BOTH
         Where organization_id=:OLD.organization_id and product_group_id=:OLD.PRODUCT_GROUP_ID;

            ELSIF DELETING THEN
            
            DELETE FROM TEMP_ORGDATA WHERE organization_id=:OLD.organization_id and product_group_id=:OLD.PRODUCT_GROUP_ID;
        
         END IF;
        
       
END CRM_ORG_PROFILE_TEST_TRG;
/