Link to home
Start Free TrialLog in
Avatar of Vasi04
Vasi04

asked on

DB trigger to delete duplicate rows

I want to write a DB trigger. I dont have any exp with oracle.
I have two tables - profile and product
The issue I have is that for each row in table profile, there are atleast 4 identical rows in table product. I want to clean up table product so that for each profile there is only one product profile.
HOw to do this?
I want to have a DB trigger to check everytime theres an insert on table product...that is to delete duplicate rows.
Thanks in advance
Avatar of Nievergelt
Nievergelt
Flag of Switzerland image

Why do you not want to clean up your product table in one operation ?
Is there a reason you want to use a trigger ?
Avatar of Vasi04
Vasi04

ASKER

I want to use trigger to avoid future insert of duplicate rows. Is this spossible?
With Single operation I can get rid of already existing duplicate rows.


ASKER CERTIFIED SOLUTION
Avatar of Nievergelt
Nievergelt
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

The best way to do this is to create a Primary key on the product profile. If the table already has a product profile, then create a unique index on product profile. This will ensure that duplicates do not occur.