Changes between Version 3 and Version 4 of UseCase007


Ignore:
Timestamp:
05/21/26 18:24:54 (6 days ago)
Author:
232012
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UseCase007

    v3 v4  
    2222{{{
    2323SELECT stock, price
    24 FROM Product
    25 WHERE product_id = @selected_product_id;
     24FROM PRODUCTS
     25WHERE product_id = :selected_product_id;
    2626}}}
    2727}}}
     
    3434{{{
    3535SELECT order_id
    36 FROM `Order`
    37 WHERE user_id = @authenticated_user_id AND status = 'Pending';
     36FROM ORDERS
     37WHERE user_id = :authenticated_user_id AND status = 'PENDING';
    3838
    39 INSERT INTO `Order` (user_id, date_created, status, total_price)
    40 VALUES (@authenticated_user_id, CURRENT_TIMESTAMP, 'Pending', 0.00);
     39INSERT INTO ORDERS (order_id, user_id, payment_method, purchase_date, points_earned, points_used, status)
     40VALUES (
     41    :new_order_id,
     42    :authenticated_user_id,
     43    'CARD',
     44    CURRENT_DATE,
     45    0,
     46    0,
     47    'PENDING'
     48);
    4149}}}
    4250}}}
     
    4856{{{#!div style="margin-left: 20px;"
    4957{{{
    50 INSERT INTO OrderItem (order_id, product_id, quantity, price_at_purchase)
    51 VALUES (@active_order_id, @selected_product_id, @requested_quantity, @current_price)
    52 ON DUPLICATE KEY UPDATE quantity = quantity + @requested_quantity;
     58INSERT INTO ORDER_ITEMS (order_id, product_id, quantity, price_at_purchase)
     59VALUES (:active_order_id, :selected_product_id, :requested_quantity, :current_price)
     60ON CONFLICT (order_id, product_id)
     61DO UPDATE SET quantity = ORDER_ITEMS.quantity + EXCLUDED.quantity;
    5362}}}
    5463}}}
     
    5867{{{#!div style="margin-left: 20px;"
    5968{{{
    60 SELECT SUM(quantity * price_at_purchase) AS new_total
    61 FROM OrderItem
    62 WHERE order_id = @active_order_id;
     69SELECT COALESCE(SUM(quantity * price_at_purchase), 0) AS new_total
     70FROM ORDER_ITEMS
     71WHERE order_id = :active_order_id;
    6372}}}
    6473}}}