- LPU MCA Semester 1
- CAP570
- Unit 5
CAP570 · Unit 5: PL/SQL
Benefits and features of PL/SQL
10 practice questions · in the ETE syllabus
Key points
- Blocks, exceptions and tight SQL integration
- Fewer network round trips improve performance
- Procedure acts, function returns a value, trigger fires on change
- Packages group related subprograms
PL/SQL combines SQL with procedural programming, which gives several benefits.
| Benefit or feature | What it means |
|---|---|
| Block structure | Code is organised in blocks that can be nested |
| Performance | A block is sent in one call, reducing network round trips |
| Exception handling | Runtime errors are caught in the EXCEPTION section |
| Tight SQL integration | SQL statements and data types are used directly |
| Reusability | Stored procedures, functions and packages are written once |
| Portability | Runs on any platform that runs Oracle |
| Security | Users get EXECUTE rights on a procedure without table access |
Main PL/SQL objects: a procedure performs an action, a function returns a value and can be used in an expression, a trigger fires automatically on INSERT, UPDATE or DELETE, a cursor processes the rows of a query one at a time, and a package groups related procedures, functions and variables.
Exam trap: portability means across operating systems running Oracle, not across database vendors.
Try two questions
Which PL/SQL object runs automatically when a table is changed by an INSERT, UPDATE or DELETE?
- Cursor
- Package
- Trigger
- Function
Show the answer
C. A trigger is a stored block that fires on a table event.
Why not A: A cursor processes query rows one at a time.
Why not B: A package groups related subprograms.
Why not D: A function runs only when it is called.
How can PL/SQL improve security?
- Every PL/SQL block automatically encrypts all columns it reads
- Users can be allowed to run a procedure without having direct access to the underlying tables
- PL/SQL blocks can run only when no other user is connected
- PL/SQL removes the need for user passwords entirely
Show the answer
B. Granting EXECUTE on a procedure exposes only what the procedure does.
Why not A: Blocks do not encrypt data by themselves.
Why not C: Blocks run alongside other users.
Why not D: Passwords remain necessary.