0% found this document useful (0 votes)
58 views11 pages

Dbms Lab Name: Rollno: Section

This document contains 8 questions about writing PL/SQL programs to perform various tasks like inputting and displaying names and numbers, calculating mathematical operations, reversing numbers, inserting into tables, and displaying patterns. For each question, it provides the PL/SQL code for the program and sample output. The document was produced for a DBMS lab course and is signed by the teacher in charge.

Uploaded by

Manish Nagesh
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)
58 views11 pages

Dbms Lab Name: Rollno: Section

This document contains 8 questions about writing PL/SQL programs to perform various tasks like inputting and displaying names and numbers, calculating mathematical operations, reversing numbers, inserting into tables, and displaying patterns. For each question, it provides the PL/SQL code for the program and sample output. The document was produced for a DBMS lab course and is signed by the teacher in charge.

Uploaded by

Manish Nagesh
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/ 11

DBMS LAB NAME : Rollno : Section :

Lab 8 Introduction to PL/ SQL

Q.1. Write a PL/SQL program to input a name and display it.

PL/ SQL Program :

OUTPUT :
Enter value for name: dinesh
old 4: name := '&name';
new 4: name := 'dinesh';
Your name is dinesh

PL/SQL procedure successfully completed.

Department of CSE, BIT DURG Sign of student Page 75


DBMS LAB NAME : Rollno : Section :

Q.2. Write a PL/SQL program to input 2 numbers and display addition, subtraction, multiplication, division and
modulus of these 2 numbers.

PL/ SQL Program :

OUTPUT :
Enter value for a: 5
old 2: a number := &a;
new 2: a number := 5;
Enter value for b: 2
old 3: b number := &b;
new 3: b number := 2;
Addition = 7
Subtraction = 3
Multiplication = 10
Division = 2.5
Modulus = 1

PL/SQL procedure successfully completed.

Department of CSE, BIT DURG Sign of student Page 76


DBMS LAB NAME : Rollno : Section :

Q.3. Write a PL/SQL program to input a 5 digit number and display the reverse of that number.

PL/ SQL Program :

OUTPUT :
Enter value for n: 12345
old 2: n number := &n;
new 2: n number := 12345;
Reverse = 54321

PL/SQL procedure successfully completed.

Department of CSE, BIT DURG Sign of student Page 77


DBMS LAB NAME : Rollno : Section :

Q.4. Write a PL/SQL program to read the radius from the keyboard and insert it into table CIRCLE the radius along
with area, the CIRCLE table has two columns defined as radius and area.

PL/ SQL Program :

OUTPUT :
Enter value for r: 5
old 2: r number := &r;
new 2: r number := 5;
Radius and area inserted in circle table

PL/SQL procedure successfully completed.

SQL> select * from circle;

RADIUS AREA
---------- ----------
5 78.5

Department of CSE, BIT DURG Sign of student Page 78


DBMS LAB NAME : Rollno : Section :

Q.5. Write a PL/SQL program to input the employee number and display its total salary (i.e. sal + comm, and if comm
is null assume it to be 0).

PL/ SQL Program :

OUTPUT :
Enter value for eno: 7369
old 2: eno emp.empno%type := &eno;
new 2: eno emp.empno%type := 7369;
Totalsal = 800

PL/SQL procedure successfully completed.

Department of CSE, BIT DURG Sign of student Page 79


DBMS LAB NAME : Rollno : Section :

Q.6. Write a PL/SQL program to input a number and find whether it is even or odd, if it is even insert it into the table
EVEN or insert it into table ODD, both tables have only one column i.e. NUM.

PL/ SQL Program :

OUTPUT :
Enter value for n: 5
old 2: n number := &n;
new 2: n number := 5;

PL/SQL procedure successfully completed.

SQL> select * from even;

no rows selected

SQL> select * from odd;

NUM
----------
5

Department of CSE, BIT DURG Sign of student Page 80


DBMS LAB NAME : Rollno : Section :

Q.7. Write a PL/SQL program to input a number and find the factorial of that number using
(i) For loop (ii) Simple loop (iii) While loop

PL/ SQL Program using for loop :

PL/ SQL Program using simple loop :

Department of CSE, BIT DURG Sign of student Page 81


DBMS LAB NAME : Rollno : Section :

PL/ SQL Program using while loop :

OUTPUT :
Enter value for n: 5
old 2: n number := &n;
new 2: n number := 5;
Factorial of 5 is = 120

PL/SQL procedure successfully completed.

Department of CSE, BIT DURG Sign of student Page 82


DBMS LAB NAME : Rollno : Section :

Q.8. Write a PL/SQL program to display the following patterns.

PL/ SQL Program :

OUTPUT :
1
2 3
4 5 6
PL/ SQL Program :

OUTPUT :
1
2 3
4 5 6
Department of CSE, BIT DURG Sign of student Page 83
DBMS LAB NAME : Rollno : Section :

PL/ SQL Program :

OUTPUT :
1
1 2 1
1 2 3 2 1

Department of CSE, BIT DURG Sign of student Page 84


DBMS LAB NAME : Rollno : Section :

PL/ SQL Program :

OUTPUT :
A
A B
A B C

Teacher I/ C
Prof. Dinesh Kumar Bhawnani

Department of CSE, BIT DURG Sign of student Page 85

You might also like