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

Adfdfd

The document describes a database management system laboratory assignment. It involves creating a customer table, inserting sample data, and writing queries to increase customer salaries by 5000 and retrieve customer names and addresses from the table.

Uploaded by

personalpcemail
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)
31 views4 pages

Adfdfd

The document describes a database management system laboratory assignment. It involves creating a customer table, inserting sample data, and writing queries to increase customer salaries by 5000 and retrieve customer names and addresses from the table.

Uploaded by

personalpcemail
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

Progressive Education Society's

Modern College of Engineering, Pune


MCA Department
A.Y.2023-24
(310917) Database Management System Laboratory
*********************************************************************************************
Class: FY-MCA Shift / Div.: F2/B Roll Number : 51146

Name: Aniket R Rajput Assignment No: 09 Date of Implementation: 15/03/2024

*********************************************************************************************

Q.: Create a table and perform the following

PREQUISITE TABLE:

CUSTOMER ( CNAME , CADDRESS , CSALARY );

TABLE CREATION:
QUERY:
CREATE TABLE customer(cid int PRIMARY KEY,cname varchar(15) , caddress varchar(20), csalary int);

OUTPUT:

DATA INSERTION:

QUERIES:

INSERT INTO customer values(1,'Vaibhav' , 'Sangamner' , 10000 );

INSERT INTO customer values(2,'Ruturaj' , 'Pune' , 20000 );

INSERT INTO customer values(3,'Kundan' , 'Nashik' , 30000 );

OUTPUTS:
1. Increase salary of each customer by 5000.

Ans.:

Query:

DECLARE v_custid customer.cid%TYPE;

v_custname customer.cname%TYPE;

v_custaddress customer.caddress%TYPE;

v_custsal customer.csalary%TYPE;

CURSOR cust_cursor1 IS

SELECT cid, cname, caddress, csalary FROM customer;

BEGIN

OPEN cust_cursor1;

DBMS_OUTPUT.PUT_LINE ('OLD DATA:');

LOOP

FETCH cust_cursor1 INTO v_custid, v_custname, v_custaddress, v_custsal;

EXIT WHEN cust_cursor1%NOTFOUNd;

DBMS_OUTPUT.PUT_LINE ( 'CUSTID:'|| ' ' || v_custid ||' '|| 'CUSTNAME:' || v_custname || ' ' || 'CUSTADDRESS:' ||
v_custaddress || ' ' || 'CUSTSALARY:' || v_custsal);

END LOOP;

DBMS_OUTPUT.PUT_LINE ('');

CLOSE cust_cursor1;

OPEN cust_cursor1;

DBMS_OUTPUT.PUT_LINE ('UPDATED DATA:');

LOOP

FETCH cust_cursor1 INTO v_custid, v_custname, v_custaddress, v_custsal;


EXIT WHEN cust_cursor1%NOTFOUNd;

v_custsal := v_custsal + 5000;

UPDATE customer SET csalary = v_custsal

WHERE v_custid=cid;

DBMS_OUTPUT.PUT_LINE ( 'CUSTID:' || ' ' || v_custid || ' ' || 'CUSTNAME:' || v_custname || ' ' || 'CUSTADDRESS:' ||
v_custaddress || ' ' || 'CUSTSALARY:' || v_custsal);

END LOOP;

CLOSE cust_cursor1;

END;

OUTPUT:

2. Write a program to retrieve the customer name and address.

Ans.:

Query:

DECLARE v_custname

customer.cname%TYPE; v_custaddress

customer.caddress%TYPE;

CURSOR cust_cursor IS

SELECT cname, caddress FROM customer;


BEGIN

OPEN cust_cursor;

LOOP

FETCH cust_cursor INTO v_custname, v_custaddress;

EXIT WHEN cust_cursor%NOTFOUNd;

DBMS_OUTPUT.PUT_LINE ( v_custname || ' ' || v_custaddress);

END LOOP;

CLOSE cust_cursor;

END;

OUTPUT:

*****************************************************************************************************
*****************************************************************************************************

You might also like