Amazon
Amazon
END register_buyer;
-----------------------------------------------------------------------------------
---------
-----------------------------------------------------------------------------------
----------
END add_contact_details;
-----------------------------------------------------------------------------------
---------
END set_default_contact_details;
-----------------------------------------------------------------------------------
---------
END add_card_info;
-----------------------------------------------------------------------------------
---------
END set_default_card_info;
-----------------------------------------------------------------------------------
---------
END add_product;
-----------------------------------------------------------------------------------
---------
END add_to_shopping_cart;
-----------------------------------------------------------------------------------
---------
END add_to_wish_list;
-----------------------------------------------------------------------------------
---------
END give_review;
-----------------------------------------------------------------------------------
---------
new_rating := :new.rating;
UPDATE product
SET
rating = ( ( rating * review_count_old ) + new_rating ) /
( review_count_old + 1 ),
review_count = review_count_old + 1
WHERE
product_id = :new.product_id;
END;
-----------------------------------------------------------------------------------
---------
UPDATE seller
SET
average_rating = ( ( average_rating * rating_count ) + new_rating ) /
( rating_count + 1 ),
rating_count = rating_count + 1
WHERE
seller_id = seller_id_to_update;
END;
-----------------------------------------------------------------------------------
---------
END update_membership;
-----------------------------------------------------------------------------------
---------
END cancel_membership;
-----------------------------------------------------------------------------------
---------
product_id_var INTEGER;
BEGIN
OPEN products_cur;
LOOP
FETCH products_cur INTO product_id_var;
EXIT WHEN products_cur%notfound;
SELECT
price,
available_units
INTO
curr_price_var,
available_units_var
FROM
product
WHERE
product_id = product_id_var;
END IF;
END LOOP;
CLOSE products_cur;
SELECT
is_prime
INTO is_prime_var
FROM
buyer
WHERE
buyer_id = buyer_id_var;
IF is_prime_var = 1 THEN
shipping_price_var := 0;
END IF;
SELECT
card_id
INTO card_id_var
FROM
card_info
WHERE
buyer_id = buyer_id_var
AND is_default = 1;
SELECT
address_id
INTO address_id_var
FROM
contact_detail
WHERE
user_id = buyer_id_var
AND is_default = 1;
END place_order;
-----------------------------------------------------------------------------------
---------
END populate_product_categories;
-----------------------------------------------------------------------------------
---------
END populate_carriers;
-----------------------------------------------------------------------------------
---------
BEGIN
OPEN products_cur;
LOOP
FETCH products_cur INTO product_id_var;
EXIT WHEN products_cur%notfound;
SELECT
available_units
INTO available_units_var
FROM
product
WHERE
product_id = product_id_var;
END IF;
END LOOP;
CLOSE products_cur;
END;
END;
BEGIN
register_buyer('[email protected]', 'anshul', 'pardhi', 'abcd123');
register_buyer('[email protected]', 'ashwani', 'kashyap', 'abcd123');
register_buyer('[email protected]', 'gunjan', 'agicha', 'abcd123');
END;
BEGIN
register_seller('[email protected]', 'kushagra', 'dar', 'abcd123',
'kushagra Co and Co',
'www.kusharga.com', 'company of shoes');
register_seller('[email protected]', 'ruchi', 'singh', 'abcd123', 'ruchi Co
and Co',
'www.ruchi.com', 'company of metals');
register_seller('[email protected]', 'anant', 'prakash', 'abcd123', 'anant
Co and Co',
'www.anant.com', 'company of iphones');
END;
BEGIN
update_contact_details('[email protected]', 1, '7825 McCallum Blvd', 'Apt
007', 'Dallas',
'Texas', 'USA', 75252, 8888888888);
set_default_contact_details(3, '[email protected]');
set_default_contact_details(1, '[email protected]');
END;
BEGIN
add_card_info('[email protected]', 1, 1234123412341234, TO_DATE('2023-12-
09', 'YYYY-MM-DD'),
666);
add_card_info('[email protected]', 2, 0234123412341234, TO_DATE('2023-12-
09', 'YYYY-MM-DD'),
777);
add_card_info('[email protected]', 3, 0234123412341234, TO_DATE('2023-12-
09', 'YYYY-MM-DD'),
777);
set_default_card_info(1, '[email protected]');
set_default_card_info(3, '[email protected]');
END;
BEGIN
populate_product_categories();
populate_carriers();
END;
BEGIN
add_product(1, 'OnePlus 7', '[email protected]', 400, 1,
'Best Phone', 2, 'Blue', 2, 2,
'bit.ly/sfdf4fg');
END;
BEGIN
add_to_wish_list('[email protected]', 1);
add_to_wish_list('[email protected]', 4);
add_to_wish_list('[email protected]', 3);
add_to_wish_list('[email protected]', 2);
END;
BEGIN
add_to_shopping_cart('[email protected]', 1);
add_to_shopping_cart('[email protected]', 3);
add_to_shopping_cart('[email protected]', 2);
add_to_shopping_cart('[email protected]', 1);
END;
BEGIN
update_membership('[email protected]');
END;
BEGIN
place_order(1, '[email protected]');
END;
BEGIN
place_order(2, '[email protected]');
END;
BEGIN
give_review(1, 1, '[email protected]', 'cool phone with great camera', 5,
'www.my_image.com');
give_review(2, 3, '[email protected]', 'good running shoes', 3,
'www.my_image.com');
END;
BEGIN
give_review(3, 2, '[email protected]', 'nice book', 3.5,
'www.my_image.com');
END;
BEGIN
give_review(4, 1, '[email protected]', 'okay phone', 3,
'www.my_image.com');
END;
BEGIN
give_review(5, 5, '[email protected]', 'doesnt work', 1,
'www.my_image.com');
END;
BEGIN
give_review(6, 5, '[email protected]', 'doesnt work at all', 0,
'www.my_image.com');
END;