0% found this document useful (0 votes)
20 views5 pages

Viva Questions and Answers Fixed

The document contains a series of questions and answers related to PL/SQL, Oracle Apex, and SQL/database concepts. It covers topics such as PL/SQL blocks, cursors, exceptions, Oracle Apex features, constraints, and normalization. Additionally, it includes practical examples of PL/SQL blocks and triggers for error handling and logging.

Uploaded by

raguljayam3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

Viva Questions and Answers Fixed

The document contains a series of questions and answers related to PL/SQL, Oracle Apex, and SQL/database concepts. It covers topics such as PL/SQL blocks, cursors, exceptions, Oracle Apex features, constraints, and normalization. Additionally, it includes practical examples of PL/SQL blocks and triggers for error handling and logging.

Uploaded by

raguljayam3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Viva Questions and Answers

PL/SQL Questions

1. What is PL/SQL, and why is it used?

Answer: PL/SQL stands for Procedural Language/Structured Query Language. It extends SQL by

adding procedural constructs such as loops, conditions, and exceptions. It is used for writing

complex business logic, creating stored procedures, functions, and triggers, and improving database

performance by reducing client-server communication.

2. What are the main sections of a PL/SQL block?

Answer:

- DECLARE: Used for defining variables, constants, and cursors.

- BEGIN: Contains the executable statements.

- EXCEPTION: Handles errors during execution.

- END: Marks the end of the block.

3. What are cursors? Explain their types.

Answer: A cursor is a pointer to a result set of a query.

- Implicit Cursor: Automatically created by Oracle for SQL queries (e.g., SELECT INTO).

- Explicit Cursor: Declared and controlled by the programmer to handle multiple rows.

4. What is the difference between a procedure and a function?

Answer:

- A procedure performs an action but doesn't necessarily return a value.

- A function always returns a value and is used for computations.


5. What are exceptions in PL/SQL?

Answer: Exceptions handle runtime errors.

- Predefined Exceptions: System-defined, e.g., NO_DATA_FOUND, ZERO_DIVIDE.

- User-Defined Exceptions: Declared explicitly by the programmer using the EXCEPTION block.

6. Write a PL/SQL block to calculate the factorial of a number.

Answer:

DECLARE

num NUMBER := 5;

factorial NUMBER := 1;

BEGIN

FOR i IN REVERSE 1..num LOOP

factorial := factorial * i;

END LOOP;

DBMS_OUTPUT.PUT_LINE('Factorial: ' || factorial);

END;

Apex Cloud Infrastructure Questions

1. What is Oracle Apex?

Answer: Oracle Application Express (Apex) is a low-code development platform for building web

applications. It allows developers to design, develop, and deploy applications rapidly using a

browser interface.

2. What is an interactive report in Apex? How does it differ from an interactive grid?
Answer:

- An interactive report is used for data analysis and reporting with tools like filters and highlights.

- An interactive grid combines reporting with inline data editing.

3. What are the authentication methods available in Apex?

Answer:

- Database Authentication

- LDAP/SSO Authentication

- Custom Authentication

- Social Sign-In (OAuth2)

4. How does Oracle Apex handle REST APIs?

Answer: Apex integrates with RESTful web services to exchange data with other systems. It

supports both consuming REST APIs and building REST-enabled applications using its REST

workshop.

SQL/Database Questions

1. What are constraints? Explain their types.

Answer: Constraints enforce data integrity rules.

- Primary Key: Ensures uniqueness and non-null values.

- Foreign Key: Links tables to enforce referential integrity.

- Unique: Ensures unique values in a column.

- Check: Validates data based on a condition.

- Not Null: Prevents null values.


2. What is the difference between DROP, DELETE, and TRUNCATE?

Answer:

- DROP: Deletes the table structure and data permanently.

- DELETE: Removes specific rows, and changes can be rolled back.

- TRUNCATE: Removes all rows, faster than DELETE, but cannot be rolled back.

3. What is a sequence? How is it used?

Answer: A sequence generates unique numerical values, often for primary keys.

Example:

CREATE SEQUENCE emp_seq START WITH 1 INCREMENT BY 1;

4. Explain normalization and its importance.

Answer: Normalization organizes data to minimize redundancy and dependency.

- First Normal Form (1NF): Removes duplicate columns.

- Second Normal Form (2NF): Removes partial dependency.

- Third Normal Form (3NF): Removes transitive dependency.

Tips for Practical Questions

1. Write a PL/SQL block to handle a division by zero error.

Answer:

DECLARE

num1 NUMBER := 10;

num2 NUMBER := 0;

result NUMBER;

BEGIN
BEGIN

result := num1 / num2;

EXCEPTION

WHEN ZERO_DIVIDE THEN

DBMS_OUTPUT.PUT_LINE('Division by zero error!');

END;

END;

2. Create a trigger that logs employee insertions.

Answer:

CREATE OR REPLACE TRIGGER log_employee_insert

AFTER INSERT ON employees

FOR EACH ROW

BEGIN

INSERT INTO logs (log_message) VALUES ('New employee added: ' || :NEW.name);

END;

You might also like