Sql programming Language -
scenario:
lets assume have order id 1001 ,where have 5 products being ordered in order (1001)..when had issue in 1 of product,we assign customer executive solve issue , there customer executive resolved date 1 product..i want date applied 4 products present within same order id (1001)...
i have explained 1 order..consider situation have thousands of order id s. how map them
eg:
1001: p1,p2,p3,p4,p5
since there issue product p2,the issue forwarded cet , once resolve have cet resolved date
i want same date replicated in p1,p3,p4,p5
in case had issue p2,p3 pick max of 2 dates , replicated in p1,p4,p5
same case should applied other order ids too
a generic solution create before update
trigger
- capture incoming
order id
,cet_resolved_date
. - find
max(date)
order_id
, compare incominget_resolved_date
. ever maximum, save in variable. - run update statement
order_id
, set otherdates
date
saved in variable. - suppose
1001
.p2
got updated date, before updating it, trigger execute, capturecet_resolved_date
, see if maximum date among other products. else save maximum date variable , update other dates oforder_id
variable value.
warning: slow down bulk updates on table.
Comments
Post a Comment