-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchproducts functions.sql
85 lines (59 loc) · 3.48 KB
/
searchproducts functions.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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
set serveroutput on;
create or replace package search_package as
procedure search_all_pro(pnam in product.name%TYPE);
procedure search_con_pro(pnam in product.name%TYPE,con in product_info.condition%TYPE);
procedure search_bran_pro(pnam in product.name%TYPE,bran in product_info.branch%TYPE);
procedure get_all_pro_branch(bran in product_info.branch%TYPE);
end search_package;
/
create or replace package body search_package as
-- search with the name of the prodect
procedure search_all_pro(pnam in product.name%TYPE)
as
cursor c is select product.pid as pid, product.name as pname, product.catagory as catagory, product.brand as brand,
product_info.product_code as product_code, product_info.buyprice as buyprice , product_info.sellprice as sellprice,
product_info.branch as branch, product_info.condition as condition from product,product_info
where product.pid = product_info.pid and product_info.status = 0 and product.name = pnam;
begin
for r in c loop
dbms_output.put_line(to_char(r.pid)|| ' ' || to_char(r.pname) || ' ' || to_char(r.branch));
end loop;
end search_all_pro;
-- search with name and condition of the product
procedure search_con_pro(pnam in product.name%TYPE,con in product_info.condition%TYPE)
as
cursor c is select product.pid as pid, product.name as pname, product.catagory as catagory, product.brand as brand,
product_info.product_code as product_code, product_info.buyprice as buyprice , product_info.sellprice as sellprice,
product_info.branch as branch, product_info.condition as condition from product,product_info
where product.pid = product_info.pid and product_info.status = 0 and product_info.condition = con and product.name = pnam;
begin
for r in c loop
dbms_output.put_line(to_char(r.pid)|| ' ' || to_char(r.pname) || ' ' || to_char(r.branch) || ' ' || to_char(r.condition));
end loop;
end search_con_pro;
-- search with name and branch of the product
procedure search_bran_pro(pnam in product.name%TYPE,bran in product_info.branch%TYPE)
as
cursor c is select product.pid as pid, product.name as pname, product.catagory as catagory, product.brand as brand,
product_info.product_code as product_code, product_info.buyprice as buyprice , product_info.sellprice as sellprice,
product_info.branch as branch, product_info.condition as condition from product,product_info
where product.pid = product_info.pid and product_info.status = 0 and product_info.branch = bran and product.name = pnam;
begin
for r in c loop
dbms_output.put_line(to_char(r.pid)|| ' ' || to_char(r.pname) || ' ' || to_char(r.branch) || ' ' || to_char(r.condition));
end loop;
end search_bran_pro;
-- get all product against branch
procedure get_all_pro_branch(bran in product_info.branch%TYPE)
as
cursor c is select product.pid as pid, product.name as pname, product.catagory as catagory, product.brand as brand,
product_info.product_code as product_code, product_info.buyprice as buyprice , product_info.sellprice as sellprice,
product_info.branch as branch, product_info.condition as condition from product,product_info
where product.pid = product_info.pid and product_info.status = 0 and product_info.branch = bran;
begin
for r in c loop
dbms_output.put_line(to_char(r.pid)|| ' ' || to_char(r.pname) || ' ' || to_char(r.branch) || ' ' || to_char(r.condition));
end loop;
end get_all_pro_branch;
end search_package;
/