DMS Short
DMS Short
Any Three
b. Write syntax for creating and dropping views.
Ans-> SUM()
AVG()
MAX()
MIN()
COUNT()
d. Define Cursor. List the two types of cursor.
Ans- A cursor is a temporary work area created in the system memory when a SQL
> statement
is executed.
Types of cursor are:
1) Implicit cursor
2) Explicit cursor
Q2 Answer any THREE. (Four marks each)
a.
Ans. 1.Union: Combines results from two SELECT queries, removing duplicates.
Ex. SELECT name FROM Employees
UNION
SELECT name FROM Managers;
2.Union All:Combines results from two SELECT queries, including duplicates.
Ex
1. SELECT name FROM Employees
2. UNION ALL
3. SELECT name FROM Managers;
3.Intersection :Retrieves common records from two SELECT queries.
Ex
1. SELECT name FROM Employees
2. INTERSECT
3. SELECT name FROM Managers;
4.Minus:Retrieves records from the first SELECT query that aren't in the second.
Ex
1. SELECT name FROM Employees
2. MINUS
3. SELECT name FROM Managers;
b. Explain PL/SQL block structure with the help of diagram.
c. Write a PL/SQL program which accepts the customer_ID from the user. If the
enters an invalid ID then the exception invalid_id is raised using exception
handling
1. DECLARE
2. c_id NUMBER(10);
3. invalid_id_Exception EXCEPTION;
4. BEGIN
5. c_id := &c_id;
6.
7. IF c_id < 0 THEN
8. RAISE invalid_id_Exception;
9. END IF;
10.
11. EXCEPTION
12. WHEN invalid_id_Exception THEN
13. DBMS_OUTPUT.PUT_LINE('Invalid customer id');
14. END;
15. /
16.