Professional Documents
Culture Documents
Department of Computer Science and Engineering Set - Ii Exp:01
Department of Computer Science and Engineering Set - Ii Exp:01
Department of Computer Science and Engineering Set - Ii Exp:01
SET –II
Exp:01
Table:Department
Department _ID(PK) Department _Name
Table:Employee
Employee_ID(PK) Employee_Name Employee_Age
Table:Employee_Department
Employee_ID(PK) Department_ID(PK)
FK:Employee_ID references Employee(Employee_ID),Department_ID references Department(Dept_ID)
Table:Building
Building _ID(PK) Building _Name
Table: Department_Building
Department_ID(PK) Building _ID(PK)
FK: Building _ID references Building (Building _ID),Department_ID references Department(Dept_ID)
Solution:
Table:Account
Emp_ID(PK) Salary
Exp:02
Write a function that will take Emp_ID as parameter and return the Emp_Name and Balance from the
above table.
As
Begin
declare @Name varchar(50)
declare @Salary varchar(50)
set @Name = (select Emp_Name from Employee where Emp_ID = @ID );
set @Salary = (select Salary from Account where Emp_ID = @ID);
or
in ORACLE
Is
Begin
@Name varchar(50);
@Salary varchar(50);
select Emp_Name into @Name from Employee where Emp_ID = @ID ;
select Salary into @Salary from Account where Emp_ID = @ID ;
return @Name + ’ ‘ + @Salary ;
End getName_Balance
Execution:
select dbo.getName_Balance('4');
or
select dbo.getName_Balance('4') from DUAL;
ORACLE 10G te
Exp:03
Create a Trigger that raises an User Defined Error Message and does not allow updating and Insertion.
END