0% found this document useful (0 votes)
7 views4 pages

DBMS PRG9 Lab

The document outlines the steps to develop an inventory database using PL/SQL, including creating a table, inserting records, updating product rates by 20%, and adding a new column for the number of items. It details the SQL commands and procedures necessary for each step. The final result confirms successful execution of all operations.

Uploaded by

joyalprincess
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)
7 views4 pages

DBMS PRG9 Lab

The document outlines the steps to develop an inventory database using PL/SQL, including creating a table, inserting records, updating product rates by 20%, and adding a new column for the number of items. It details the SQL commands and procedures necessary for each step. The final result confirms successful execution of all operations.

Uploaded by

joyalprincess
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/ 4

EX-NO : 9

DEVELOP INVENTORY DATABASE USING PL/SQL


DATE :

AIM:
To implement inventory database using PL/SQL.

ALGORITHM:
QUERIES

Step-1: Create inventory table

create table inventory(pid int primary key,pname varchar(30),rate numeric(10,2));

Step-2: Insert records into inventory table

insert into inventory values(100,"PEN",80),(101,"PENCIL",10),(102,"BOX",150),


(103,"BOOK",350),(104,"SKETCH",50),(105,"PENDRIVE",600);

Step-3:View Table ( Before Update 20% )

Select *from inventory;

Step-4: Write PL/SQL for Update 20% rate for all products
delimiter $$
create procedure update_Rate()
begin
declare done int default 0;
declare upid int;
declare uprate numeric(10,2);
declare upname varchar(30);
declare cur cursor for select *from inventory;
declare exit handler for not found set done=1;
open cur;
upinv:loop
if done=1 then
leave upinv;
end if;
fetch cur into upid,upname,uprate;
set uprate=uprate+((uprate*20)/100);
update inventory set rate=uprate where pid=upid;
end loop;
close cur;
end $$
delimiter ;
call update_Rate();

select *from inventory;

Step-5: Adding new filed (Number_of_Item) using Alter command

alter table inventory add column Number_of_Items int;


select *from inventory;

Step-6:Place values for Number_of_items in All Records in Table

update inventory set Number_of_Items=15 where pid=100;


update inventory set Number_of_Items=5 where pid=101;
update inventory set Number_of_Items=25 where pid=102;
update inventory set Number_of_Items=6 where pid=103;
update inventory set Number_of_Items=13 where pid=104;
update inventory set Number_of_Items=22 where pid=105;
select *from inventory;
OUTPUT

RESULT:
The Above Result has been obtained successfully.

You might also like