0% found this document useful (0 votes)
2 views2 pages

Program 9

The document outlines a PL/SQL script to update the 'Rate' field in the 'Inventory' table by increasing it by 20%. It also describes the creation of a new column 'Alter_No' for item numbers and updates this new field for each item. The script includes SQL commands for creating the table, inserting values, and performing the updates without using a PL/SQL block.

Uploaded by

praneshmbsc2025
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)
2 views2 pages

Program 9

The document outlines a PL/SQL script to update the 'Rate' field in the 'Inventory' table by increasing it by 20%. It also describes the creation of a new column 'Alter_No' for item numbers and updates this new field for each item. The script includes SQL commands for creating the table, inserting values, and performing the updates without using a PL/SQL block.

Uploaded by

praneshmbsc2025
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

Write a PL/SQL to update the rate field by 20% more than the current rate

in inventory table which has the following fields: Prono, ProName and
Rate. After updating the table a new field (Alter) called for Number of item
and place for values for the new field without using PL/SQL block

QUERY

CREATE TABLE Inventory (

Prono NUMBER PRIMARY KEY,

ProName VARCHAR2(30),

Rate NUMBER

);

INSERT INTO Inventory VALUES (1, 'Pen', 10);

INSERT INTO Inventory VALUES (2, 'Book', 50);

INSERT INTO Inventory VALUES (3, 'Pencil', 5);

COMMIT;

SELECT * FROM Inventory;

BEGIN

UPDATE Inventory

SET Rate = Rate * 1.20;

COMMIT;

END;

SELECT * FROM Inventory;

ALTER TABLE Inventory

ADD Alter_No NUMBER;


UPDATE Inventory

SET Alter_No = 101

WHERE Prono = 1;

UPDATE Inventory

SET Alter_No = 102

WHERE Prono = 2;

UPDATE Inventory

SET Alter_No = 103

WHERE Prono = 3;

COMMIT;

SELECT * FROM Inventory;

You might also like