InterviewSolution
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.
| 201. |
What Are The Advantages Of Using Packages? |
|
Answer» The MAIN ADVANTAGES of using packages are given as follows:
The main advantages of using packages are given as follows: |
|
| 202. |
When Does A Package Need To Be Recompiled? |
|
Answer» A package needs to be recompiled COMPLETELY whenever any changes are MADE in the package specification. Any CHANGE to the package body does not require recompilation of the package. A package needs to be recompiled completely whenever any changes are made in the package specification. Any change to the package body does not require recompilation of the package. |
|
| 203. |
Suppose A Procedure, A_proc, Is Defined With A Number Parameter As Input Within A Package Called A_package In The A_user Schema. Write The Statement To Invoke The A_proc Procedure On The Sql Prompt From The User,b_user ? |
|
Answer» The STATEMENT is GIVEN as FOLLOWS: The statement is given as follows: |
|
| 204. |
What Is Written As Part Of The Package Specification And The Package Body? |
|
Answer» The package specification consists of the declaration of all the global variables, cursors, types, procedures, and FUNCTIONS that are public and required to be called from within or outside the package. The package body consists of the definition of all the public constructs that are declared within the package specification and the definition of all the PRIVATE variables, cursors, types, procedures, and functions that are required only within the package. FOLLOWING code snippet shows the IMPLEMENTATION of the package specification and the package body: The package specification consists of the declaration of all the global variables, cursors, types, procedures, and functions that are public and required to be called from within or outside the package. The package body consists of the definition of all the public constructs that are declared within the package specification and the definition of all the private variables, cursors, types, procedures, and functions that are required only within the package. Following code snippet shows the implementation of the package specification and the package body: |
|
| 205. |
Is It Possible To Write A Package Specification Without A Package Body? |
|
Answer» Yes, it is possible to write a package specification without a package body but not the vice VERSA. This is specifically USED if there is a package, which is only used for the declaration of PUBLIC variables, types, constants, and exceptions. In such case, there is no NEED for a package body and only package specification is ENOUGH. Yes, it is possible to write a package specification without a package body but not the vice versa. This is specifically used if there is a package, which is only used for the declaration of public variables, types, constants, and exceptions. In such case, there is no need for a package body and only package specification is enough. |
|
| 206. |
What Is The Difference Between Local And Global Variables Within A Package? |
|
Answer» A local VARIABLE is defined within a package body and is only available to the constructs within the same package. A local variable is defined within a package body and is only available to the constructs within the same package. |
|
| 207. |
Can A Complete Package Be Called? |
|
Answer» No, a complete package is not POSSIBLE to CALL, invoke, or PARAMETERIZE; however, any CONSTRUCT from the package can be called or INVOKED. No, a complete package is not possible to call, invoke, or parameterize; however, any construct from the package can be called or invoked. |
|
| 208. |
What Is The Difference Between Private Package Construct And Public Package Construct? |
Answer»
|
|
| 209. |
What Is A Package And How Does It Differ From Procedure And Function? |
|
Answer» A package is a group of logically related PL/SQL SUBPROGRAMS BUNDLED together with PL/SQL types and other associated OBJECTS. It consists of the following two parts:
The whole package is fully loaded into the memory when any package construct is called for the first time. Therefore, it does not require any DISK input/output on later calls to constructs in the same package. A package is a group of logically related PL/SQL subprograms bundled together with PL/SQL types and other associated objects. It consists of the following two parts: The whole package is fully loaded into the memory when any package construct is called for the first time. Therefore, it does not require any disk input/output on later calls to constructs in the same package. |
|
| 210. |
What Are The Advantages Of Using Stored Procedures And Functions? |
|
Answer» Stored procedures are a collection of SQL, PL/SQL, and Java statements that allow a programmer to shift the code from the application side to the database side. This enables the business rules and application logic to be stored as procedures within the database. The main advantages of using stored procedures and functions are as follows:
Stored procedures are a collection of SQL, PL/SQL, and Java statements that allow a programmer to shift the code from the application side to the database side. This enables the business rules and application logic to be stored as procedures within the database. The main advantages of using stored procedures and functions are as follows: |
|
| 211. |
How Can The Parameter List For A Function Or Procedure Be Displayed? |
|
Answer» The PARAMETER list for a FUNCTION or PROCEDURE can be displayed USING the DESCRIBE COMMAND, given as follows: DESCRIBE subprogram_nameThe parameter list for a function or procedure can be displayed using the DESCRIBE command, given as follows: |
|
| 212. |
Write The Syntax For The Show_error Command ? |
|
Answer» The SYNTAX for the SHOW_ERROR COMMAND is as FOLLOWS: The syntax for the SHOW_ERROR command is as follows: |
|
| 213. |
How Can The Text Of A Procedure Or Function Specification Be Viewed? |
|
Answer» The TEXT of a PROCEDURE or function specification can be viewed using the USER_SOURCE DATA DICTIONARY VIEW. The text of a procedure or function specification can be viewed using the USER_SOURCE data dictionary view. |
|
| 214. |
Write The Sql Query To View All The Procedures Within A Schema ? |
|
Answer» SQL QUERY to view all the PROCEDURES WITHIN a SCHEMA is as follows: SQL query to view all the procedures within a schema is as follows: |
|
| 215. |
What Is The Use Of The User_errors Data Dictionary View? |
|
Answer» The USER_ERRORS DATA dictionary VIEW is USED to view the COMPILATION errors of the SUBPROGRAMS. The USER_ERRORS data dictionary view is used to view the compilation errors of the subprograms. |
|
| 216. |
How Can A Compiled Object Code Be Viewed? |
|
Answer» COMPILED object code cannot be VIEWED, as it is not ACCESSIBLE to the user. Compiled object code cannot be viewed, as it is not accessible to the user. |
|
| 217. |
Can A Role Be Used To Define Privileges To Access Database Objects Of Another Schema In Procedures And Functions? |
|
Answer» Database objects of another schema cannot be accessed in a procedure or FUNCTION through roles; however, explicit privileges have to be GRANTED to the USER for those database objects. Database objects of another schema cannot be accessed in a procedure or function through roles; however, explicit privileges have to be granted to the user for those database objects. |
|
| 218. |
What Is The Difference Between Create Or Replace Function And Drop Function Commands? |
|
Answer» The CREATE OR REPLACE FUNCTION command creates the function if it does not exist and replaces it with the NEW VERSION if it already exists. The DROP FUNCTION command deletes the function altogether from the DATABASE. Any PRIVILEGE assigned on the function remains the same when the CREATE OR REPLACE FUNCTION command is used; HOWEVER, in the case of the DROP FUNCTION command, all the privileges are revoked. The CREATE OR REPLACE FUNCTION command creates the function if it does not exist and replaces it with the new version if it already exists. The DROP FUNCTION command deletes the function altogether from the database. Any privilege assigned on the function remains the same when the CREATE OR REPLACE FUNCTION command is used; however, in the case of the DROP FUNCTION command, all the privileges are revoked. |
|
| 219. |
What Restrictions Can Be Applied On Stored Functions, Which Are Called From Sql Statements? |
|
Answer» The main restrictions on stored FUNCTIONS that are CALLED from SQL statements are:
The main restrictions on stored functions that are called from SQL statements are: |
|
| 220. |
Which Datatypes Can Be Used Within Functions That Can Be Invoked In Sql Statements? |
|
Answer» Stored FUNCTIONS can USE VALID SQL datatypes, such as NUMBER, VARCHAR2, and DATE. However, they cannot use PL/SQL datatypes, such as BOOLEAN, RECORD, and TYPE. Stored functions can use valid SQL datatypes, such as NUMBER, VARCHAR2, and DATE. However, they cannot use PL/SQL datatypes, such as BOOLEAN, RECORD, and TYPE. |
|
| 221. |
Can Functions Be Stored Within A Database As Database Objects? |
|
Answer» YES, FUNCTIONS can be STORED as DATABASE OBJECTS in the database. Yes, functions can be stored as database objects in the database. |
|
| 222. |
Can User Defined Functions Be Called Within Sql Statements? If Yes, Then How? |
|
Answer» Yes, USER defined functions can be CALLED in SQL STATEMENTS as shown in the following code: Yes, user defined functions can be called in SQL statements as shown in the following code: |
|
| 223. |
Can A Function Be Defined Without A Return Statement? |
|
Answer» No, a function cannot be DEFINED without a RETURN statement because it has to return a value BACK to the calling environment. In CASE a RETURN statement is not defined, runtime error is RAISED. No, a function cannot be defined without a RETURN statement because it has to return a value back to the calling environment. In case a RETURN statement is not defined, runtime error is raised. |
|
| 224. |
What Are The Different Parameter Modes, Which Can Be Used In The Function Specification? |
|
Answer» The three different modes, IN, OUT, and IN OUT, can be USED in the function SPECIFICATION. HOWEVER, it is recommended to use only the IN MODE. This is because functions are supposed to accept values from the CALLING environment and return a single value. The three different modes, IN, OUT, and IN OUT, can be used in the function specification. However, it is recommended to use only the IN mode. This is because functions are supposed to accept values from the calling environment and return a single value. |
|
| 225. |
Is It Possible To Define A Return Statement In The Exception Part Of A Function? |
|
Answer» YES, it is POSSIBLE to define RETURN statement in the exception SECTION. This RETURN statement would be EXECUTED if an exception is raised and control is passed to the exception section of the code. Yes, it is possible to define RETURN statement in the exception section. This RETURN statement would be executed if an exception is raised and control is passed to the exception section of the code. |
|
| 226. |
Can There Be Multiple Return Statements Within A Function? |
|
Answer» Yes, there can be MULTIPLE RETURN statements within a FUNCTION THOUGH only one is executed. After the value is retuned, the CONTROL passes back to the calling environment and function PROCESSING is stopped. Yes, there can be multiple RETURN statements within a function though only one is executed. After the value is retuned, the control passes back to the calling environment and function processing is stopped. |
|
| 227. |
What Is The Basic Specification For A Function? |
|
Answer» The BASIC SPECIFICATION for a FUNCTION is GIVEN as FOLLOWS: The basic specification for a function is given as follows: |
|
| 228. |
What Happens If An Exception Is Unhandled Within A Procedure? |
|
Answer» If an exception is unhandled within a procedure, the control is PASSED BACK to the calling environment. Any DML STATEMENTS, which were EXECUTED within the procedure, are ROLLED back. If an exception is unhandled within a procedure, the control is passed back to the calling environment. Any DML statements, which were executed within the procedure, are rolled back. |
|
| 229. |
How Can You Reference Remote Tables In Procedures? |
|
Answer» REMOTE TABLES can be referenced within PROCEDURES through SQL STATEMENTS. A remote table can be queried through a database link in the procedure. The following CODE inserts a record in the STUDENT_MARKS table, which is in another schema, using the CONNECT_STUDENT database link: Remote tables can be referenced within procedures through SQL statements. A remote table can be queried through a database link in the procedure. The following code inserts a record in the STUDENT_MARKS table, which is in another schema, using the CONNECT_STUDENT database link: |
|
| 230. |
What Is The Scope Of The Procedure Defined Within A Pl/sql Block? |
|
Answer» The SCOPE of any procedure that is defined within the PL/SQL BLOCK will be limited as it can be CALLED only within the PL/SQL block and not by any other procedure or calling ENVIRONMENT. The scope of any procedure that is defined within the PL/SQL block will be limited as it can be called only within the PL/SQL block and not by any other procedure or calling environment. |
|
| 231. |
Can A Procedure Be Declared And Defined Within A Pl/sql Block? |
|
Answer» YES, any procedure can be DECLARED and defined WITHIN a PL/SQL BLOCK. Yes, any procedure can be declared and defined within a PL/SQL block. |
|
| 232. |
What Are The Different Methods For Passing Parameters To A Procedure? |
|
Answer» There are following three different METHODS to pass values to a procedure:
There are following three different methods to pass values to a procedure: |
|
| 233. |
Can Default Values Be Assigned To In Out Parameters In A Procedure? |
|
Answer» No, DEFAULT VALUES cannot be ASSIGNED to IN OUT PARAMETERS; only IN parameters can be assigned default values. No, default values cannot be assigned to IN OUT parameters; only IN parameters can be assigned default values. |
|
| 234. |
How Can A Parameter Be Initialized In A Procedure? |
|
Answer» The IN OUT parameter mode can be used to initialize a parameter in a procedure, as any VALUE can be INITIALLY assigned to this parameter when the procedure is called from the CALLING ENVIRONMENT. The value of this parameter can be changed during the EXECUTION of the procedure and the result can be returned back to the calling environment from the procedure. The IN OUT parameter mode can be used to initialize a parameter in a procedure, as any value can be initially assigned to this parameter when the procedure is called from the calling environment. The value of this parameter can be changed during the execution of the procedure and the result can be returned back to the calling environment from the procedure. |
|
| 235. |
How Can The Out Parameters Be Viewed On The Execution Of Procedure In The Sql Plus Environment? |
|
Answer» The OUT parameters can be viewed in the SQL PLUS ENVIRONMENT by DECLARING variables for the same, as shown in the following code:
The OUT parameters can be viewed in the SQL PLUS environment by declaring variables for the same, as shown in the following code:
|
|
| 236. |
What Are The Different Parameter Modes, Which Can Be Used In The Procedure Specification? |
|
Answer» There are three parameter modes for a procedure, given as follows:
There are three parameter modes for a procedure, given as follows: |
|
| 237. |
Which Datatypes Can Be Used For Parameters Within A Procedure? |
|
Answer» EXPLICIT datatypes, %TYPE and %ROWTYPE, without size SPECIFICATION can be USED for parameters in a PROCEDURE. Explicit datatypes, %TYPE and %ROWTYPE, without size specification can be used for parameters in a procedure. |
|
| 238. |
What Is The Difference Between Formal And Actual Parameters In A Subprogram Specification? |
|
Answer» FORMAL parameters are variables declared as the parameter list in the subprogram SPECIFICATION.
Formal parameters are variables declared as the parameter list in the subprogram specification.
|
|
| 239. |
Can The Size Of The Parameter Passed To The Procedure Be Restricted In The Procedure Definition? |
|
Answer» No, the SIZE of the PARAMETER passed to the procedure cannot be restricted in the procedure DECLARATION. The datatype for the parameter has to be SPECIFIED only. No, the size of the parameter passed to the procedure cannot be restricted in the procedure declaration. The datatype for the parameter has to be specified only. |
|
| 240. |
What Does The Replace Option Indicates In The Procedure Definition? |
|
Answer» The REPLACE option SPECIFIES that if the PROCEDURE with the same name exists in the DATABASE, it will be DROPPED and RECREATED in the database as a new version. The REPLACE option specifies that if the procedure with the same name exists in the database, it will be dropped and recreated in the database as a new version. |
|
| 241. |
What Is A Procedure? Can It Be Stored In The Database? |
|
Answer» A procedure is a named PL/SQL block (subprogram) that can have more than one parameter as an input from the calling ENVIRONMENT and it may return none, one, or more than one VALUE. A procedure is a named PL/SQL block (subprogram) that can have more than one parameter as an input from the calling environment and it may return none, one, or more than one value. |
|
| 242. |
Give The Basic Block Structure Of A Subprogram ? |
|
Answer» The BLOCK STRUCTURE of a SUBPROGRAM is GIVEN as FOLLOWS: The block structure of a subprogram is given as follows: |
|
| 243. |
What Is The Difference Between The Code Syntax Of An Anonymous Block And Named Subprogram Block? |
|
Answer» A subprogram has TWO parts: subprogram specification and subprogram BODY.
An anonymous block has no specification or header section. It only consists of a PL/SQL block in the body that contains the declaration, executable, and exception sections. A subprogram has two parts: subprogram specification and subprogram body. An anonymous block has no specification or header section. It only consists of a PL/SQL block in the body that contains the declaration, executable, and exception sections. |
|
| 244. |
What Is The Basic Difference Between Procedure And Function? |
|
Answer» A PROCEDURE is executed as a PL/SQL statement. It can accept more than one PARAMETER as an input from the CALLING environment and may return NONE, one, or more than one VALUE. A procedure is executed as a PL/SQL statement. It can accept more than one parameter as an input from the calling environment and may return none, one, or more than one value. |
|
| 245. |
What Are The Two Different Types Of Subprograms In Pl/sql? |
|
Answer» The TWO different types of subprograms in PL/SQL are procedures and FUNCTIONS. Both can be called from an EXTERNAL environment or application. In ADDITION, they can accept parameters. The two different types of subprograms in PL/SQL are procedures and functions. Both can be called from an external environment or application. In addition, they can accept parameters. |
|
| 246. |
What Is A Subprogram? What Are Its Advantages? |
|
Answer» A named Procedural Language/Structured Query Language (PL/SQL) block is CALLED a subprogram. It has three sections: declarative, executable, and exception handling (optional). The main advantage of a subprogram is that it can be compiled and stored in a database. In addition, it has the FOLLOWING advantages:
A named Procedural Language/Structured Query Language (PL/SQL) block is called a subprogram. It has three sections: declarative, executable, and exception handling (optional). The main advantage of a subprogram is that it can be compiled and stored in a database. In addition, it has the following advantages: |
|
| 247. |
Which Column In The User.triggers Data Dictionary View Shows That The Trigger Is A Pl/sql Trigger? |
|
Answer» The ACTION_TYPE COLUMN of the USER_TRIGGERS data DICTIONARY view SHOWS that the trigger is a PL/SQL trigger. The ACTION_TYPE column of the USER_TRIGGERS data dictionary view shows that the trigger is a PL/SQL trigger. |
|
| 248. |
Write The Alter Statement To Enable All The Triggers On The T.students Table ? |
|
Answer» The ALTER STATEMENT is GIVEN as FOLLOWS: ALTER TABLE T_STUDENTS ENABLE ALL TRIGGERS;The ALTER statement is given as follows: |
|
| 249. |
What Are Conditional Predicates? |
|
Answer» Triggers use CONDITIONAL predicates, such as INSERTING, UPDATING, and DELETING, to determine which particular EVENT will cause the trigger to fire. All the THREE predicates have Boolean values and are useful in triggers, such as AFTER INSERT or UPDATE. Triggers use conditional predicates, such as INSERTING, UPDATING, and DELETING, to determine which particular event will cause the trigger to fire. All the three predicates have Boolean values and are useful in triggers, such as AFTER INSERT or UPDATE. |
|
| 250. |
Is It Possible To Include An Insert Statement On The Same Table To Which The Trigger Is Assigned? |
|
Answer» If an INSERT STATEMENT is used on the same table to which the TRIGGER is ASSOCIATED, then this will GIVE RISE to a mutating table, as it is not possible to change the same table that is already in the process of being changed. If an INSERT statement is used on the same table to which the trigger is associated, then this will give rise to a mutating table, as it is not possible to change the same table that is already in the process of being changed. |
|