forked from Batuhan-Ultrk/Pharmacy-Automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unite_price_cal_body.sql
34 lines (25 loc) · 1.16 KB
/
unite_price_cal_body.sql
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
create or replace PACKAGE BODY UnitePriceCal AS
PROCEDURE Unite_price(p_id INVENTORY.MEDICATION_ID%TYPE , unitPrice NUMBER, salePrice NUMBER) AS
CURSOR c_unitP(p_id INVENTORY.MEDICATION_ID%TYPE) IS SELECT INVENTORY_ID,MEDICATION_ID,QUANTITY,EXPIRATION_DATE FROM INVENTORY WHERE MEDICATION_ID=p_id;
result NUMBER;
BEGIN
FOR i IN c_unitP(p_id) LOOP
result :=Unite_price_func(unitPrice ,i.QUANTITY,salePrice);
DBMS_OUTPUT.PUT_LINE('Inventory Id: '||i.INVENTORY_ID);
DBMS_OUTPUT.PUT_LINE('Medication Id: '||i.MEDICATION_ID);
DBMS_OUTPUT.PUT_LINE('Expiration Date: '||i.EXPIRATION_DATE);
DBMS_OUTPUT.PUT_LINE('Quantity: '||i.QUANTITY);
DBMS_OUTPUT.PUT_LINE('Birim Fiyatý: '||unitPrice);
DBMS_OUTPUT.PUT_LINE('Satýþ Fiyatý: '||salePrice);
DBMS_OUTPUT.PUT_LINE('Tahmini Kar: '||result);
END LOOP;
END;
FUNCTION Unite_price_func(unitPrice NUMBER,quantity INVENTORY.QUANTITY%TYPE,salePrice NUMBER)
RETURN NUMBER
IS
result NUMBER;
BEGIN
result :=(salePrice *quantity)-(unitPrice*quantity);
RETURN result;
END;
END UnitePriceCal;