0% found this document useful (0 votes)
7 views6 pages

LAb Output

The document outlines the implementation of Row Level and Statement Level Triggers, along with transaction control languages including commit, rollback, and save points. It also details Data Manipulation Language operations such as insert, delete, and update, as well as various types of joins like Cartesian Product, Equi Join, Left Outer Join, Right Outer Join, and Full Outer Join. Additionally, it covers aggregate functions, set operations, and nested queries with corresponding outputs for each operation.

Uploaded by

shanthi
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)
7 views6 pages

LAb Output

The document outlines the implementation of Row Level and Statement Level Triggers, along with transaction control languages including commit, rollback, and save points. It also details Data Manipulation Language operations such as insert, delete, and update, as well as various types of joins like Cartesian Product, Equi Join, Left Outer Join, Right Outer Join, and Full Outer Join. Additionally, it covers aggregate functions, set operations, and nested queries with corresponding outputs for each operation.

Uploaded by

shanthi
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/ 6

20.

(a)Write and execute a program to implement Row Level and Statement Level Triggers
(b) Write and execute transaction control languages

(i)Commit, rollback and save points.

a. Output :

Row-Level Trigger: Inserted Employee ID 1


Statement-Level Trigger: Insert operation performed on Employee table.
Row-Level Trigger: Inserted Employee ID 2
Statement-Level Trigger: Insert operation performed on Employee table.

Notes:

 To see DBMS_OUTPUT.PUT_LINE messages, ensure the DBMS_OUTPUT is enabled in


your SQL client (e.g., Oracle SQL Developer).
 For enabling:

Sql

SET SERVEROUTPUT ON;

Run this before executing the script.

b. AccID | Balance
--------------
1 | 1000
2 | 2000

AccID | Balance
--------------
1 | 900
2 | 2000

AccID | Balance
--------------
1 | 900
2 | 2100

AccID | Balance
--------------
1 | 900
2 | 2000

Output Summary:
 After First Update:
o Account 1: Balance reduced to 900.
 After Savepoint Creation:
o No visible output; SAVEPOINT sp1 is created.
 After Second Update:
o Account 2: Balance temporarily increased to 2100.
 After Rollback to Savepoint:
o Account 2: Balance reverted to 2000.
 After Commit:
o Transaction committed. Changes to Account 1 balance are now
permanent.

4. Write and execute Data Manipulation Language

(a)Insert, Delete, Update

(b) Cartesian Product, Equi Join, Left Outer Join, Right Outer Join and Full Outer Join

(a) Insert, Delete, Update

Initial Table States:

1. Employee Table:

markdown
Copy code
EmpID | Name | Salary
-----------------------
1 | Alice | 50000
2 | Bob | 60000

2. Department Table:

markdown
Copy code
DeptID | DeptName
-----------------
1 | HR
2 | IT

Insert:
sql
Copy code
INSERT INTO Employee VALUES (3, 'Charlie', 70000);
INSERT INTO Department VALUES (3, 'Finance');

Output After Insert:

 Employee Table:

markdown
Copy code
EmpID | Name | Salary
-------------------------
1 | Alice | 50000
2 | Bob | 60000
3 | Charlie | 70000

 Department Table:

markdown
Copy code
DeptID | DeptName
-----------------
1 | HR
2 | IT
3 | Finance

Delete:
sql
Copy code
DELETE FROM Employee WHERE EmpID = 2;

Output After Delete:

 Employee Table:

markdown
Copy code
EmpID | Name | Salary
-------------------------
1 | Alice | 50000
3 | Charlie | 70000

Update:
sql
Copy code
UPDATE Employee SET Salary = 80000 WHERE EmpID = 3;

Output After Update:

 Employee Table:

markdown
Copy code
EmpID | Name | Salary
-------------------------
1 | Alice | 50000
3 | Charlie | 80000

(b) Joins

Cartesian Product:
sql
Copy code
SELECT * FROM Employee, Department;
Output:

 Combines all rows from both tables.

markdown
Copy code
EmpID | Name | Salary | DeptID | DeptName
--------------------------------------------
1 | Alice | 50000 | 1 | HR
1 | Alice | 50000 | 2 | IT
1 | Alice | 50000 | 3 | Finance
3 | Charlie | 80000 | 1 | HR
3 | Charlie | 80000 | 2 | IT
3 | Charlie | 80000 | 3 | Finance

Equi Join:
sql
Copy code
SELECT e.EmpID, e.Name, e.Salary, d.DeptName
FROM Employee e, Department d
WHERE e.EmpID = d.DeptID;

Output:

 Matches rows where EmpID in Employee equals DeptID in Department.

markdown
Copy code
EmpID | Name | Salary | DeptName
------------------------------------
1 | Alice | 50000 | HR

Left Outer Join:


sql
Copy code
SELECT e.EmpID, e.Name, e.Salary, d.DeptName
FROM Employee e LEFT OUTER JOIN Department d
ON e.EmpID = d.DeptID;

Output:

 All rows from Employee with matching Department rows and NULL for non-match-
ing:

markdown
Copy code
EmpID | Name | Salary | DeptName
------------------------------------
1 | Alice | 50000 | HR
3 | Charlie | 80000 | NULL

Right Outer Join:


sql
Copy code
SELECT e.EmpID, e.Name, e.Salary, d.DeptName
FROM Employee e RIGHT OUTER JOIN Department d
ON e.EmpID = d.DeptID;

Output:

 All rows from Department with matching Employee rows and NULL for non-match-
ing:

sql
Copy code
EmpID | Name | Salary | DeptName
------------------------------------
1 | Alice | 50000 | HR
NULL | NULL | NULL | IT
NULL | NULL | NULL | Finance

Full Outer Join:


sql
Copy code
SELECT e.EmpID, e.Name, e.Salary, d.DeptName
FROM Employee e FULL OUTER JOIN Department d
ON e.EmpID = d.DeptID;

Output:

 All rows from both tables, with NULL for non-matching entries:

sql
Copy code
EmpID | Name | Salary | DeptName
------------------------------------
1 | Alice | 50000 | HR
3 | Charlie | 80000 | NULL
NULL | NULL | NULL | IT
NULL | NULL | NULL | Finance
(a) Write and execute transaction control languages
6.
(i)Commit, rollback and save points.

(b) Write and execute


(i)Aggregate Functions
(ii)Set Operations

(iii)Nested Queries

Output:

TotalOrders | TotalRevenue | AverageOrderValue | MinimumOrderValue | Maxim-


umOrderValue
---------------------------------------------------------------------------
----------
2 | 1300.00 | 650.00 | 600.00 | 700.00
b. CustomerID | Name

-----------------

1 | Alice

Output:

 Average TotalAmount is 650.00, so the query retrieves orders with amounts greater
than this value:

markdown
Copy code
OrderID | CustomerName | TotalAmount
------------------------------------
2 | Bob | 700.00

You might also like