Jump to content

SQL Trigger - Reference generator


martin_88

Recommended Posts

I'd like to generate a custom reference after the product is created. I looked up and found the trigger slq option.

Something like this.

 

CREATE TRIGGER product_add_reference
After INSERT ON ps_product_lang
FOR EACH ROW
update ps_product set reference = id_product

My understanding is that when we click on "create product" the prodct in the data base is already created.

I would like to add the trigger after the full product is update because the reference is based on the catgory the product will be.

Example :

Woman
   Shirt
   Pens

If the product is in Pens the reference would be P-001. If the product is in Shirt, the reference should be S-001.

I'm blocked because the trigger is actually generated when clicking on "create a new product" but it should be trigger after the full product submittion.

 

Edited by martin_88 (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...