0% found this document useful (0 votes)
89 views32 pages

Record

The document describes programs for various database operations: 1) A student details database is created and attributes are modified, data is inserted and queried. 2) A library database is created, tuples are inserted, publishers and book details are queried. 3) An employee salary database is created, tuples are inserted and various aggregate functions are used to query salaries. 4) An inventory database with item and purchase tables is created, tuples are inserted and items purchased are listed with totals. 5) A bank customer database with customer and account tables is created, primary and foreign keys are specified and tuples are inserted.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views32 pages

Record

The document describes programs for various database operations: 1) A student details database is created and attributes are modified, data is inserted and queried. 2) A library database is created, tuples are inserted, publishers and book details are queried. 3) An employee salary database is created, tuples are inserted and various aggregate functions are used to query salaries. 4) An inventory database with item and purchase tables is created, tuples are inserted and items purchased are listed with totals. 5) A bank customer database with customer and account tables is created, primary and foreign keys are specified and tuples are inserted.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 32

PROGRAM : 1

STUDENT DETAILS DATABASE The student details database has a table with the following attributes.
STUDENT (RegNo: number; Name: text; DOB: date; Marks: number)

a) Remove the existing attribute marks from the table

b) Change the data type of regno from integer to string.

c) Add a new attribute PhoneNo to the existing table.

d) Enter 5 tuples into the table.

e) Display all the tuples in student table.

f) Display all the students who were born in 1980s.

g) Display all the students in alphabetical order of their names.

-- create table in the name of student

create table student1028(regno number,name varchar2(20),dob date,marks number);

Table created. --describe student table

desc student1028;
• Remove the existing attribute marks from the table

alter table student1028 drop(marks);

Table altered.

desc student1028;

• Change the data type of regno from integer to string.

alter table student1028modify regno varchar2(20);

Table altered

desc student1028;

• Add a new attribute PhoneNo to the existing table

alter table student1028 add phoneno number;

Table altered.

desc student1028;

• Enter 5 tuples into the table.

insert into student1028 values('cs501','asha','11/07/1980',9840559146);

1 row(s) inserted.

Select * from student1028;

insert into student1028 values('cs506','banu','05/03/1985',9876576543);

1 row(s) inserted.

insert into student1028 values('cs503','zemi','09/02/1990',9884537564);

1 row(s) inserted

. insert into student1028 values('cs504','mitran','09/21/1987',9723425687);


1 row(s) inserted.

insert into student1028 values('cs502','megu','04/27/1992',98843322445);

1 row(s) inserted.

• Display all the tuples in student table

select name,phoneno from student1028;

• Display all the students who were born in 1980s.

select * from student1028 where to_char(dob,'yyyy') between 1980 and 1989;

• Display all the students in alphabetical order of their names.

select * from student1028order by name;

Order by regno

select * from student1028 order by regno;

Result: Thus the above program was successfully completed and verified.
PROGRAM : 2.

LIBRARY DATABASE A library database has a table with the following attributes:LIBRARY (Bookld:
number; Title: text; Author: text; Publisher: text; Year_Pub: number; Price: number (6,2))

a) Enter 5 tuples into the table.

b) Display the different publishers from the list.

c) Arrange the tuples in the alphabetical order of book titles.

d) List details of all the books whose price ranges between Rs. 100.00 and Rs.300.00

e) Display all the authors under a specific publisher.

Create table

create table library1028(bookid number primary key,title varchar2(30),author varchar2 (25),publisher


varchar2(25),year_pub number, price number(6,2));

Table created.

desc library1028;

• Enter 5 tuples into the table.

insert into library1028 values( 1001,'dbms','elmasri','faisal',1995,150);

1 row(s) inserted

insert into library1028 values( 1021,'electronics','joyal','springer',1990,190);

1 row(s) inserted.

insert into library1028 values( 1011,'java','kiran','prasand',2000,310);

1 row(s) inserted.

insert into library1028 values( 1016,'c++','mahesh','manish',2005,280);


1 row(s) inserted.

insert into library1028 values( 1003,'datastructure','samantha','prasand',1986,29 9);

1 row(s) inserted.

select * from library1028;

• Display the different publishers from the list.

select distinct publisher from library1028;

• Arrange the tuples in the alphabetical order of book titles.

select * from library1028 order by title;

• List details of all the books whose price ranges between Rs. 100.00 and Rs.300.00

select * from library1028 where price between 100 and 300;

• Display all the authors under a specific publisher.

select author from library1028 where publisher = 'prasand’;


PROGRAM: 3

EMPLOYEE SALARY DATABASE

The salary database of an organization has a table ith the following attributes:

EMPSALARY (EmpCode: number; EmpName: text; DOB: date; Dept: text; Salary Number (10,2))

a) Enter 5 tuples into the table.

b) Display the number of employees working in each department.

c) Find the sum of the salaries of all employees.

d) Find the sum and average of the salaries of employees of a particular department.

e) Find the highest salary that an employee draws.


f) Find the least salary that an employee draws.

g) Find the total salary for each department.

h) Increase the salary of those employees working for the accounts department by Rs. 1000.

i) Display all employees increasing order of their age for a specific department.

Crete empsalary table:

create table empsalary1028(empcode number(10) primary key, empname varchar2(20), dob date, dept
varchar2(20),salary number(10,2));

Table created.

a) Enter 5 tuples into the table.

--a) Enter 5 tuples into the table.

insert into empsalary1028 values(101,'arun','12/20/1986','sales',30000.00);

insert into empsalary1028 values(106,'deepak','09/25/1980','marketing',10000.00);

insert into empsalary1028 values(103,'hari','07/27/1983','HR',50000.00);

insert into empsalary1028 values(102,'kani','11/12/1991','sales',25000.00);

insert into empsalary1028 values(105,'imthiya','04/29/1985','accounts',45000.00);

1 row(s) inserted.

select * from empsalary1028;

b) Display the number of employees working in each department. –

select dept,count(empcode) from empsalary1028 group by dept;


c) Find the sum of the salaries of all employees. –

select sum(salary) from empsalary1028;

d) Find the sum and average of the salaries of employees of a particular department.

select dept,sum(salary),avg(salary) from empsalary1028 group by dept having dept='sales';

e)Find the highest salary that an employee draws.

select max(salary) from empsalary1028;

f) Find the least salary that an employee draws..

select min(salary) from empsalary1028;

g) Find the total salary for each department

select dept,sum(salary) from empsalary1028 group by dept;


h) Increase the salary of those employees working for the computer department by Rs. 1000.

update empsalary1028set salary=salary+1000 where dept='accounts';

1 row(s) updated.

select * from empsalary1028;

i) Display all employees increasing order of their age for a specific department.

select * from empsalary1028 where dept='sales' order by dob asc;

Result: The above query successfully completed and verified.

PROGRAM 4:

INVENTORY DATABASE An inventory database has the following tables ITEM (ItemCode: number,
ItemName: text; Price: number (10,2)) PURCHASE (ItemCode: number, Quantity: number)
a) Create the tables with the above attributes.

b) Enter 5 — 7 tuples into the tables.

c) List the items purchased

d) Display the total items purchased (listing must have the columns: ItemCode ItemName,
TotalQuantity)

e) List the items which are not purchased by anyone

a)Create the tables with the above attributes.

Table 1: item

create table item20cs1k1028(itemcode number primary key, itemname varchar2(20),price


number(10,2)); desc item20cs1k1028;

Create table 2:

Table 2: purchase

create table purchase20cs1k1028(itemcode number primary key, quantity number);

desc purchase20cs1k1028;

b) Enter 5 — 7 tuples into the tables.

insert into item20cs1k1028 values(:itemcode,:itemname,:price);

select * from item20cs1k1028;

Insert values into purchase table:


insert into purchase20cs1k1028 values(:itemcode,:quantity);

select * from purchase20cs1k1028;

c) List the items purchased

Select item.itemcode, item.itemname,purchase.quantity from item,purchase where


item.itemcode=purchase.itemcode;

d) Display the total items purchased (listing must have the columns: ItemCode ItemName, Total,
Quantity)

To connect two table use - view or join concept

Create view

create view purchaseview20cs1k1028as select item.itemname,purchase.itemcode,purchase.quantity


from item,purchase where item.itemcode=purchase.itemcode;

select * from purchaseview20cs1k1028;

Display the total item purchased

select itemcode,itemname,sum(quantity) as TotalQuantity from purchaseview group by


itemcode ,itemname;

List the items which are not purchased by anyone. .

insert into item20cs1k1028 values(222,'pen',10);

select * from item20cs1k1028;

Item table:
. select itemname from item where itemcode not in (select itemcode from purchase);

Result: The above program was successfully completed and verified.

PROGRAM :5

BANK CUSTOMER DATABASE

A bank customer database has two tables CUSTOMER and ACCOUNT.

CUSTOMER (CustNo: number; CustName: text; City: text; AccNo: number; Balance: number (10,2))

ACCOUNT (AccNo: number; AccType: text; Branch: text; AccStatus: text; ChequeFacility: text

a) Create the above tables and specify the primary and foreign keys

b) Enter 5 — 8 tuples for each relation

c) List the customers from "Bangalore" who have cheque facility.

d) List all the customers whose balance is greater than 30000.00 and have anactiveaccount.
e) Find the current outstanding balance amount of branch "Malleshwar"

a) Create the above tables and specify the primary and foreign keys

Create 2 Tables:

Create Account table:

create table account1028(accno number(5) primary key,acctype varchar2(20),branch varcha


r2(10),accstatus varchar2(10),chequefacility varchar2(10));

desc account1028;

Customer Table:

create table customer1028(custno number(7) primary key,custname varchar2(20),city varch


ar2(20),accno number(15) references account(accno),balance number(10,2));

desc customer1028;

b) Enter 5 — 8 tuples for each relation

insert into account1028 values(:accno,:acctype,:branch,:accstatus,:chequefacility);

select * from account1028;

Insert into customer table:

insert into customer1028 values(:custno,:custname,:city,:accno,:balance);

select * from customer1028;

c) List the customers from "Bangalore" who have cheque facility.

select custname from account,customer where city='bangalore' and chequefacility='yes' and


account.accno=customer.accno;

d) List all the customers whose balance is greater than 30000.00 and have anactiveaccount.

select custname from account,customer where accstatus='active' and balance >30000 and
account.accno=customer.accno;
e) Find the current outstanding balance amount of branch "Malleshwar"

select sum(balance) as OutstandingBalance from account,customer where branch='mall eshwar' and


account.accno=customer.accno;

Result:

Thus the above query was successfully fetch the data from bank customer database

Program 6

INSURANCE DATABASE

Consider the Insurance database given below.

The primary keys are underlined and the data types are specified.

PERSON (Driverld: text; Name: text; Address: text)

CAR (RegNo: text; Model: text; Year: number)

OWNS (DriverId: text; RegNo: text)

ACCIDENT (ReportNo: number, AccDate: Date; Location: text)

PARTICIPATED (DriverId; text; RegNo: text; ReportNo; number, Dmg_Amt:number (10, 2))

a) Create the above tables by specifying the primary and foreign keys.
b) Enter at least five tuples for each relation

c) Update the damage amount for each car accident.

d) Add a new accident to the database.

e) Find the total number of people who owned cars that were involved in accidents in the year 2002.

f) Find the number of accidents in which cars belonging to a specific model were involved.

g) Display the owners and their car details.

a) Create the above tables by specifying the primary and foreign keys.

create table person1028(driverid varchar2(20) primary key,name varchar2(20),address varchar2(20));

desc person1028;

CAR (RegNo: text; Model: text; Year: number)

create table car1028(regno varchar2(20) primary key,model varchar2(20),year number);

desc car1028;

--OWNS (DriverId: text; RegNo: text)

create table owns1028(driverid varchar2(20) references person(driverid),regno varchar2(20) referenc es


car(regno));

desc owns1028;

--ACCIDENT (ReportNo: number, AccDate: Date; Location: text)

create table accident1028(reportno number primary key,accdate date,location varchar2(20));

desc accident1028;
-- PARTICIPATED (DriverId; text; RegNo: text; ReportNo; number, Dmg_Amt:number (1 0,2))

create table participated1028(dirverid varchar2(20) references person(driverid), regno varchar2(20) r


eferences car(regno),reportno number references accident(reportno), dmg_amt number(10,2));

desc participated1028;

b) Enter at least five tuples for each relation Insert values into person table:

insert into person1028 values(:driverid,:name,:address);

select * from person1028;

Insert values into car table:

insert into car1028 values(:regno,:model,:year);

select * from car1028;

Insert values into owns table:

insert into owns1028 values(:driverid,:regno);

select * from owns1028;

Insert values into accident table:

insert into accident1028 values(:reportno,:accdate,:location);

select * from accident1028;

Insert values into participated table:

insert into participated1028 values(:driverid,:regno,:reportno,:dmg_amt);

select * from participated1028;

d)insert into accident1028 values(666,'07/17/2015','paris');

select * from accident1028;


e)Find the total number of people who owned cars that were involved in accidents in the year 2002.

select count(*) from accident1028 where accdate between '01/01/2002' and '12/31/2002';

--f) Find the number of accidents in which cars belonging to a specific model were involved.

select count(*) as Maruthi_Accident from car,accident,participated where car.regno= participated.regno


and accident.reportno=participated.reportno and car.model='maruthi';

g)Display the owners and their car details.

select person.driverid,person.name,person.address,car.regno,car.model from person,car,owns w here


owns.regno=car.regno and person.driverid=owns.driverid;

RESULT

Process finished

PROGRAM 7
ORDER PROCESSING DATABASE

Consider the following relations for an order processing database application in a company.
CUSTOMER (Custld: number, CustName: text; City: text)

CUSTORDER (OrderNo; number; OrderDate: date; Custld: number; OrderAmount: number) ITEM
(ItemNo: number, ItemName: text; UnitPrice number (10,2));

ORDER_ITEM (OrderNo: number, ItemNo: number; OrdltemQty: number)

WAREHOUSE (Warehouse No: number; City: text)

SHIPMENT (OrderNo: number;WarehouseNo: number;ShipDate: date)

a) Create the above tables by properly specifying the primary keys and the foreign keys.

b) Enter atleast five tuples for each iteration.

c) Produce a listing: CustName; no_of_orders; avg_order_amt; where the middle attribute is the
total average order amount for that customer.

d) List the order_no for orders that were shipped from all the warehouses that the company has
in a specific way

e) Demonstrate the delete of itemno 919 from the ITEM table and make that field null in the
ORDER_ITEM table.

Create table customertable1028bca(custid number(2) primary key,custname char(10) not null,city


char(10) not null);

desc customertable1028bca;

create table itemtable1028bca(itemno number(5) primary key, itemname char(10) not null,unitprice
number(10) not null);

desc itemtable1028bca;

create table custordertable1028bca(orderno number(5) primary key,orderdate date not null, custid
number(5) references customertable1028bca(custid),orderamount number(10,2) not null);

desc custordertable1028bca;
create table orderitemtable1028bca(orderno number(5) references
custordertable1028bca(orderno),itemno number(5) references itemtable1028bca(itemno) on delete
cascade,orderitemqty number(5) not null);

desc orderitemtable1028bca;

create table warehousetable1028bca(warehouseno number(5) primary key,city char(10) not null);

desc warehousetable1028bca;

create table shipmenttable1028bca(orderno number(5) references

custordertable1028bca(orderno),warehouseno number(5) references


warehousetable1028bca(warehouseno),shipdate date not null);

desc shipmenttable1028bca;

b) Enter atleast five tuples for each iteration.

insert into customertable1028bca values(:custid,:custname,:city);

select * from customertable1028bca;

insert into custordertable1028bca values(:orderno,:orderdate,:custid,:orderamount);

select * from custordertable1028bca;

insert into itemtable1028bca values(:itemno,:itemname,:unitprice);

select * from itemtable1028bca;

insert into orderitemtable1028bca values(:orderno,:itemno,:orditemquantity);


select * from orderitemtable1028bca;

insert into warehousetable1028bca values(:warehouseno,:city);

select * from warehousetable1028bca;

insert into shipmenttable1028bca values(:orderno,:warehouseno,:shipdate);

select * from shipmenttable1028bca;

c) select custname,avg(orderamount) as TOTAL_AVERAGE_ORDER_AMOUNT,count(orderno) from


customertable1028bca,custordertable1028bca where
customertable1028bca.custid=custordertable1028bca.custid group by custname;

d) Select orderno,warehouseno from shipmenttable1028bca where warehouseno in (select


warehouseno from warehousetable1028bca where city ='Bangalore');

e)Delete from itemtable1028bca where itemno=10;

select * from itemtable1028bca;

RESULT

Process finished
PROGRAM 8

STUDENT ENROLLMENT DATABASE

Create tables :

create table student1028bca(regno number(10) primary key, name varchar2(15)not null, major
varchar(10) not null, bdate date not null);

desc student1028bca;

create table course1028bca(courseno number(5) primary key,coursename varchar2(20) not


null,department varchar2(20) not null);

desc course1028bca;

create table enroll1028bca(regno number(10) references studentbca(regno),courseno number(5)


references coursebca(courseno),semester number(5) not null,totalmarks number(5) not null);

desc enroll1028bca;

create table textbook103bca(bkisbn number(5) primary key,booktitle varchar2(20),publisher


varchar2(20),author varchar2(20));

desc textbook1028bca;

create table bookadoption1028bca(courseno number(5) references course1028(courseno),bkisbn


number(5) references textbook1028(bkisbn),semester number(5));

desc bookadoption1028bca;
b.Enter at least five tuples for each relation.
insert into student1028bca values(:regno,:name,:major,:bdate);

select * from student1028bca;

insert into course1028bca values(:courseno,:coursename,:department);

select * from course1028bca

insert into enroll1028bca values(:regno,:courseno,:semester,:totalmarks);

select * from enroll1028bca;

insert into textbook1028bca values(:bk_isbn,:booktitle,:publisher,:author);


select * from textbook1028bca;

insert into bookadoption1028bca values(:courseno,:bk_isbn,:regno);


select * from bookadoption1028bca;

c. Insert a new text book to the database and make this book be adopted by some
department.
insert into textbook1028bca values(6005,'Java','albertz','prentice');
select * from textbook1028bca;

insert into bookadoption1028bca values(12,6005,4);


select * from bookadoption1028bca;

d.List the student who have been enrolled


select e.regno,s.name ,e.courseno,s.major,e.semester from enroll1028bca
e,student1028bca s where e.regno=s.regno;

e.List the student who have registered but not enrolled


select s.regno,s.name,s.major from student1028bca s where s.regno not in(select
regno from enroll1028bca);

f.List the book which have been adopted


select t.booktitle,t.publisher,t.author from textbook1028bca t,bookadoption1028bca
a where t.bkisbn=a.bkisbn;
g.List any department that has all its adopted books published by a specific
publisher.

select c.department,c.coursename ,t.bkisbn,t.booktitle,t.publisher from


course1028bca c,bookadoption1028bca a,textbook1028bca t where t.bkisbn=a.bkisbn
and a.courseno=c.courseno and t.publisher='BPB';

h. Illustrate inner join,outer join by joing student and enroll table.


select * from bcaenrollstudent inner join bcaenroll on
bcaenrollstudent.regno=bcaenroll.regno;

select * from student1028bca left join enroll1028bca on


student1028bca.regno=enroll1028bca.regno;

select * from student1028bca right join enrollbca on


student1028bca.regno=enroll1028bca.regno;

select * from student1028bca full join enroll1028bca on


student1028bca.regno=enroll1028bca.regno;

RESULT

Process finished
PROGRAM 9
MOVIE DATABASE

create table studio1028(studioname varchar2(20)


primarykey,address varchar2(20));
desc studio1028;

create table movie1028(title varchar2(20) primary key,year


number,length number,incolour varchar2(20),studioname
varchar2(20) references studio1028(studioname),producer
varchar2(20))
desc movie1028;

create table moviestar1028(starname varchar2(20),address


varchar2(20),gender char(1),birthdate date);
desc moviestar1028;

create table starsin1028(movietitle varchar2(20),movieyear


number,starname varchar2(20),foreign key(movietitle) references
movie1028(title));
desc starsin1028;

create table movieexecutive1028(starname varchar2(20),address


varchar2(20),networth number);
desc movieexecutive1028;

b) Enter atleast 5 tuples for each relation


insert into studio1028 values(:studioname,:address);
select * from studio1028;

insert into movie1028


values(:title,:year,:lenght,:incolour,:studioname,:producer);
select * from movie1028;

insert into moviestar1028


values(:starname,:address,:gender,:dob);
select * from moviestar1028;

insert into starsin1028 values(:movietitle,:movieyear,:starname);


select * from starsin1028;

insert into movieexecutive1028


values(:starname,:address,:networth)
select * from movieexecutive1028;

c) Find the address of mgm studio


select address from studio1028 where studioname='mgm';

d) Find Julia Roberts birthdate

select birthdate from moviestar1028 where starname='julia roberts';

e)Find all the stars that appear in a movie made in 1980 or a movie with “life” in the title

select starname from starsin1028 where movieyear='1980' or movietitle='life';

• Find all the executive worth $100000;

select starname from movieexecutive1028 where networth =100000;


F)Find all the stars who are either a Male or live in “Miami” ( Miami as part of their address) S

select * from moviestar1028 where address='mian' or gender='M';

RESULT

Process finished
PROGRAM 10

STUDENT FACULITY ALLOTMENT DATABASE

CREATE TABLES

create table student33(snum number(2) primary key,sname char(15) not null,major char(15) not
null,leve char(10) not null,age number(2));

desc student33;

create table faculty33(fid number(5) primary key,fname char(15) not null, deptid number(4) unique);

desc faculty33;

create table class33(cname char(15) primary key,meets_at varchar2(15) not null,room number(4) not
null,fid number(5) references faculty33(fid));

desc class33;

create table enrolled33(snum number(2) references student33(snum),cname char(15) references


class33(cname));

desc enrolled33;

b) enter atleast 5 tuples

Insert into student33 values('2','Sam','Commerce','JR',26);

Insert into student33 values('3','Jerin','Management','SR',27);

Insert into student33 values('4','Prakask','Computer','JR',25);

Insert into student33 values('5','Arun','Commerce','SR',25);

Insert into student33 values('6','Babu','Computer','JR',26);


select * from student33;

Insert into faculty33 values('10','Ram','111');

Insert into faculty33 values('20','Sibi','222');

Insert into faculty33 values('30','Mathew','333');

Insert into faculty33 values('40','Morgan','444');

Insert into faculty33 values('50','Mary','555');

select * from faculty33;

Insert into class33 values('I BCA','4 Hr','128','10');

Insert into class33 values('II BCOM','4 Hr','203','20');

Insert into class33 values('II BSC','1 Hr','202','10');

Insert into class33 values('I BBA','3 Hr','204','20');

Insert into class33 values('II BBA','3 Hr','204','30');

Insert into class33 values('I BCOM','4 Hr','203','40');

Insert into class33 values('III BCOM','4 Hr','128','40');

select * from class33;

Insert into enrolled33 values('1','II BSC');

Insert into enrolled33 values('2','I BCOM');

Insert into enrolled33 values('3','II BBA');

Insert into enrolled33 values('4','I BCA');

Insert into enrolled33 values('5','II BCOM');

Insert into enrolled33 values('6','I BCA');

Insert into enrolled33 values('7','I BCA');


Insert into enrolled33 values('8','I BCA');

Insert into enrolled33 values('9','I BCA');

Insert into enrolled33 values('10','I BCA');

select * from enrolled33;

c) select distinct (s.sname) from student33 s,class33 c,enrolled33 e,faculty33 f where s.snum=e.snum
and e.cname=c.cname and c.fid=f.fid and f.fname='Ram' and s.leve='JR';

d) select c.cname from class33 c where c.room=128;

e)select distinct s.sname from student10 s where s.snum in (select e1.snum from enrolled4 e1,enrolled4
e2,class10 c1, class10 c2 where e1.snum <> e2.snum and e1.cname <> e2.cname and
e1.cname=c1.cname and e2.cname=c2.cname and c1.meets_at=c2.meets_at);

f)select f.fname,c.fid,c.room from faculty33 f,class10 c where c.fid=f.fid;

g)select distinct f.fname from faculty33 f where 5 >(select count(e.snum) from class33 c,enrolled33 e
where c.cname=e.cname and c.fid=f.fid);

RESULT

Process finished

PROGRAM11

Write a program to multiply two numbers by prompting for values from the user. Then the result should
be displayed as “The multiplication of 5 and 10 is 50” (if 5 and 10 were supplied by the user)

declare

a number;
b number;

c number;

begin

a:=:a;

b:=:b;

c:=a*b;

dbms_output.put_line('The multiplication of'||a||'and'||b||'is'||c);

end;

RESULT

STATEMENT PROCESSED

PROGRAM 12

Display the name, salary and job of the employee MARTIN of the emp table in the format MARTIN is
working as SALESMAN and earning a salary of 1250 using a PL/SQL block

create table emp1028bca(ename varchar2(20), job varchar2(20), sal number(6));

desc emp1028bca;

insert into emp1028bca values('martin','salesman',1250);

insert into emp1028bca values('sanu','engineer',10000);

insert into emp1028bca values('appu','doctor',1000);

insert into emp1028bca values('anu','salesman',2500);

insert into emp1028bca values('sam','advocate',3200);

select * from emp1028bca;


declare

vname varchar2(20);

vsal number;

vjob varchar2(10);

begin

select ename,job,sal into vname,vjob,vsal from emp1028bca where ename='martin';

dbms_output.put_line(vname||' is working as '||vjob||' and earning a salary of '||vsal);

end;

RESULT

STATEMENT PROCESSED

PROGRAM 13

Write a PL/SQL code to retrieve the employee name, join_date and designation from employee database
of an employee whose number is input by the user

create table employee33(empno number(8), ename varchar2(20), joindate date, designation


varchar2(20));

desc employee33;

insert into employee33 values(111,'arun','05-12-1990','clerk');


insert into employee33 values(222,'banu','10-17-1992','typist');

select * from employee33;

DECLARE

empnum number(8):=&num;

c_name employee.ename%type;

c_joindate employee.joindate%type;

c_designation employee.designation%type;

begin

SELECT ENAME,JOINDATE,DESIGNATION INTO C_NAME, C_JOINDATE, C_DESIGNATION FROM EMPLOYEE


WHERE EMPNO = EMPNUM;

DBMS_OUTPUT.PUT_LINE('NAME: ' || c_name);

DBMS_OUTPUT.PUT_LINE('JOINING DATE: ' || c_JOINDATE);

DBMS_OUTPUT.PUT_LINE('DESIGATION: ' || c_DESIGNATION);

END;

RESULT

STATEMENT PROCESSED

You might also like