Aim:
             To find the Current Stock using PL/SQL.

Algorithm:

Step 1: Start the program.

Step 2: Create the table and insert their records.

Step 3: Create the return function.

Step 4: Declare the variable c.

Step 5: End the total stock.

Step 6: Get the output.

Step 7: Stop the process.

Program

create table product (pno number(5),pname varchar2(10),stock number(4));

insert into product values(101,'pencil',500);
insert into product values(102,'pen',650);
insert into product values(103,'Marker',150);
insert into product values(104,'Notebook',500);
insert into product values(105,'book',500);

CREATE OR REPLACE FUNCTION totalstock
RETURN number IS 
   total number(4) := 0; 
BEGIN 
   SELECT stock into total 
   FROM product where pname='book';     
   RETURN total; 
END; 

DECLARE 
   c number(5); 
BEGIN 
   c := totalstock(); 
   dbms_output.put_line('Total no. of stock is : ' || c); 
END; 

OUTPUT

Total no. of stock is : 500
 

Post a Comment

أحدث أقدم