-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHandsOn06sql
64 lines (55 loc) · 1.5 KB
/
HandsOn06sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
CREATE OR REPLACE PROCEDURE prod_add_sp
(p_name IN bb_product.productname%TYPE,
p_descrip IN bb_product.description%TYPE,
p_image IN bb_product.productimage%TYPE,
p_price IN bb_product.price%TYPE,
p_active IN bb_product.active%TYPE)
IS
BEGIN
INSERT INTO bb_product (idproduct, productname, description,
productimage, price, active)
VALUES (bb_prodid_seq.NEXTVAL, p_name, p_descrip, p_image, p_price,
p_active);
COMMIT;
END;
BEGIN
prod_add_sp('Roasted Blend','Well-balanced mix of roasted beans,
a medium body','roasted.jpg',9.50,1);
END;
---------------------------------------
CREATE OR REPLACE PROCEDURE prod_add_sp
(p_name IN bb_product.productname%TYPE,
p_descrip IN bb_product.description%TYPE,
p_image IN bb_product.productimage%TYPE,
p_price IN bb_product.price%TYPE,
p_active IN bb_product.active%TYPE)
IS
BEGIN
INSERT INTO bb_product (idproduct, productname, description,
productimage, price, active)
VALUES (bb_prodid_seq.NEXTVAL, p_name, p_descrip, p_image, p_price,
p_active);
COMMIT;
END;
BEGIN
prod_add_sp('Roasted Blend','Well-balanced mix of roasted beans,
a medium body','roasted.jpg',9.50,1);
END;
--------------------------------------------------
CREATE OR REPLACE FUNCTION dollar_fmt_sf
(p_num NUMBER)
RETURN VARCHAR2
IS
lv_amt_txt VARCHAR2(20);
BEGIN
lv_amt_txt := TO_CHAR(p_num,'$99,999.99');
RETURN lv_amt_txt;
END;
DECLARE
lv_amt_num NUMBER(8,2) := 9999.55;
BEGIN
DBMS_OUTPUT.PUT_LINE(dollar_fmt_sf(lv_amt_num));
END;
SELECT dollar_fmt_sf(shipping), dollar_fmt_sf(total)
FROM bb_basket
WHERE idBasket = 3;