Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

501.

Can You Use A Commit Statement Within A Database Trigger?

Answer»

No.

No.

502.

What Is The Difference Between No Data Found And %notfound?

Answer»

NO DATA FOUND is an exception raised only for the SELECT....INTO statements when the where clause of the querydoes not match any rows. When the where clause of the EXPLICIT CURSOR does not match any rows the %NOTFOUND ATTRIBUTE is SET to TRUE instead.

NO DATA FOUND is an exception raised only for the SELECT....INTO statements when the where clause of the querydoes not match any rows. When the where clause of the explicit cursor does not match any rows the %NOTFOUND attribute is set to TRUE instead.

503.

Can Cursor Variables Be Stored In Pl/sql Tables. If Yes How. If Not Why?

Answer»

No, a CURSOR VARIABLE POINTS a ROW which cannot be STORED in a two-dimensional PL/SQL table.

No, a cursor variable points a row which cannot be stored in a two-dimensional PL/SQL table.

504.

What Are Various Constraints Used In Sql?

Answer»

505.

Display Odd/ Even Number Of Records?

Answer»

Odd number of RECORDS:
SELECT * from EMP where (rowid,1) in (select rowid, mod(rownum,2) from emp);
Output:-
1
3
5
Even number of records:
select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
Output:-
2
4
6

Odd number of records:
select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
Output:-
1
3
5
Even number of records:
select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
Output:-
2
4
6

506.

How You Open And Close A Cursor Variable. Why It Is Required?

Answer»

OPEN CURSOR variable FOR SELECT...Statement
CLOSE cursor variable In order to associate a cursor variable with a PARTICULAR SELECT statement OPEN SYNTAX is used. In order to FREE the resources used for the query CLOSE statement is used.

OPEN cursor variable FOR SELECT...Statement
CLOSE cursor variable In order to associate a cursor variable with a particular SELECT statement OPEN syntax is used. In order to free the resources used for the query CLOSE statement is used.

507.

What Is The Purpose Of A Cluster?

Answer»

Oracle does not ALLOW a USER to specifically locate tables, since that is a part of the function of the RDBMS. HOWEVER, for the purpose of increasing performance, oracle allows a developer to create a CLUSTER. A CLUSTER provides a means for storing data from different tables together for FASTER retrieval than if the table PLACEMENT were left to the RDBMS.

Oracle does not allow a user to specifically locate tables, since that is a part of the function of the RDBMS. However, for the purpose of increasing performance, oracle allows a developer to create a CLUSTER. A CLUSTER provides a means for storing data from different tables together for faster retrieval than if the table placement were left to the RDBMS.

508.

What Is A Cursor?

Answer»

Oracle uses work area to execute SQL statements and STORE processing INFORMATION PL/SQL construct called a CURSOR lets you name a work area and access its stored information A cursor is a mechanism used to fetch more than ONE row in a Pl/SQl block.

Oracle uses work area to execute SQL statements and store processing information PL/SQL construct called a cursor lets you name a work area and access its stored information A cursor is a mechanism used to fetch more than one row in a Pl/SQl block.

509.

What Is The Difference Between An Implicit & An Explicit Cursor?

Answer»

only one row. However,queries that return more than one row you must declare an explicit cursor or use a cursor FOR loop. Explicit cursor is a cursor in which the cursor name is explicitly assigned to a SELECT statement via the CURSOR...IS statement. An IMPLICIT cursor is USED for all SQL STATEMENTS Declare, Open, Fetch, Close. An explicit cursors are used to process multirow SELECT statements An implicit cursor is used to process INSERT, UPDATE, DELETE and single row SELECT. .INTO statements.

only one row. However,queries that return more than one row you must declare an explicit cursor or use a cursor FOR loop. Explicit cursor is a cursor in which the cursor name is explicitly assigned to a SELECT statement via the CURSOR...IS statement. An implicit cursor is used for all SQL statements Declare, Open, Fetch, Close. An explicit cursors are used to process multirow SELECT statements An implicit cursor is used to process INSERT, UPDATE, DELETE and single row SELECT. .INTO statements.

510.

Display The Records Between Two Range?

Answer»

select rownum, empno, ENAME from emp where ROWID in (select rowid from emp where rownum <=&AMP;upto minus select rowid from emp where rownum<&Start);

select rownum, empno, ename from emp where rowid in (select rowid from emp where rownum <=&upto minus select rowid from emp where rownum<&Start);

511.

What A Select For Update Cursor Represent?

Answer»

SELECT......FROM......FOR......UPDATE[OF column-reference][NOWAIT].

The processing done in a fetch loop modifies the rows that have been retrieved by the cursor. A convenient way of modifying the rows is done by a METHOD with TWO PARTS: the FOR UPDATE clause in the cursor declaration, WHERE CURRENT OF CLAUSE in an UPDATE or declaration statement.

SELECT......FROM......FOR......UPDATE[OF column-reference][NOWAIT].

The processing done in a fetch loop modifies the rows that have been retrieved by the cursor. A convenient way of modifying the rows is done by a method with two parts: the FOR UPDATE clause in the cursor declaration, WHERE CURRENT OF CLAUSE in an UPDATE or declaration statement.

512.

What Are Various Joins Used While Writing Subqueries?

Answer»
  • Self JOIN-Its a join foreign key of a table references the same table.
  • Outer Join--Its a join condition USED where One can query all the rows of one of the tables in the join condition even though they don't SATISFY the join condition.
  • Equi-join-Its a join condition that retrieves rows from one or more tables in which one or more COLUMNS in one table are EQUAL to one or more columns in the second table.

513.

What Is Difference Between Sql And Sql*plus?

Answer»

SQL*PLUS is a command line tool where as SQL and PL/SQL LANGUAGE interface and reporting tool. Its a command line tool that allows user to type SQL commands to be executed directly against an ORACLE database. SQL is a language used to QUERY the relational database(DML,DCL,DDL). SQL*PLUS commands are used to format query result, Set options, EDIT SQL commands and PL/SQL.

SQL*PLUS is a command line tool where as SQL and PL/SQL language interface and reporting tool. Its a command line tool that allows user to type SQL commands to be executed directly against an Oracle database. SQL is a language used to query the relational database(DML,DCL,DDL). SQL*PLUS commands are used to format query result, Set options, Edit SQL commands and PL/SQL.

514.

What Is Difference Between Substr And Instr?

Answer»

SUBSTR RETURNS a SPECIFIED portion of a string eg SUBSTR('BCDEF',4) output BCDE INSTR provides character position in which a pattern is found in a string. eg INSTR('ABC-DC-F','-',2) output 7 (2nd occurence of '-')

SUBSTR returns a specified portion of a string eg SUBSTR('BCDEF',4) output BCDE INSTR provides character position in which a pattern is found in a string. eg INSTR('ABC-DC-F','-',2) output 7 (2nd occurence of '-')

515.

What Should Be The Return Type For A Cursor Variable. Can We Use A Scalar Data Type As Return Type?

Answer»

The return TYPE for a CURSOR MUST be a record type.It can be declared explicitly as a user-defined or %ROWTYPE can be USED. eg TYPE t_studentsref IS REF CURSOR RETURN students%ROWTYPE.

The return type for a cursor must be a record type.It can be declared explicitly as a user-defined or %ROWTYPE can be used. eg TYPE t_studentsref IS REF CURSOR RETURN students%ROWTYPE.

516.

What Is Difference Between A Formal And An Actual Parameter?

Answer»

The variables declared in the PROCEDURE and which are passed, as arguments are called actual, the parameters in the procedure declaration. Actual parameters contain the VALUES that are passed to a procedure and receive RESULTS. Formal parameters are the PLACEHOLDERS for the values of actual parameters.

The variables declared in the procedure and which are passed, as arguments are called actual, the parameters in the procedure declaration. Actual parameters contain the values that are passed to a procedure and receive results. Formal parameters are the placeholders for the values of actual parameters.

517.

What Are Oracle Precompilers?

Answer»

Using ORACLE PRECOMPILERS, SQL statements and PL/SQL blocks can be CONTAINED inside 3GL programs written in C,C++,COBOL,PASCAL, FORTRAN,PL/1 AND ADA. The Precompilers are known as Pro*C,Pro*Cobol,... This form of PL/SQL is known as embedded pl/sql,the language in which pl/sql is embedded is known as the host language. The prcompiler translates the embedded SQL and pl/sql statements into calls to the precompiler runtime library. The output must be compiled and linked with this library to CREATOR an EXECUTABLE.

Using ORACLE PRECOMPILERS, SQL statements and PL/SQL blocks can be contained inside 3GL programs written in C,C++,COBOL,PASCAL, FORTRAN,PL/1 AND ADA. The Precompilers are known as Pro*C,Pro*Cobol,... This form of PL/SQL is known as embedded pl/sql,the language in which pl/sql is embedded is known as the host language. The prcompiler translates the embedded SQL and pl/sql statements into calls to the precompiler runtime library. The output must be compiled and linked with this library to creator an executable.

518.

What Is An Utl_file.what Are Different Procedures And Functions Associated With It?

Answer»

UTL_FILE is a PACKAGE that adds the ability to read and write to operating system FILES. PROCEDURES ASSOCIATED with it are FCLOSE, FCLOSE_ALL and 5 procedures to output data to a file PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH.PUT, FFLUSH.PUT_LINE,FFLUSH.NEW_LINE. Functions associated with it are FOPEN, ISOPEN.

UTL_FILE is a package that adds the ability to read and write to operating system files. Procedures associated with it are FCLOSE, FCLOSE_ALL and 5 procedures to output data to a file PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH.PUT, FFLUSH.PUT_LINE,FFLUSH.NEW_LINE. Functions associated with it are FOPEN, ISOPEN.

519.

Can A Primary Key Contain More Than One Columns?

Answer»

Yes.

Yes.

520.

Can The Default Values Be Assigned To Actual Parameters?

Answer»

Yes.

Yes.

521.

What Is Database Trigger ?

Answer»

A Database Trigger is procedure (SET of SQL and PL/SQL STATEMENTS) that is automatically EXECUTED as a result of an insert in, update to, or delete from a table.

A Database Trigger is procedure (set of SQL and PL/SQL statements) that is automatically executed as a result of an insert in, update to, or delete from a table.

522.

What Is Difference Between Procedures And Functions ?

Answer»

A FUNCTION RETURNS a VALUE to the CALLER where as a PROCEDURE does not.

A Function returns a value to the caller where as a Procedure does not.

523.

What Is A Package ?

Answer»

A Package is a collection of related PROCEDURES, functions, VARIABLES and other package CONSTRUCTS together as a unit in the DATABASE.

A Package is a collection of related procedures, functions, variables and other package constructs together as a unit in the database.

524.

What Is A Procedure ?

Answer»

A PROCEDURE CONSIST of a set of SQL and PL/SQL statements that are GROUPED together as a unit to solve a SPECIFIC problem or perform a set of RELATED tasks.

A Procedure consist of a set of SQL and PL/SQL statements that are grouped together as a unit to solve a specific problem or perform a set of related tasks.

525.

What Are The Uses Of Database Trigger ?

Answer»

Database triggers can be USED to automatic data generation, audit data modifications, ENFORCE COMPLEX Integrity CONSTRAINTS, and customize complex security authorizations.

Database triggers can be used to automatic data generation, audit data modifications, enforce complex Integrity constraints, and customize complex security authorizations.

526.

What Are The Advantages Of Having A Package ?

Answer»

Increased FUNCTIONALITY (for example,global package VARIABLES can be DECLARED and USED by any proecdure in the package) and performance (for example all objects of the package are parsed compiled, and LOADED into memory once).

Increased functionality (for example,global package variables can be declared and used by any proecdure in the package) and performance (for example all objects of the package are parsed compiled, and loaded into memory once).

527.

What Are The Different Types Of Pl/sql Program Units That Can Be Defined And Stored In Oracle Database ?

Answer»

PROCEDURES and FUNCTIONS,PACKAGES and DATABASE TRIGGERS.

Procedures and Functions,Packages and Database Triggers.

528.

What Are % Type And % Rowtype ? What Are The Advantages Of Using These Over Datatypes?

Answer»

% TYPE provides the DATA type of a variable or a database column to that variable.
% ROWTYPE provides the RECORD type that REPRESENTS a entire row of a table or view or columns SELECTED in the cursor.

The ADVANTAGES are :

  • Need not know about variable's data type
  • If the database definition of a column in a table changes, the data type of a variable changes accordingly.

% TYPE provides the data type of a variable or a database column to that variable.
% ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.

The advantages are :

529.

What Are The Cursor Attributes Used In Pl/sql ?

Answer»
  • %ISOPEN - to CHECK whether cursor is OPEN or not.
  • % ROWCOUNT - number of rows fetched/updated/deleted.
  • % FOUND - to check whether cursor has fetched any row. TRUE if rows are fetched.
  • % NOT FOUND - to check whether cursor has fetched any row. True if no rows are featched.

These attributes are proceeded with SQL for Implicit CURSORS and with Cursor name for EXPLICIT Cursors.

These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for Explicit Cursors.

530.

What Is Difference Between A Cursor Declared In A Procedure And Cursor Declared In A Package Specification ?

Answer»

A CURSOR DECLARED in a package specification is global and can be accessed by other PROCEDURES or procedures in a package.

A cursor declared in a PROCEDURE is LOCAL to the procedure that can not be accessed by other procedures.

A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.

A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.

531.

What Is Difference Between A Procedure &amp; Function ?

Answer»

A FUNCTION is always returns a VALUE using the return statement.

A PROCEDURE MAY return ONE or more VALUES through parameters or may not return at all.

A FUNCTION is always returns a value using the return statement.

A PROCEDURE may return one or more values through parameters or may not return at all.

532.

What Is A Stored Procedure ?

Answer»

A stored procedure is a sequence of STATEMENTS that PERFORM specific FUNCTION.

A stored procedure is a sequence of statements that perform specific function.

533.

How Packaged Procedures And Functions Are Called From The Following? A. Stored Procedure Or Anonymous Block B. An Application Program Such A Prc *c, Pro* Cobol C. Sql *plus??

Answer»

a. PACKAGE NAME.PROCEDURE NAME (parameters);
variable := PACKAGE NAME.FUNCTION NAME (arguments);
EXEC SQL EXECUTE
b.BEGIN
PACKAGE NAME.PROCEDURE NAME (parameters)
variable := PACKAGE NAME.FUNCTION NAME (arguments);
END;
END EXEC;
C. EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any out/in-out parameters. A function can not be called.


a. PACKAGE NAME.PROCEDURE NAME (parameters);
variable := PACKAGE NAME.FUNCTION NAME (arguments);
EXEC SQL EXECUTE
b.BEGIN
PACKAGE NAME.PROCEDURE NAME (parameters)
variable := PACKAGE NAME.FUNCTION NAME (arguments);
END;
END EXEC;
c. EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any out/in-out parameters. A function can not be called.


534.

What Will Happen After Commit Statement ?

Answer»

Answer : Cursor C1 is
Select EMPNO,
ename from emp;
Begin
open C1; loop
Fetch C1 into
eno.ename;
EXIT When
C1 %notfound;
commit;
end loop;
end;

The cursor having QUERY as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
The cursor having query as SELECT.... does not GET closed EVEN after COMMIT/ROLLBACK.

 

The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.

 

535.

What Is A Cursor For Loop ?

Answer»

Cursor for loop implicitly DECLARES %ROWTYPE as loop INDEX, OPENS a cursor, fetches ROWS of values from active set into fields in the record and closes when all the records have been processed.
e.g.. FOR emp_rec IN C1 LOOP
salary_total := salary_total +emp_rec sal;
END LOOP;

Cursor for loop implicitly declares %ROWTYPE as loop index, opens a cursor, fetches rows of values from active set into fields in the record and closes when all the records have been processed.
e.g.. FOR emp_rec IN C1 LOOP
salary_total := salary_total +emp_rec sal;
END LOOP;

536.

What Is A Cursor ? Why Cursor Is Required ?

Answer»

Cursor is a named private SQL AREA from where information can be accessed. Cursors are REQUIRED to PROCESS rows individually for queries returning MULTIPLE rows.

Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows.

537.

What Is A Database Trigger ? Name Some Usages Of Database Trigger ?

Answer»

Database trigger is stored PL/SQL program unit ASSOCIATED with a specific database table. Usages are AUDIT data modifications, Log events transparently, ENFORCE complex business RULES Derive column values automatically, Implement complex security AUTHORIZATIONS. Maintain replicate tables.

Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modifications, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.

538.

What Are The Components Of A Pl/sql Block ?

Answer»

PL/SQL BLOCK CONTAIN

  • DECLARATION Section,
  • Executable Section,
  • Exception Handling Section.

i.e

PL/SQL Block Contain

i.e

539.

What Are The Pl/sql Statements Used In Cursor Processing ?

Answer»

DECLARE CURSOR name, OPEN cursor name, FETCH cursor name INTO or Record TYPES, CLOSE cursor name.

DECLARE CURSOR name, OPEN cursor name, FETCH cursor name INTO or Record types, CLOSE cursor name.

540.

What Is An Exception ? What Are Types Of Exception ?

Answer»

Exception is the ERROR handling PART of PL/SQL BLOCK. The types are Predefined and USER defined. Some of Predefined exceptions are.

  • CURSOR_ALREADY_OPEN
  • DUP_VAL_ON_INDEX
  • NO_DATA_FOUND
  • TOO_MANY_ROWS
  • INVALID_CURSOR
  • INVALID_NUMBER
  • LOGON_DENIED
  • NOT_LOGGED_ON
  • PROGRAM-ERROR
  • STORAGE_ERROR
  • TIMEOUT_ON_RESOURCE
  • VALUE_ERROR
  • ZERO_DIVIDE
  • OTHERS.

Exception is the error handling part of PL/SQL block. The types are Predefined and user defined. Some of Predefined exceptions are.

541.

What Are Advantages Fo Stored Procedures?

Answer»

EXTENSIBILITY,MODULARITY, Reusability, MAINTAINABILITY and ONE time compilation.

Extensibility,Modularity, Reusability, Maintainability and one time compilation.

542.

Explain How Procedures And Functions Are Called In A Pl/sql Block ?

Answer»

FUNCTION is called as PART of an EXPRESSION.
SAL := calculate_sal ('a822');
procedure is called as a PL/SQL STATEMENT
calculate_bonus ('A822');

Function is called as part of an expression.
sal := calculate_sal ('a822');
procedure is called as a PL/SQL statement
calculate_bonus ('A822');

543.

Give The Structure Of The Function ?

Answer»

ANSWER : FUNCTION name (argument LIST .....) RETURN DATATYPE is
local variable declarations
Begin
executable statements
Exception
execution handlers
End;

544.

Where The Pre_defined_exceptions Are Stored ?

Answer»

In the STANDARD package.
PROCEDURES, FUNCTIONS & Packages ;

In the standard package.
Procedures, Functions & Packages ;

545.

What Are The Modes Of Parameters That Can Be Passed To A Procedure ?

Answer»

IN,OUT,IN-OUT PARAMETERS.

IN,OUT,IN-OUT parameters.

546.

Is It Possible To Use Transaction Control Statements Such A Rollback Or Commit In Database Trigger?why ?

Answer»

It is not possible. As triggers are defined for each table, if you USE COMMIT of ROLLBACK in a TRIGGER, it affects LOGICAL TRANSACTION processing.

It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a trigger, it affects logical transaction processing.

547.

What Happens If A Procedure That Updates A Column Of Table X Is Called In A Database Trigger Of The Same Table ?

Answer»

MUTATION of table OCCURS.

Mutation of table occurs.

548.

What Are The Components Of Oem?

Answer»

Oracle Enterprise Manager (OEM) has the following components:

  • Management Server (OMS): MIDDLE tier server that handles communication with the intelligent agents. The OEM Console connects to the management server to monitor and configure the Oracle enterprise.
  • Console: This is a graphical interface from where one can schedule JOBS, events, and monitor the database. The console can be opened from a Windows workstation, Unix XTerm (oemapp command) or Web BROWSER session (oem_webstage).
  • Intelligent Agent (OIA): The OIA runs on the target database and takes care of the execution of jobs and events SCHEDULED through the Console.

Oracle Enterprise Manager (OEM) has the following components:

549.

What Is Pl/sql ?

Answer»

PL/SQL is a PROCEDURAL language that has both INTERACTIVE SQL and procedural programming language CONSTRUCTS such as ITERATION, CONDITIONAL branching.

PL/SQL is a procedural language that has both interactive SQL and procedural programming language constructs such as iteration, conditional branching.

550.

What Is Oem (oracle Enterprise Manager)?

Answer»

OEM is a set of systems MANAGEMENT tools PROVIDED by Oracle Corporation for MANAGING the Oracle environment. It provides tools to monitor the Oracle environment and automate tasks (both one-time and repetitive in nature) to TAKE database administration a STEP closer to "Lights Out" management.

OEM is a set of systems management tools provided by Oracle Corporation for managing the Oracle environment. It provides tools to monitor the Oracle environment and automate tasks (both one-time and repetitive in nature) to take database administration a step closer to "Lights Out" management.