0% found this document useful (0 votes)
4 views

Oracle

Oracle lesson

Uploaded by

vongdavid63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Oracle

Oracle lesson

Uploaded by

vongdavid63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

I.

Question
1.Answer:

1 2 3 4 5 6 7 8 9 10
A C H E I J F G F G

2.True/false

1 2 3 4 5 6 7 8 9 10
T F F F T T T T F F

3. Fill the gap for correcting answer


p_PRODUCTNAMEEN in PRODUCT_TBL.PRODUCTNAMEEN%type default null,

p_PROUDUCID in PRODUCT_TBL.PROUDUCID%type,

p_PRODUCTNAMEKH in PRODUCT_TBL.PRODUCTNAMEKH%type default null,

p_QTYONHAND in PRODUCT_TBL.QTYONHAND%type default null,

p_UNITPRICE in PRODUCT_TBL.UNITPRICE%type default null,

p_CATEGORYID in PRODUCT_TBL.CATEGORYID%type default null,

p_BARCODE in PRODUCT_TBL.BARCODE%type default null,

p_UNITCOST in PRODUCT_TBL.UNITCOST%type default null,

p_REORDER in PRODUCT_TBL.QTYREORDER%type default null, -- Assuming "REORDER" is intended to


refer to a "QTYREORDER" or similar field, as "REORDER" was not previously defined.

p_EXPIREDDATE in PRODUCT_TBL.EXPIREDDATE%type default null);

II. CODING
1.In the package API
create or replace package body PRODUCT_TBL_tapi

is

-- insert

procedure ins (

p_ProductNameEn in PRODUCT_TBL.PRODUCTNAMEEN%type default null,


p_ProductID in PRODUCT_TBL.PRODUCTID%type,

p_ProductNameKh in PRODUCT_TBL.PRODUCTNAMEKH%type default null,

p_QtyOnHand in PRODUCT_TBL.QTYONHAND%type default null,

p_UnitPrice in PRODUCT_TBL.UNITPRICE%type default null,

p_CategoryID in PRODUCT_TBL.CATEGORYID%type default null,

p_Barcode in PRODUCT_TBL.BARCODE%type default null,

p_UnitCost in PRODUCT_TBL.UNITCOST%type default null,

p_Reorder in PRODUCT_TBL.QTYREORDER%type default null,

p_ExpiredDate in PRODUCT_TBL.ExpiredDate %type default null

) is

begin

insert into PRODUCT_TBL(

PRODUCTNAMEEN,

PRODUCTID,

PRODUCTNAMEKH,

QTYONHAND,

UNITPRICE,

CATEGORYID,

BARCODE,

UNITCOST,

REORDER,

EXPIREDDATE

) values (

p_ProductNameEn,

p_ProductID,

p_ProductNameKh,

p_QtyOnHand,

p_UnitPrice,

p_CategoryID,
p_Barcode,

p_UnitCost,

p_Reorder,

p_ExpiredDate );end;

-- update

procedure upd (

p_ProductNameEn in PRODUCT_TBL.PRODUCTNAMEEN%type default null,

p_ProductID in PRODUCT_TBL.PRODUCTID%type,

p_ProductNameKh in PRODUCT_TBL.PRODUCTNAMEKH%type default null,

p_QtyOnHand in PRODUCT_TBL.QTYONHAND%type default null,

p_UnitPrice in PRODUCT_TBL.UNITPRICE%type default null,

p_CategoryID in PRODUCT_TBL.CATEGORYID%type default null,

p_Barcode in PRODUCT_TBL.BARCODE%type default null,

p_UnitCost in PRODUCT_TBL.UNITCOST%type default null

) is

begin

update PRODUCT_TBL set

PRODUCTNAMEEN = p_ProductNameEn,

PRODUCTNAMEKH = p_ProductNameKh,

QTYONHAND = p_QtyOnHand,

UNITPRICE = p_UnitPrice,

CATEGORYID = p_CategoryID,

BARCODE = p_Barcode,

UNITCOST = p_UnitCost

where PRODUCTID = p_ProductID;

end;
---Delete
procedure del (

p_ProductID in PRODUCT_TBL.PRODUCTID%type

) is

begin

delete from PRODUCT_TBL

where PRODUCTID = p_ProductID;

end;

end PRODUCT_TBL_tapi;

2.In the C# Project


public class Product_Tbl {

public int ProductID { get; set; }


public string Barcode { get; set; }
public string ProductNameKh { get; set; }
public string ProductNameEn { get; set; }
public double QtyOnHand { get; set; }

public double UnitCost { get; set; }


public double UnitPrice { get; set; }
public double Reorder { get; set; }}
3. b. Insert()
public bool Insert() {
bool ch;
OracleCommand cmd = new OracleCommand(“Product_Tbl _tapi.ins", clsGlob.cn);
CmdHelper(cmd);
try
{
cmd.ExecuteNonQuery();
ch = true;
}
catch (Exception ex)
{
ch = false;
}
return ch;
}

c. Update()
public bool Update()
{
bool ch;
OracleCommand cmd = new OracleCommand("Product_Tbl _tapi.upd",
clsGlob.cn);
CmdHelper(cmd);
try
{
cmd.ExecuteNonQuery();
ch = true;
}
catch (Exception ex)
{
ch = false;
}
return ch;
c. Delete()

public bool Delete()


{
bool ch;
OracleCommand cmd = new OracleCommand("Product_Tbl _tapi.del", clsGlob.cn);
CmdHelper(cmd);
try
{
cmd.ExecuteNonQuery();
ch = true;
}
catch (Exception ex)
{
ch = false;
}
return ch;}

d. CmdHelper()

private void CmdHelper(OracleCommand cmd)


{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("p_ PRODUCTNAMEEN", PRODUCTNAMEEN);
cmd.Parameters.Add("p_ProductID", ProductID);

cmd.Parameters.Add("p_ProductNameKh ", ProductNameKh);

cmd.Parameters.Add("p_QtyOnHand ", QtyOnHand);

cmd.Parameters.Add("p_UnitPrice ", p_UnitPrice);

cmd.Parameters.Add("p_CategoryID ", p_CategoryID);

cmd.Parameters.Add("p_Barcode ", Barcode);

cmd.Parameters.Add("p_UnitCost", UnitCost);
cmd.Parameters.Add("p_Reorder", Reorder);
cmd.Parameters.Add("p_ExpiredDate ", ExpiredDate);

You might also like