of Chapter 2.3 - Control Structures
of Chapter 2.3 - Control Structures
ENGINEERING
1. To have good understanding of database system concepts and design databases for
different applications.
2. To learn how to use a DBMS and RDBMS.
3. To implement and understand different types of DDL, DML and DCL statements.
4. To understand transaction concepts related to databases and recovery/backup
techniques required for the proper storage of data.
Control Structures :
Syntax :
Output
: of given number is:
reverse
321
Syntax :
GOTO jump;
....
<<jump>>
1. Implicit cursors
2. Explicit cursors
%ROWCOUNT
It displays the number of rows produced by a SELECT INTO command or affected by DML
operations like INSERT, DELETE, and UPDATE.
• Fetch Data: Retrieve one row at a time from the result set.
• Close the Cursor: Release the resources associated with the cursor.
Disadvantages:
• Slower performance compared to set-based
operations.
• Increases code complexity.
• Declare the Cursor: Use the view in the SELECT query for the cursor declaration.
• Fetch Rows from the Cursor: Retrieve rows one at a time from the cursor .
• Process Each Row: Apply desired logic (e.g., calculations, updates) to the fetched data.
• Close the Cursor: Release resources after completing processing.
1. Simplicity:
⚬ Views can encapsulate complex queries,
making the cursor's logic simpler.
2. Reusability:
⚬ A view can be reused across different queries or
cursors.
3. Data Abstraction:
⚬ Views abstract the underlying table structure,
providing a layer of security and modularity.