0% found this document useful (0 votes)
14 views

Example

easy

Uploaded by

kruthi reddy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Example

easy

Uploaded by

kruthi reddy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

1.

Example

Write a pl/sql program welcome

Test Output:

2.Example

Insert value into dept table using pl/sql

Test Output:

3.Example

Write a pl/sql program to get the area of the circle provided the radius is given.

Test Output:

4.Example

Write a pl/sql program to get the name and salary of specified employee.

Test Output:

5.Example

Write a pl/sql program to get the name and salary of specified employee using %type attribute.

Test Output:

6.Example

Write a pl/sql program to get the name and salary of specified employee

using %type attribute

Test Output:

PL/SQL Control Structures

7.Example

Write a pl/sql program Accept Number from a User and display Hello message if the entered

number is Positive.

Test Output:

8.Example
Write a pl/sql program to Display Salary of a specified employee increasing by 500 if its salary

is more than 3000.

Test Output:

9.Example

Write a pl/sql program to Accept number from a user and find out whether it is Odd or Even.

Test Output:

10.Example

Write a pl/sql program to Accept employee number from a user and increase its salary depends
on

the current salary as follows.

Salary Increment

>= 5000 12.5%; <5000 11%

Test Output:

11.Write a pl/ sql program by using Iterative Control / Loops

Test Output:

12.Write a pl/sql program by using while loop.

Test Output:

13.Write a pl/sql program by using FOR Loop

Test Output:

Exception Handling

14.Example

Write a PL/SQL Block to accept employee name from a user if it is exist display its salar y

otherwise display appropriate message using exception handling.

Test Output:
15.Example

Write a PL/SQL Block to display the salary of that employee whose age is 45 year otherwise
display appropriate message using exception handling.

Test Output:

16.Example

Write a PL/SQL Block to insert add one row in employee table with employee number and

name.Display appropriate message using exception handling on duplication entry of employee

number.

Test Output:

Aim: Writing triggers

Database Triggers:

Example

Test Output:

17.Example

Create or replace trigger upperdname before insert or update

on dept for each row

Test Output:

18.Example

Create or replace trigger emp_rest before insert or update or delete on

Emp.

Test Output:

19.Example

Create or replace trigger find_tran before insert or update

or delete on dept for each row

Test Output:
20.Examples:

Create of insert trigger, delete trigger and update trigger.

Test Output:

SQL> @trigger

Trigger created.

SQL> select * from Bus;

Test Output:

21.Create Trigger updchek before update on Ticket For Each Row

Test Output:

22.CREATE OR RELPLACE TRIGGER trig1 before insert on Passenger for each

row

Test Output:

AIM: Implement Cursors:

Example

Test Output:

Aim; Implement the %notfound Attribute

23.Write a cursor by using the %notfound Attribute

Test Output:

Aim; Implement the %found Attribute

24.Write a cursor program by using the % found Attribute

Test Output:

Aim: Implement The %rowCount Attribute:

25.Write a cursor program by using the %rowCount Attribute:


Test Output:

Aim:

26.To write a Cursor to display the list of Male and Female Passengers.

Test Output:

27.b)To write a Cursor to display List of Passengers from Passenger Table.

Test Output:

SQL>@Passenger

Test Output:

28.AIM: Implement SubPrograms in PL/SQL.

Create a procedure, which receives a number and display whether it is odd or

even.

Test Output:

29.SQL > execute/exec procedure_name(parameter list)

SQL> Exec example1(7)

Test Output:

Example

30.Make a procedure, which will accept a number and return it’s Square.

Test Output:

Example

31.Pass employee no and name and store into employee table.

Test Output:

SQL> exec emp_add(1013,’DAXESH’);

Test Output:
32.Example

Create a Procedure, which receives employee number and display employee name,

Designation and salary.

SQL>exec empdata(1051)

Test output:

Example

33.Write a PL/SQL block, which will use a user-defined procedure, which accept employee

number and return employee name and department name in a out parameter.

Test output:

34.Example

Create a procedure, which receives department number and get total Salary of that

Test output:

35.Example

Write procedure to accept Department number and display Name, Designation and Age of

each employee belonging to such Department.

Test output:

SQL>exec dept_list(20);

Test output:

36.Example

Create a procedure, which will accept Deptno and Display no of employee under different

grade.

Test output:

37.AIM: Implement Functions of PL/SQL.


SQL>exec empcount (30);

Test output:

38.Example

Create a function to get cube of passed number

Test output:

SQL> select cube(5) from dual;

Test output:

39.Example

Write a Function to find out maximum salary for the passed designation.

Test output:

SQL> SELECT MAXJOB(‘ANALYST’) FROM DUAL;

Test output:

40.Example

Create a Function to find out existence of employee whose name is passed as a parameter

Test output:

41.Example

Write a Function to find out Total salary for the passed department Name.

Test output:

Example

42.Write a function to check whether passed number is Odd or Even.

Test output:

Example
43.Write a Function to find out total annual income for the employee, who’s number we passed.

Test output:

SQL> select ann_income(1010) from dual;

Test output:

Example

44.Create a function, which receives three arguments, first two as a number and third as a

arithmetic.

Test output:

Additional Experiments:

45.Create relations for the following schemas and write queries for retrieving data.

Student(sid,sname,address)

Course(cid,cname,fee)

Enrolled(cid,sid,doj)

46.Apply key constraints & participation constraints for the following relations.

emp(eid,ename,sal)

dept(did,dname,location)

manages(did,eid,day)

47.Create relations for the following schemas and write quaries for retrieving.

Professor ( SSN,Nmae,Age,Rank)

Projects (project no,Sponsor Name,starting date,ending date,budget)

Graduate (SSN,Name,Age,Degree)

48.Create relations for the following schemas and write queries for retrieving

data. and apply key constraints

Supplies(Sid,Sname,Address)

Parts(pid,Pname,color)

Catalog(sid,pid,cost)

49.Create relations for the following schemas and write queries for retrieving

data. and apply key constraints


Sailors (sid,ssname,rating,age)

Boats( bid,bname,color)

Reserves(sid,bid,day)

50.Create relations for the following schemas and write queries for retrieving

data. and apply key constraints

Flights(flno,from,to,distance,departs,arrives)

Aircraft(aid,anme,cruisingrange)

Certified(eid,aid)

Employees(eid,enmae,salary)

You might also like