Use Case
Use Case
Creation of Tables
Increment By 1
MinValue 1000
MaxValue 9999;
Start With 1
Increment By 1
MinValue 1
MaxValue 9999;
2. Create Procedures to
a. Add Row to Items
b. Add Rows to Bill_Master
a. Create or replace Procedure Add_Items(vICode Varchar2,vIName Varchar2,vRate
Number,vStock Number) is
Begin
insert into Items_ values (vIcode,vIName,vRate,vStock);
Dbms_OutPut.Put_Line ('One Item Added to DataBase');
Exception
When Dup_Val_on_Index Then
Dbms_OutPut.Put_Line ('Item ID Already Exists in Database, Insert Aborted');
When Others Then
Dbms_OutPut.Put_Line (SQLERRM);
End Add_Items ;
Begin
Exception
Dbms_OutPut.Put_Line (SQLERRM);
End Add_Bill;
vStock items_.stock%Type;
Begin
select stock into vStock from items_ where icode=vICode;
if vStock>0 then
Return TRUE;
else
Return False;
end if;
exception
Return FALSE;
End Check_Stock;
vStock items_.stock%Type;
Begin
if vstock>=vQty then
return TRUE;
else
return False;
end if;
Exception
return False;
return False;
End Check_Stock_Qty;
vRate items_.rate%Type;
vBAmt Bill_Master.btotal%type:=0;
Begin
if CHECK_STOCK(vICode) Then
if Check_Stock_Qty(vIcode,vQty) Then
vBamt:=(vRate*vQty);
else
end if;
else
end if;
exception
dbms_output.put_line(sqlerrm);
End Add_BTrans;
v1 Bill_Master%rowtype;
v2 bill_transactions%rowtype;
v3 items_%rowtype;
begin
Open my_cur1(vBno);
Loop
dbms_output.put_line('Bill Date:-'||v1.BDate);
dbms_output.put_line('-------------------------------------');
dbms_output.put_line('-------------------------------------');
open my_cur2(vBno);
loop
to_char(v2.qty*v3.rate,'9,999.99'));
end loop;
close my_cur2;
dbms_output.put_line('-------------------------------------');
dbms_output.put_line('------------------------'||v1.BTotal);
dbms_output.put_line('------------------------------------');
End Loop;
Close my_cur1;
Exception
dbms_output.put_line(sqlerrm);
End Show_Bill;
Exec Add_Items(1000,'Bread',50,5);
Exec Add_Items(1001,'Butter',250,5);
Exec Add_Btrans(1,1000,2);
Exec Add_Btrans(1,1001,1);
Exec Show_bill(1);
Begin
Exception
End Add_Items ;
Begin
Exception
Dbms_OutPut.Put_Line (SQLERRM);
End Add_Bill;
vStock items_.stock%Type;
Begin
if vStock>0 then
Return TRUE;
else
Return False;
end if;
exception
Return FALSE;
End Check_Stock;
vStock items_.stock%Type;
Begin
if vstock>=vQty then
return TRUE;
else
return False;
end if;
Exception
return False;
return False;
End Check_Stock_Qty;
vRate items_.rate%Type;
vBAmt Bill_Master.btotal%type:=0;
Begin
if CHECK_STOCK(vICode) Then
if Check_Stock_Qty(vIcode,vQty) Then
else
end if;
else
end if;
exception
dbms_output.put_line(sqlerrm);
End Add_BTrans;
v1 Bill_Master%rowtype;
v2 bill_transactions%rowtype;
v3 items_%rowtype;
begin
Open my_cur1(vBno);
Loop
dbms_output.put_line('Bill Date:-'||v1.BDate);
dbms_output.put_line('-------------------------------------');
dbms_output.put_line('-------------------------------------');
open my_cur2(vBno);
loop
to_char(v2.qty*v3.rate,'9,999.99'));
end loop;
close my_cur2;
dbms_output.put_line('-------------------------------------');
dbms_output.put_line('------------------------'||v1.BTotal);
dbms_output.put_line('------------------------------------');
End Loop;
Close my_cur1;
Exception
dbms_output.put_line(sqlerrm);
End Show_Bill;
End PKG_Billing;