The shop staff repeat the same changes every day. Save them as procedures.
- Create a procedure
add_stock(p_id integer, qty integer). It addsqtyto the stock of productp_id. - Try
SELECT add_stock(3, 25);. Which keyword does the HINT tell you to use? - Run your procedure: the Daemon Cat Plush (product 3) gets 25 new units.
- Create a procedure
place_order(o_id integer, c_id integer, p_id integer, qty integer). It makes three changes:- adds order
o_idfor customerc_id, with today's date and statuspending, - adds the item: product
p_id, quantityqty, unit price = the product's current price, - takes
qtyoff the product's stock.
- adds order
- Run it: Yuki Tanaka (customer 9) orders 3 Linux Sticker Packs (product 7) as order 116.