Guest User

Untitled

a guest
Nov 16th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. /* edit the purchase items */
  2. WHILE items_index<items_length DO
  3. UPDATE PurchaseOrderItems SET quantity=JSON_EXTRACT(p_purchaseitems, CONCAT('$[',items_index,'].quantity')) ,products_productid=JSON_EXTRACT(p_purchaseitems, CONCAT('$[',items_index,'].productid')) WHERE itemid=JSON_EXTRACT(p_purchaseitems, CONCAT('$[',items_index,'].purchaseitemid'));
  4. IF items_index+1=items_length THEN
  5. /* condition will only be true in last iteration*/
  6. SET item_separator='';
  7. END IF;
  8. SET save_list = CONCAT(save_list,JSON_EXTRACT(p_purchaseitems, CONCAT('$[',items_index,'].purchaseitemid')),item_separator);
  9. SET items_index=items_index+1;
  10. END WHILE;
  11. /* delete all other items that were not in the list */
  12. DELETE FROM PurchaseOrderItems WHERE purchaseorders_purchaseorderid=p_purchaseorderid AND itemid not in (save_list);
Add Comment
Please, Sign In to add comment