0% found this document useful (0 votes)
17 views3 pages

Hexaware PLSQL Interview Questions

The document provides a comprehensive overview of PL/SQL interview questions and answers, covering topics such as cursors, triggers, packages, and materialized views. It explains the differences between primary keys and unique keys, procedures and functions, and discusses the use of bind variables and dynamic SQL. Additionally, it highlights key features of Oracle 10g and includes examples for better understanding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Hexaware PLSQL Interview Questions

The document provides a comprehensive overview of PL/SQL interview questions and answers, covering topics such as cursors, triggers, packages, and materialized views. It explains the differences between primary keys and unique keys, procedures and functions, and discusses the use of bind variables and dynamic SQL. Additionally, it highlights key features of Oracle 10g and includes examples for better understanding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Hexaware PL/SQL Interview Questions -

Detailed Answers
What is a cursor?
A cursor is a database object used to retrieve, manipulate, and navigate through a result set
row-by-row. It provides control over the context area in memory where SQL statements are
processed.

What is implicit and explicit cursor and examples?


Implicit Cursor: Automatically created by Oracle for single-row SQL statements such as
INSERT, UPDATE, DELETE, and SELECT INTO.
Example:
SELECT salary INTO v_sal FROM emp WHERE empno = 101;

Explicit Cursor: Manually declared and controlled by the programmer, used for queries that
return multiple rows.
Example:
CURSOR c1 IS SELECT empno, ename FROM emp;

Ref cursor and types


A Ref Cursor is a PL/SQL data type that acts as a pointer to a result set. It can be passed as a
parameter and is useful for dynamic queries.
- Strong Ref Cursor: Tied to a specific return type.
- Weak Ref Cursor: No specific return type, allowing greater flexibility.

What is exception and exception types


An exception is an error condition during program execution. Types:
- Predefined exceptions: Already defined by Oracle, e.g., NO_DATA_FOUND,
TOO_MANY_ROWS.
- User-defined exceptions: Declared explicitly by the programmer in the DECLARE section.

Two types of triggers


- Row-level Trigger: Executes once for each affected row.
- Statement-level Trigger: Executes once for the triggering SQL statement regardless of the
number of rows affected.

What is package?
A package is a schema object that groups logically related PL/SQL types, variables,
procedures, and functions. It provides modularity and helps in hiding implementation
details.
10g features
- Automatic Storage Management (ASM)
- Flashback Query and Flashback Table
- AWR (Automatic Workload Repository) and ADDM (Automatic Database Diagnostic
Monitor)
- Data Pump Export/Import utilities
- SQL Tuning Advisor and improved optimizer

Difference between primary key and unique key


- Primary Key: Ensures entity integrity. Not null and unique. Only one per table.
- Unique Key: Enforces uniqueness but allows one NULL value. Multiple unique keys
allowed in a table.

Difference between procedure and function


- Procedure: Performs an action, may or may not return a value.
- Function: Must return a single value. Can be used in SQL expressions.

What is bind variable


Bind variables are placeholders in SQL statements used to pass values at runtime. They
improve performance and prevent SQL injection.
Example: EXECUTE IMMEDIATE 'SELECT * FROM emp WHERE empno = :1' USING
v_empno;

How to create a table using procedure and how to pass variables for table
Use dynamic SQL with EXECUTE IMMEDIATE inside a procedure to create tables
dynamically.
Example:
EXECUTE IMMEDIATE 'CREATE TABLE ' || v_table_name || '(id NUMBER, name
VARCHAR2(50))';

What is the use of execute immediate command


The EXECUTE IMMEDIATE command allows the execution of dynamic SQL statements
(DDL, DML, or queries) within PL/SQL blocks.

What is materialized view?


A materialized view stores the result of a query physically in the database. It can be
refreshed periodically and is used to improve query performance.

Any restriction to create a materialized view


- Base tables should have primary keys for fast refresh.
- Complex joins, subqueries, and non-deterministic functions can restrict fast refresh.
- Base tables should reside in the same database for local refresh.
What is fast refresh on commit?
It allows the materialized view to automatically refresh its data whenever a change is
committed to the base tables.

What is integrity constraint


Integrity constraints are rules that ensure data accuracy and consistency in a database.
Types: PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, NOT NULL

What is index by array


Also known as associative arrays, these are PL/SQL collections indexed by PLS_INTEGER or
VARCHAR2.
Example:
TYPE emp_tab IS TABLE OF emp%ROWTYPE INDEX BY PLS_INTEGER;

What is difference between group function and analytic function?


- Group Functions: Aggregate data and return one result for a group (e.g., SUM, AVG).
- Analytic Functions: Perform calculations on a set of rows and return a value for each row
(e.g., RANK(), ROW_NUMBER()).

What is ls command with different options?


The 'ls' command lists directory contents in Unix/Linux.
- ls -l : Detailed list with permissions
- ls -a : Includes hidden files
- ls -lh : Human-readable file sizes
- ls -R : Recursive listing
- ls -lt : Sort by modification time

You might also like