PL/SQL UNIT-IV SHORT NOTES (Syllabus Aligned)
1. EXCEPTIONS
- Errors during program execution.
- Types:
• Predefined (NO_DATA_FOUND, TOO_MANY_ROWS, ZERO_DIVIDE)
• User-defined exceptions
- Syntax:
BEGIN
-- code
EXCEPTION
WHEN exception_name THEN
-- handler
END;
2. CURSORS
- Pointer to result of a query (row-by-row processing).
- Types:
• Implicit cursor
• Explicit cursor
- Explicit cursor steps:
1. Declare CURSOR c IS SELECT...
2. OPEN c;
3. FETCH c INTO variables;
4. CLOSE c;
- Attributes: %FOUND, %NOTFOUND, %ROWCOUNT, %ISOPEN
3. PROCEDURES
- Subprogram performing actions.
- Syntax:
CREATE OR REPLACE PROCEDURE p IS
BEGIN
-- code
END;
4. FUNCTIONS
- Similar to procedures but return a value.
- Syntax:
CREATE OR REPLACE FUNCTION f RETURN datatype IS
BEGIN
RETURN value;
END;
5. TRIGGERS
- Automatically executed when an event occurs (INSERT, UPDATE, DELETE).
- Types:
• BEFORE / AFTER
• ROW-level / Statement-level
- Syntax:
CREATE OR REPLACE TRIGGER t
BEFORE INSERT ON table
FOR EACH ROW
BEGIN
-- code
END;
6. NoSQL DATABASES
- Non-relational databases for unstructured/large-scale data.
- Properties:
• Schema-less
• Distributed
• High scalability
• Supports Big Data
- Types:
• Document (MongoDB)
• Key-Value (Redis)
• Column-family (Cassandra)
• Graph (Neo4j)
7. INTRODUCTION TO MONGODB
- Document-oriented NoSQL database.
- Stores data in BSON documents.
- Collections = Tables, Documents = Rows
- Basic commands:
show dbs
use mydb
[Link]({...})
[Link]()
END OF NOTES