Home »
SQL
PL/SQL Multiple-Choice Questions (MCQs)
PL/SQL stands for "Procedural Language Extension of SQL". PL/SQL uses a block-structured syntax. Each of the logical blocks of PL/SQL can be nested into any number of subblocks.
This section contains the PL/SQL MCQs on various topics such as Variables, Constants, Literals, Case, Loop, Continue, Trigger, Cursor, Procedure, etc.
These PL/SQL MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of PL/SQL.
PL/SQL MCQs Index
- PL/SQL Variables MCQs
- PL/SQL Constants, Literals, and If MCQs
- PL/SQL CASE, LOOP, CONTINUE, GOTO MCQs
- PL/SQL Procedure MCQs
- PL/SQL Function MCQs
- PL/SQL Cursor MCQs
- PL/SQL Triggers MCQs
- PL/SQL Exception MCQs
1) PL/SQL Variables MCQs
1. PL/SQL is a –
- Brick Structured Language
- Block Structured Language
- Banner Structured Language
- Build Structured Language
Answer: B) Block Structured Language
Explanation:
PL/SQL is a Block Structured Language.
Discuss this Question
2. What does PL/SQL stand for?
- PL/SQL stands for Procedural Language Extension of SQL
- PL/SQL stands for Primary Language Extension of SQL
- PL/SQL stands for Pattern Language Extension of SQL
- PL/SQL stands for Private Language Extension of SQL
Answer: A) PL/SQL stands for Procedural Language Extension of SQL
Explanation:
PL/SQL stands for Procedural Language Extension of SQL.
Discuss this Question
3. What is TRUE about PL/SQL functionalities?
- Conditions and loops are fundamental elements of procedural languages like PL/SQL.
- Various types and variables can be declared, as can procedures and functions, as well as types and variables of those types.
- Arrays can be used with it as well as handling exceptions (runtime errors).
- All of the above
Answer: D) All of the above
Explanation:
TRUE about PL/SQL functionalities –
- Conditions and loops are fundamental elements of procedural languages like PL/SQL.
- Various types and variables can be declared, as can procedures and functions, as well as types and variables of those types.
- Arrays can be used with it as well as handling exceptions (runtime errors).
Discuss this Question
4. Oracle Database's ____ are inherited in PL/SQL.
- Portability
- Robustness
- Security
- All of the above
Answer: D) All of the above
Explanation:
Oracle Database's portability, robustness and security are inherited in it.
Discuss this Question
5. PL/SQL text is made up of lexical units, which are groups of characters and can be classified as –
- Delimiters
- Identifiers
- Literals
- All of the above
Answer: D) All of the above
Explanation:
PL/SQL text is made up of lexical units, which are groups of characters and can be classified as Delimiters, Identifiers, Literals and Comments.
Discuss this Question
6. A Variable in PL/SQL should not exceed –
- 10
- 20
- 30
- 40
Answer: C) 30
Explanation:
A Variable in PL/SQL should not exceed 30 characters.
Discuss this Question
7. Which of the following is/are TRUE about PL/SQL Variables?
- Variables serve as a means for programmers to temporarily store data during code execution.
- PL/SQL programs benefit from its use.
- There is nothing special about it other than being the name of a storage area.
- All of the above
Answer: D) All of the above
Explanation:
In the case of PL/SQL Variables –
- Variables serve as a means for programmers to temporarily store data during code execution.
- PL/SQL programs benefit from its use.
- There is nothing special about it other than being the name of a storage area.
Discuss this Question
8. PL/SQL Variables are by default –
- Case Sensitive
- Upper Case Sensitive
- Lower Case Sensitive
- Not Case Sensitive
Answer: D) Not Case Sensitive
Explanation:
PL/SQL Variables are by default not case sensitive.
Discuss this Question
9. PL/SQL Variable needs to be declared in the –
- Variable Section
- Declaration Section
- Initialization Section
- None of the above
Answer: B) Declaration Section
Explanation:
PL/SQL Variable needs to be declared in the Declaration Section.
Discuss this Question
10. The correct syntax to declare PL/SQL variable is –
- variable_name [CONSTANT] datatype [NOT NULL] [:= | DEFAULT initial_value]
- datatype [CONSTANT] variable_name [NOT NULL] [:= | DEFAULT initial_value]
- variable_name [CONSTANT] datatype [NULL] [:= | DEFAULT initial_value]
- datatype [CONSTANT] variable_name [NULL] [:= | DEFAULT initial_value]
Answer: A) variable_name [CONSTANT] datatype [NOT NULL] [:= | DEFAULT initial_value]
Explanation:
The correct syntax to declare PL/SQL variable is –
variable_name [CONSTANT] datatype [NOT NULL] [:= | DEFAULT initial_value]
Discuss this Question
11. The term ____ refers to a declaration with a size, scale, or precision limit.
- Constant declaration
- Constrained declaration
- Constant decision
- Constrained decision
Answer: B) Constrained declaration
Explanation:
The term constrained declaration refers to a declaration with a size, scale, or precision limit.
Discuss this Question
12. Which of the following is TRUE about Constrained Declaration?
- An unconstrained declaration requires more memory than a constrained declaration.
- An unconstrained declaration requires less memory than a constrained declaration.
- An unconstrained declaration requires equal memory to a constrained declaration.
- None of the above
Answer: A) An unconstrained declaration requires more memory than a constrained declaration
Explanation:
An unconstrained declaration requires more memory than a constrained declaration.
Discuss this Question
13. What is/are the Naming Rules for the PL/SQL Variables?
- An ASCII letter must be the first letter in the variable name.
- In the case of variables, make sure you use easy to read, easy to understand characters after the first character, such as underscore (_) or dollar sign ($).
- Optionally, the variable can be specified as NOT NULL.
- All of the above
Answer: D) All of the above
Explanation:
The Naming Rules for the PL/SQL Variables states that –
- An ASCII letter must be the first letter in the variable name.
- In the case of variables, make sure you use easy to read, easy to understand characters after the first character, such as underscore (_) or dollar sign ($).
- Optionally, the variable can be specified as NOT NULL.
Discuss this Question
14. In order to initialize a variable with the value other than NULL, it can be done using which method?
- The Assignment Operator
- The DEFAULT Keyword
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
In order to initialize a variable with the value other than NULL, it can be done using the Assignment Operator and the DEFAULT Keyword both.
Discuss this Question
15. What is the name of the two variable scopes in PL/SQL?
- Local & Grind Variable
- Letter & Grind Variable
- Local & Global Variable
- Letter & Global Variable
Answer: C) Local & Global Variable
Explanation:
The two variable scopes in PL/SQL are Local & Global Variables.
Discuss this Question
16. What is the difference between Local & Global Variables?
- Variables in an outer block are defined as local variables since they cannot be accessed from the outside whereas the innermost block declares global variables.
- Variables in an inner block are defined as global variables since they cannot be accessed from the outside whereas the outermost block declares local variables.
- Variables in an outer block are defined as global variables since they can be accessed from the outside and the innermost block also declares global variables.
- Variables in an inner block are defined as local variables since they cannot be accessed from the outside whereas the outermost block declares global variables.
Answer: D) Variables in an inner block are defined as local variables since they cannot be accessed from the outside whereas the outermost block declares global variables.
Explanation:
Variables in an inner block are defined as local variables since they cannot be accessed from the outside whereas the outermost block declares global variables.
Discuss this Question
2) PL/SQL Constants, Literals, and If MCQs
17. ____ are values used in PL/SQL blocks that do not change during execution.
- Variables
- Constants
- Functions
- Cursor
Answer: B) Constants
Explanation:
Constants are values used in PL/SQL blocks that do not change during execution.
Discuss this Question
18. PL/SQL Constant is a/an ____ literal value.
- In-built
- User-defined
- Both a and b
- None of the above
Answer: B) User-defined
Explanation:
PL/SQL Constant is a User-defined literal value.
Discuss this Question
19. Choose the correct syntax to declare a constant.
- constant_name CONSTANT datatype := VALUE;
- datatype CONSTANT constant_name := VALUE;
- constant_name CONST datatype =: VALUE;
- datatype CONSTANT constant_name =: VALUE;
Answer: A) constant_name CONSTANT datatype := VALUE;
Explanation:
The correct syntax to declare a constant is –
constant_name CONSTANT datatype := VALUE;
Discuss this Question
20. What is TRUE about constant_name in PL/SQL Constant?
- Exactly like a variable name, it is a name for a constant.
- A constant word doesn't change its value and is a reserved word.
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
In case of constant_name in PL/SQL Constant –
- Exactly like a variable name, it is a name for a constant.
- A constant word doesn't change its value and is a reserved word.
Discuss this Question
21. A value is assigned to a constant in PL/SQL at the time of –
- Initialization
- Declaration
- Valuation
- Numeralization
Answer: B) Declaration
Explanation:
A value is assigned to a constant in PL/SQL at the time of Declaration.
Discuss this Question
22. ____ are values which do not have an identifier and are numeric, character, string, or boolean.
- Constants
- Literals
- Cursor
- Variables
Answer: B) Literals
Explanation:
Literals are values which do not have an identifier and are numeric, character, string, or Boolean.
Discuss this Question
23. Which is the correct example of the literal of type Boolean.
- NULL
- TRUE
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
NULL, TRUE, etc. Are the examples of the literal of type Boolean.
Discuss this Question
24. Select the correct statement.
- PL/SQL literals are case-sensitive
- PL/SQL literals are not case-sensitive
- PL-SQL Variables are not case-sensitive
- None of the above
Answer: A) PL/SQL literals are case-sensitive
Explanation:
PL/SQL literals are case-sensitive.
Discuss this Question
25. Which of the following is NOT a type of PL/SQL literal?
- Numeric
- String
- Boolean
- Check
Answer: D) Check
Explanation:
Type of PL/SQL literals are Numeric, Character, String, Boolean and Date & Time.
Discuss this Question
26. Which of the following is Numeric literal?
- 1234
- 22
- 0
- All of the above
Answer: D) All of the above
Explanation:
Examples of Numeric literals are 1234, 12.22, 0 etc.
Discuss this Question
27. Which of the following is NOT a Boolean literal?
- TRUE
- FALSE
- HELLO
- NULL
Answer: C) HELLO
Explanation:
HELLO is NOT a Boolean literal. TRUE, FALSE, NULL etc. are Boolean literals.
Discuss this Question
28. Which of the following is a Character literal?
- B
- 4
- %
- All of the above
Answer: D) All of the above
Explanation:
B, 4, % etc. are all Character literals.
Discuss this Question
29. What programming languages features are used in PL/SQL?
- Iterative Statements
- Conditional Statements
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
Programming languages features that are used in PL/SQL are iterative and conditional statements.
Discuss this Question
30. Which of the following is correct syntax of IF statement?
- IF-THEN statement
- IF-THEN-ELSE statement
- IF-THEN-ELSIF statement
- All of the above
Answer: D) All of the above
Explanation:
Explanation: Different Syntax of If statements are –
- IF-THEN statement
- IF-THEN-ELSE statement
- IF-THEN-ELSIF statement
- IF-THEN-ELSIF-ELSE statement
Discuss this Question
31. IF-THEN syntax is used –
- Depending on whether the condition is TRUE or FALSE, you may want to execute one set of statements or another set.
- If the condition is TRUE, then you want statements to be executed
- As long as condition1 is TRUE, then one set of statements will be executed, and when condition2 is TRUE, another set will be executed.
- When condition1 is TRUE, one set of statements will be executed, and when both conditions are FALSE, a different set of statements will be executed.
Answer: B) If the condition is TRUE, then you want statements to be executed
Explanation:
If the condition is TRUE, then you want statements to be executed
Discuss this Question
32. IF-THEN-ELSE syntax is used –
- Depending on whether the condition is TRUE or FALSE, you may want to execute one set of statements or another set.
- If the condition is TRUE, then you want statements to be executed
- As long as condition1 is TRUE, then one set of statements will be executed, and when condition2 is TRUE, another set will be executed.
- When condition1 is TRUE, one set of statements will be executed, and when both conditions are FALSE, a different set of statements will be executed.
Answer: A) Depending on whether the condition is TRUE or FALSE, you may want to execute one set of statements or another set.
Explanation:
Depending on whether the condition is TRUE or FALSE, you may want to execute one set of statements or another set.
Discuss this Question
33. IF-THEN-ELSIF syntax is used –
- Depending on whether the condition is TRUE or FALSE, you may want to execute one set of statements or another set.
- If the condition is TRUE, then you want statements to be executed
- As long as condition1 is TRUE, then one set of statements will be executed, and when condition2 is TRUE, another set will be executed.
- When condition1 is TRUE, one set of statements will be executed, and when both conditions are FALSE, a different set of statements will be executed.
Answer: C) As long as condition1 is TRUE, then one set of statements will be executed, and when condition2 is TRUE, another set will be executed.
Explanation:
As long as condition1 is TRUE, then one set of statements will be executed, and when condition2 is TRUE, another set will be executed.
Discuss this Question
34. ____ executes the corresponding code whenever a TRUE condition is found. Otherwise, the condition cannot be checked again.
- IF-THEN statement
- IF-THEN-ELSE statement
- IF-THEN-ELSIF statement
- IF-THEN-ELSIF-ELSE statement
Answer: B) IF-THEN-ELSE statement
Explanation:
IF-THEN-ELSE executes the corresponding code whenever a TRUE condition is found. Otherwise, the condition cannot be checked again.
Discuss this Question
35. In the absence of a condition, the ELSE part of the ____ statement will be executed.
- IF-THEN-ELSE statement
- IF-THEN-ELSIF statement
- IF-THEN-ELSIF-ELSE statement
- None of the above
Answer: A) IF-THEN-ELSE statement
Explanation:
In the absence of a condition, the ELSE part of the IF-THEN-ELSE statement will be executed.
Discuss this Question
36. Which portion is optional in IF statements?
- IF
- THEN
- ELSE
- None of the above
Answer: C) ELSE
Explanation:
ELSE and ELSIF portions are optional in IF statements.
Discuss this Question
3) PL/SQL CASE, LOOP, CONTINUE, GOTO MCQs
37. CASE statement uses which keyword to work like IF statement?
- INTO
- AS
- WHEN
- IN
Answer: C) WHEN
Explanation:
CASE statement uses WHEN keyword to work like IF statement.
Discuss this Question
38. What are the selectors in case of CASE statement?
- Variable
- Function
- Expression
- All of the above
Answer: D) All of the above
Explanation:
The selectors in case of CASE statement are Variable, Function or Expression.
Discuss this Question
39. Evaluation of CASE statement is done –
- RIGHT to LEFT
- TOP to BOTTOM
- BOTTOM to TOP
- None of the above
Answer: B) TOP to BOTTOM
Explanation:
Evaluation of CASE statement is done TOP to BOTTOM.
Discuss this Question
40. By using PL/SQL ____, you can repeatedly execute one or more statements over and over again.
- Loops
- Cursor
- Variables
- Case
Answer: A) Loops
Explanation:
By using PL/SQL loops, you can repeatedly execute one or more statements over and over again.
Discuss this Question
41. PL/SQL Loops are also known as –
- Iterative Case Statements
- Iterative Control Statements
- Indentation Control Statements
- Indentation Case Statements
Answer: B) Iterative Control Statements
Explanation:
PL/SQL Loops are also known as Iterative Control Statements.
Discuss this Question
42. What is the syntax of PL/SQL Loop?
LOOP
END LOOP;
Sequence of statements;
END LOOP;
LOOP
Sequence of statements;
LOOP
Sequence of statements;
END LOOP;
END LOOP;
Sequence of statements;
LOOP
Answer: C)
LOOP
Sequence of statements;
END LOOP;
Explanation:
Syntax of PL/SQL Loop is –
LOOP
Sequence of statements;
END LOOP;
Discuss this Question
43. How many types of PL/SQL Loops are there?
- 3
- 4
- 5
- 6
Answer: B) 4
Explanation:
There are 4 types of PL/SQL loops.
Discuss this Question
44. Which of the following is correct type of PL/SQL Loop?
- While
- For
- Cursor For
- All of the above
Answer: D) All of the above
Explanation:
Types of PL/SQL Loops are –
- Basic Loop / Exit Loop
- While Loop
- For Loop
- Cursor For Loop
Discuss this Question
45. A/An _______ loop in PL/SQL ensures that at least one statement is executed before the loop terminates.
- While
- For
- Cursor For
- Exit
Answer: D) Exit
Explanation:
An exit loop in PL/SQL ensures that at least one statement is executed before the loop terminates.
Discuss this Question
46. Which of the following is TRUE while using PL/SQL Exit Loop?
- The loop body should be initialized with a variable
- Variables in the loop are incremented.
- When you are ready to exit the loop, you should use the EXIT WHEN statement.
- All of the above
Answer: D) All of the above
Explanation:
While using PL/SQL Exit Loop –
- The loop body should be initialized with a variable
- Variables in the loop are incremented.
- When you are ready to exit the loop, you should use the EXIT WHEN statement.
Discuss this Question
47. The PL/SQL ____ loop runs a series of statements as long as a condition is true, so it can be used in a series of statements.
- While
- Cursor For
- Basic
- For
Answer: A) While
Explanation:
The PL/SQL While loop runs a series of statements as long as a condition is true, so it can be used in a series of statements.
Discuss this Question
48. What is the correct syntax of WHILE Loop?
WHILE <condition>
LOOP statements;
END LOOP;
LOOP statements;
WHILE <condition>
END LOOP;
END LOOP;
WHILE <condition>
LOOP statements;
- None of the above
Answer: A)
WHILE <condition>
LOOP statements;
END LOOP;
Explanation:
The correct syntax of WHILE Loop is –
WHILE <condition>
LOOP statements;
END LOOP;
Discuss this Question
49. When you want to execute a series of statements repeatedly, you use the PL/SQL ____ loop.
- Cursor For
- Cursor
- For
- While
Answer: C) For
Explanation:
When you want to execute a series of statements repeatedly, you use the PL/SQL for loop.
Discuss this Question
50. The counter in PL/SQL FOR Loop is by default incremented by –
- 0
- 1
- 2
- NULL
Answer: B) 1
Explanation:
The counter in PL/SQL FOR Loop is by default incremented by 1.
Discuss this Question
51. Which of the following is TRUE while using PL/SQL FOR Loop?
- The counter variable is implicitly declared in the declaration section, so you do not need to declare it explicitly.
- It is not necessary to explicitly increment the counter variable since it is incremented by 1.
- FOR loops can use EXIT WHEN and EXIT statements, but it isn't often used.
- All of the above
Answer: D) All of the above
Explanation:
While using PL/SQL FOR Loop –
- The counter variable is implicitly declared in the declaration section, so you do not need to declare it explicitly.
- It is not necessary to explicitly increment the counter variable since it is incremented by 1.
- FOR loops can use EXIT WHEN and EXIT statements, but it isn't often used.
Discuss this Question
52. PL/SQL ____ statement initiates the next iteration of a loop, skipping any code in between, by exiting the loop from the reminder in its body either conditionally or unconditionally.
- Condition
- Cursor
- Continue
- Check
Answer: C) Continue
Explanation:
PL/SQL Continue statement initiates the next iteration of a loop, skipping any code in between, by exiting the loop from the reminder in its body either conditionally or unconditionally.
Discuss this Question
53. In which Oracle does the PL/SQL Continue Statement is supported?
- Oracle 8g
- Oracle 9g
- Oracle 10g
- Oracle 11g
Answer: D) Oracle 11g
Explanation:
Oracle 11g supports PL/SQL Continue statement.
Discuss this Question
54. A ____ statement in PL/SQL allows you to jump from this statement to a specific statement label within the same subprogram within a PL/SQL block.
- JUMP
- GOTO
- CONTINUE
- BLINK
Answer: B) GOTO
Explanation:
A GOTO statement in PL/SQL allows you to jump from this statement to a specific statement label within the same subprogram within a PL/SQL block.
Discuss this Question
55. The symbol in which the label_name is encapsulated in PL/SQL GOTO statement is –
- ( )
- { }
- [ ]
- <<>>
Answer: D) <<>>
Explanation:
The symbol in which the label_name is encapsulated in PL/SQL GOTO statement is << >>.
Discuss this Question
56. What is/are the correct restriction(s) on GOTO statement?
- A LOOP statement or sub-block cannot be used as an IF statement, CASE statement, or LOOP statement.
- A CASE statement WHEN clause or an IF statement clause cannot transfer control to another.
- No control can be transferred between outer blocks and sub-blocks.
- All of the above
Answer: D) All of the above
Explanation:
The restrictions on the GOTO statement are –
- A LOOP statement or sub-block cannot be used as an IF statement, CASE statement, or LOOP statement.
- A CASE statement WHEN clause or an IF statement clause cannot transfer control to another.
- No control can be transferred between outer blocks and sub-blocks.
- A subprogram cannot be controlled by a parent program.
- An exception handler cannot take control.
Discuss this Question
4) PL/SQL Procedure MCQs
57. PL/SQL Procedure consists of –
- Header and Footer
- Body and Footer
- Header and Body
- None of the above
Answer: C) Header and Body
Explanation:
PL/SQL Procedure consists of Header and Body.
Discuss this Question
58. What is TRUE about header?
- Parameters and variables are contained in the header of the procedure.
- Similar to a general PL/SQL block, the header contains declarations, executions, and exceptions.
- Both A. and B.
- None of the above
Answer: A) Parameters and variables are contained in the header of the procedure
Explanation:
Parameters and variables are contained in the header of the procedure.
Discuss this Question
59. How much number of ways is there to pass the parameters in procedure?
- 1
- 2
- 3
- 4
Answer: C) 3
Explanation:
There are 3 numbers of ways to pass the parameters in the procedure.
Discuss this Question
60. Which of the following are the pass parameters in procedure?
- IN
- OUT
- INOUT
- All of the above
Answer: D) All of the above
Explanation:
The pass parameters in procedure are –
- IN
- OUT
- INOUT
Discuss this Question
61. Which of the following pass parameters can be referenced by procedure?
- IN, OUT
- OUT, INOUT
- IN, INOUT
- None of the above
Answer: C) IN, INOUT
Explanation:
IN and INOUT pass parameters can be reference by procedure.
Discuss this Question
62. Which of the following cannot be overwritten by procedure?
- IN
- OUT
- INOUT
- None of the above
Answer: A) IN
Explanation:
IN pass parameter cannot be overwritten by procedure.
Discuss this Question
63. Which of the following can be performed in PL/SQL Procedure?
- Create
- Call
- Drop
- All of the above
Answer: D) All of the above
Explanation:
In PL/SQL Procedure, the following functions can be performed –
- Create
- Call
- Drop
Discuss this Question
5) PL/SQL Function MCQs
64. What is the difference between PL/SQL Function and PL/SQL Procedure?
- PL/SQL function may or may not return the value whereas PL/SQL Procedure must have to return the value.
- PL/SQL Procedure may or may not return the value whereas PL/SQL Function must have to return the value.
- PL/SQL Function may or may not return the function whereas PL/SQL Procedure must have to return the function.
- None of the above
Answer: B) PL/SQL Procedure may or may not return the value whereas PL/SQL Function must have to return the value
Explanation:
PL/SQL Procedure may or may not return the value whereas PL/SQL Function must have to return the value.
Discuss this Question
65. Which of the following is NOT present in the syntax of PL/SQL function?
- Function_name
- [OR REPLACE]
- Optional Parameter List
- None of the above
Answer: D) None of the above
Explanation:
Function_name, [OR REPLACE], Optional Parameter List, IN are all present in the syntax of PL/SQL function.
Discuss this Question
66. PL/SQL function must contain a –
- Follow Statement
- GOTO Statement
- Return Statement
- NULL Statement
Answer: C) Return Statement
Explanation:
PL/SQL function must contain a Return Statement.
Discuss this Question
67. AS Keyword is used in the PL/SQL function in order to create a –
- Identity Function
- Quadratic Function
- One to One Function
- Standalone Function
Answer: D) Standalone Function
Explanation:
AS keyword is used in the PL/SQL function in order to create a Standalone Function.
Discuss this Question
68. We can demonstrate which of the following in a PL/SQL function?
- Declare
- Define
- Invoke
- All of the above
Answer: D) All of the above
Explanation:
We can demonstrate Declare, Define and Invoke in PL/SQL function.
Discuss this Question
69. Which of the following is /are TRUE about calling a PL/SQL function?
- You need to define a function's purpose when creating it.
- In order to utilize a function, you must call it in order to accomplish the defined task.
- Calling a function passes the program control to that function.
- All of the above
Answer: D) All of the above
Explanation:
All the below points are TRUE about calling a PL/SQL function –
- You need to define a function's purpose when creating it.
- In order to utilize a function, you must call it in order to accomplish the defined task.
- Calling a function passes the program control to that function.
Discuss this Question
70. The call function returns program control to the ____ after successful completion of the defined task.
- Main Table
- Main Database
- Main Program
- Main Row
Answer: C) Main Program
Explanation:
The call function returns program control to the main program after successful completion of the defined task.
Discuss this Question
71. Calling a function requires that the parameters be provided along with the ____, and if the function returns a value, that value can be stored.
- Function Name
- Optional Parameter List
- IF Statement
- Rollback Statement
Answer: A) Function Name
Explanation:
Calling a function requires that the parameters be provided along with the function name, and if the function returns a value, that value can be stored.
Discuss this Question
72. It is called ____ when the subprogram calls itself and ____ is the process.
- Recursion, Recursive Call
- Recursive Call, Recursion
- Recursive Name, Recursive Call
- Recursive Call, Recursive Name
Answer: B) Recursive Call, Recursion
Explanation:
It is called recursive call when the subprogram calls itself and recursion is the process.
Discuss this Question
73. In order to remove the PL/SQL function, which function is used?
- REMOVE FUNCTION
- DELETE FUNCTION
- ERASE FUNCTION
- DROP FUNCTION
Answer: D) DROP FUNCTION
Explanation:
In order to remove the PL/SQL function, DROP FUNCTION is used.
Discuss this Question
6) PL/SQL Cursor MCQs
74. Oracle creates ____ when SQL statements are processed.
- Content Areas
- Context Areas
- Context Ids
- Content Ids
Answer: B) Context Areas
Explanation:
Oracle creates context areas when SQL statements are processed.
Discuss this Question
75. In the contexts created by Oracle, a cursor represents a ____.
- Function
- Table
- Pointer
- None of the above
Answer: C) Pointer
Explanation:
In the contexts, create by Oracle, a cursor represents a Pointer.
Discuss this Question
76. An SQL ____ refers to a program that retrieves and processes one row at a time, based on the results of the SQL statement.
- Cursor
- Function
- Procedure
- View
Answer: A) Cursor
Explanation:
An SQL cursor refers to a program that retrieves and processes one row at a time, based on the results of the SQL statement.
Discuss this Question
77. How many types of PL/SQL Cursor are there?
- 1
- 2
- 3
- 4
Answer: B) 2
Explanation:
There are 2 types of PL/SQL Cursors.
Discuss this Question
78. Which of the following is/are the type(s) of the PL/SQL Cursor?
- Implicit
- Explicit
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
Implicit and Explicit Cursors are the types of PL/SQL Cursor.
Discuss this Question
79. Which of the following PL/SQL Cursor is automatically generated by Oracle?
- Implicit
- Explicit
- Both a and b
- None of the above
Answer: A) Implicit
Explanation:
Implicit Cursor is automatically generated by Oracle.
Discuss this Question
80. The Implicit cursors are created in order to process the ____ statements.
- DDL
- DCL
- DML
- TCL
Answer: C) DML
Explanation:
The implicit cursors are created in order to process the DML statements such as INSERT, DELETE, UPDATE, etc.
Discuss this Question
81. Which of the following is/are an/the implicit cursor's attribute(s)?
- %FOUND
- %ROWCOUNT
- %ISOPEN
- All of the above
Answer: D) All of the above
Explanation:
%FOUND, %ROWCOUNT, %OPEN and %NOTFOUND are all the implicit cursor's attributes.
Discuss this Question
82. What is TRUE about %FOUND in PL/SQL Cursor?
- If any DML statement, such as INSERT, DELETE or UPDATE, effects one or more rows, or if a SELECT INTO statement returns at least one row, this method returns TRUE.
- A SELECT INTO statement or DML statements like INSERT, DELETE, AND UPDATE do not result in any rows being affected.
- Because SQL cursors are automatically closed after execution of their associated SQL statements, the function always returns FALSE for implicit cursors.
- Results are returned for DML statements such as inserting, deleting, and updating records, or for those returned by a SELECT INTO command.
Answer: A) If any DML statement, such as INSERT, DELETE or UPDATE, effects one or more rows, or if a SELECT INTO statement returns at least one row, this method returns TRUE
Explanation:
In the case of %FOUND, if any DML statement, such as INSERT, DELETE or UPDATE, effects one or more rows, or if a SELECT INTO statement returns at least one row, this method returns TRUE.
Discuss this Question
83. What is TRUE about %ISOPEN in PL/SQL Cursor?
- If any DML statement, such as INSERT, DELETE or UPDATE, effects one or more rows, or if a SELECT INTO statement returns at least one row, this method returns TRUE.
- A SELECT INTO statement or DML statements like INSERT, DELETE, AND UPDATE do not result in any rows being affected.
- Because SQL cursors are automatically closed after execution of their associated SQL statements, the function always returns FALSE for implicit cursors.
- Results are returned for DML statements such as inserting, deleting, and updating records, or for those returned by a SELECT INTO command.
Answer: C) Because SQL cursors are automatically closed after execution of their associated SQL statements, the function always returns FALSE for implicit cursors
Explanation:
In the case of %ISOPEN, Because SQL cursors are automatically closed after execution of their associated SQL statements, the function always returns FALSE for implicit cursors.
Discuss this Question
84. What is TRUE about %ROWCOUNT in PL/SQL Cursor?
- A SELECT INTO statement or DML statements like INSERT, DELETE, AND UPDATE do not result in any rows being affected.
- Results are returned for DML statements such as inserting, deleting, and updating records, or for those returned by a SELECT INTO command.
- Both A. and B.
- None of the above
Answer: B) Results are returned for DML statements such as inserting, deleting, and updating records, or for those returned by a SELECT INTO command
Explanation:
Results are returned for DML statements such as inserting, deleting, and updating records, or for those returned by a SELECT INTO command.
Discuss this Question
85. For ____ control over the context area, programmers can define explicit cursors.
- Greater
- Lesser
- Equal
- None of the above
Answer: A) Greater
Explanation:
For greater control over the context area, programmers can define explicit cursors.
Discuss this Question
86. In the PL/SQL Block, Explicit cursors are defined in ___________ section.
- Initialization
- Declaration
- End
- None of the above
Answer: B) Declaration
Explanation:
In the PL/SQL Block, Explicit cursors are defined in Declaration Section.
Discuss this Question
87. On the ____ statements, the explicit cursors are created which return rows more than one.
- DELETE
- CREATE
- SELECT
- UPDATE
Answer: C) SELECT
Explanation:
On the SELECT statements, the explicit cursors are created which return rows more than one.
Discuss this Question
88. Which of the following is the correct syntax to create the Explicit Cursor?
- IS select_statement cursor_name CURSOR;
- CURSOR select_statement IS cursor_name;
- CURSOR cursor_name select_statement IS;
- CURSOR cursor_name IS select_statement;
Answer: D) CURSOR cursor_name IS select_statement;
Explanation:
CURSOR cursor_name IS select_statement; is the correct syntax to create the Explicit Cursor.
Discuss this Question
89. There are 4 steps to work on Explicit Cursor:
- Declare the cursor to be initialized in memory.
- Allocate memory by opening the cursor.
- Retrieve data by fetching the cursor.
- Release allocated memory by closing the cursor.
Select the correct order of the above 4 steps to work on Explicit Cursor.
- II > III > IV > I
- I > II > IV > III
- I > II > III > IV
- IV > III > II > I
Answer: C) I > II > III > IV
Explanation:
This is the order in which 4 steps will be performed to work on Explicit Cursor:
- Declare the cursor to be initialized in memory.
- Allocate memory by opening the cursor.
- Retrieve data by fetching the cursor.
- Release allocated memory by closing the cursor.
Discuss this Question
90. Which of the following is the correct syntax to declare explicit cursor?
CURSOR IS name
SELECT statement;
CURSOR name is
Statement SELECT;
Name IS CURSOR
SELECT statement;
CURSOR name IS
SELECT statement;
Answer: D)
CURSOR name IS
SELECT statement;
Explanation:
The correct syntax to declare explicit cursor is –
CURSOR name IS
SELECT statement;
Discuss this Question
91. Which of the following is the correct syntax to fetch the cursor?
- FETCH cursor_name INTO variable_list;
- FETCH variable_list INTO cursor_name;
- INTO cursor_name FETCH variable_list;
- INTO variable_list FETCH cursor_name;
Answer: A) FETCH cursor_name INTO variable_list;
Explanation:
FETCH cursor_name INTO variable_list is the correct syntax to fetch the cursor.
Discuss this Question
92. Which clause is used to open the cursor?
- BEGIN
- START
- OPEN
- INITIATE
Answer: C) OPEN
Explanation:
OPEN is the clause used to open the cursor.
Discuss this Question
93. Which clause is used to close the cursor?
- END
- STOP
- FINISH
- CLOSE
Answer: D) CLOSE
Explanation:
CLOSE clause is used to close the cursor.
Discuss this Question
7) PL/SQL Triggers MCQs
94. Whenever a specified event occurs, the ____ is automatically triggered by the Oracle engine.
- Cursor
- Trigger
- Exception
- View
Answer: B) Trigger
Explanation:
Whenever a specified event occurs, the trigger is automatically triggered by the Oracle engine.
Discuss this Question
95. Which of the following is TRUE about PL/SQL Trigger?
- When certain conditions are met, a trigger stored in a database is triggered.
- A trigger is an application that executes or fires automatically when a certain event occurs.
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
The following points are TRUE about PL/SQL Trigger –
- When certain conditions are met, a trigger stored in a database is triggered.
- A trigger is an application that executes or fires automatically when a certain event occurs.
Discuss this Question
96. In which event(s) trigger is executed?
- DDL
- DML
- Database Operation
- All of the above
Answer: D) All of the above
Explanation:
Trigger is executed when -
- DDL occurs
- DML occurs
- Database Operation occurs
Discuss this Question
97. Which of the following is database operation?
- SERVERERROR
- STARTUP
- SHUTDOWN
- All of the above
Answer: D) All of the above
Explanation:
SERVERERROR, STARTUP, SHUTDOWN, LOGON and LOGOFF are all the database operations.
Discuss this Question
98. Which of the following is not an advantage of trigger?
- Various column values are automatically generated by triggers
- Maintains the integrity of referential
- Tables are replicated asynchronously
- Validating transactions and preventing them from being invalid
Answer: C) Tables are replicated asynchronously
Explanation:
Trigger has this advantage of the tables to be replicated synchronously and not asynchronously.
Discuss this Question
99. What does INSERT or UPDATE or DELETE clauses do in Trigger syntax?
- DML Operation is performed
- DDL Operation is performed
- DCL Operation is performed
- TCL Operation is performed
Answer: A) DML Operation is performed
Explanation:
INSERT or UPDATE or DELETE clauses performs the DML Operations in Trigger syntax.
Discuss this Question
100. Which clause(s) is/are used to specify when the trigger will get executed?
- BEFORE
- AFTER
- INSTEAD OF
- All of the above
Answer: D) All of the above
Explanation:
BEFORE or AFTER or INSTEAD OF clauses are used to specify when the trigger will get executed.
Discuss this Question
101. Which clause is used to create trigger on a view?
- BEFORE
- AFTER
- INSTEAD OF
- None of the above
Answer: C) INSTEAD OF
Explanation:
INSTEAD OF clause is used to create trigger on a view.
Discuss this Question
102. What is the difference between OF column_name and ON table_name in trigger syntax?
- OF column_name specifies the column name that is needed to be updated whereas ON table_name specified the table name that is associated with the trigger.
- ON table_name specifies the column name that is needed to be updated whereas OF column_name specified the table name that is associated with the trigger.
- OF table_name specifies the column name that is needed to be updated whereas ON column_name specified the table name that is associated with the trigger.
- ON column_name specifies the column name that is needed to be updated whereas OF table_name specified the table name that is associated with the trigger.
Answer: A) OF column_name specifies the column name that is needed to be updated whereas ON table_name specified the table name that is associated with the trigger.
Explanation:
OF column_name specifies the column name that is needed to be updated whereas ON table_name specified the table name that is associated with the trigger.
Discuss this Question
103. What does FOR EACH ROW clause do in Trigger syntax?
- A row-level trigger is specified, meaning that each row is affected by this trigger
- When the SQL statement is run, the trigger will be executed just once, which is what is called a table-level trigger
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
In the case of FOR EACH ROW –
- A row-level trigger is specified, meaning that each row is affected by this trigger
- When the SQL statement is run, the trigger will be executed just once, which is what is called a table-level trigger
Discuss this Question
104. WHEN condition is valid for which triggers?
- Table Level Triggers
- Row Level Triggers
- Column Level Triggers
- Database Level Triggers
Answer: B) Row Level Triggers
Explanation:
WHEN condition is valid for Row Level Triggers.
Discuss this Question
105. Which of the following statement is TRUE?
- Table-level triggers do not have access to OLD and NEW references. Record-level triggers use OLD and NEW references.
- Record-level triggers do not have access to OLD and NEW references. Table-level triggers use OLD and NEW references.
- Table-level triggers have access to OLD and NEW references.
- Record-level triggers do not use OLD and NEW references.
Answer: A) Table-level triggers do not have access to OLD and NEW references. Record-level triggers use OLD and NEW references.
Explanation:
Table-level triggers do not have access to OLD and NEW references. Record-level triggers use OLD and NEW references.
Discuss this Question
106. Which keyword is used to query the table in the same trigger?
- BEFORE
- AFTER
- SAME
- EXACT
Answer: B) AFTER
Explanation:
AFTER keyword is used to query the table in the same trigger.
Discuss this Question
107. What does REFERENCING OLD AS o NEW AS n clause do in trigger?
- This clause is used to refer the old values for different DML statements.
- This clause is used to refer the new values for different DML statements.
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
REFERENCING OLD AS o NEW AS n clause is used to refer the old and new values for different DML statements.
Discuss this Question
108. Which of the following is an advantage of trigger?
- Imposing authorizations for security
- Keeping track of table access events and logging them
- Auditing
- All of the above
Answer: D) All of the above
Explanation:
The advantages of trigger are –
- Imposing authorizations for security
- Keeping track of table access events and logging them
- Auditing
Discuss this Question
109. Which of the following clause is not present in the syntax of trigger?
- DECLARE
- TRIGGER
- CURSOR
- INSTEAD OF
Answer: C) CURSOR
Explanation:
CURSOR clause is not present in the syntax of trigger.
Discuss this Question
110. Tables, views, schemas, or databases can be defined as ________ for events.
- Procedure
- Views
- Triggers
- Cursors
Answer: C) Triggers
Explanation:
Tables, views, schemas, or databases can be defined as triggers for events.
Discuss this Question
8) PL/SQL Exception MCQs
111. Errors that are encountered during the execution of the program are referred to as ____ in PL/SQL.
- FUNCTION
- CURSOR
- EXCEPTION
- PROCEDURE
Answer: C) EXCEPTION
Explanation:
Errors that are encountered during the execution of the program are referred to as exceptions in PL/SQL.
Discuss this Question
112. How many types of exceptions are there?
- 2
- 3
- 4
- 5
Answer: A) 2
Explanation:
There are 2 types of exceptions.
Discuss this Question
113. Which of the following is/are an/the type(s) of exceptions?
- System-defined
- User-defined
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
System-defined and User-defined exceptions are both the types of exceptions.
Discuss this Question
114. Which command is used in order to raise an exception explicitly?
- RISE
- ROSE
- RAISE
- RINSE
Answer: C) RAISE
Explanation:
With the help of RAISE command, one can easily raise an exception explicitly.
Discuss this Question
115. Which of the following is TRUE about User-defined exceptions?
- Users can explicitly raise an exception by using a RAISE statement
- RAISE_APPLICATION_ERROR can be used to raise a user-defined exception explicitly.
- Both A. and B.
- None of the above
Answer: C) Both A. and B.
Explanation:
Users can explicitly raise an exception by using a RAISE statement or DBMS_STANDARD.RAISE_APPLICATION_ERROR can be used to raise a user-defined exception explicitly.
Discuss this Question
116. What is the syntax of User-defined exceptions?
- DECLARE my-exception EXCEPTION;
- DECLARE EXCEPTION;
- DECLARE my-exception;
- EXCEPTION;
Answer: A) DECLARE my-exception EXCEPTION;
Explanation:
DECLARE my-exception EXCEPTION is the syntax of user-defined exceptions.
Discuss this Question
117. Which of the following clause does not comes in the syntax while raising an exception?
- DECLARE
- WHEN
- CLOSE
- END
Answer: C) CLOSE
Explanation:
CLOSE clause doesn't come in the syntax while raising an exception.
Discuss this Question
118. When SELECT INTO returns no rows, which pre-defined exception is raised?
- ACCESS_INTO_NULL
- NO_DATA_FOUND
- NOT_LOGGED_ON
- VALUE_ERROR
Answer: B) NO_DATA_FOUND
Explanation:
When SELECT INTO returns no rows, NO_DATA_FOUND pre-defined exception is raised.
Discuss this Question
119. When ACCESS_INTO_NULL exception does is raised?
- A unique index column with duplicate values is raised when this error occurs.
- An invalid username or password is used by a program to connect to a database.
- An automatic assignment of a value to a NULL object raises this exception.
- It is raised when more than one row is returned by a SELECT INTO statement.
Answer: C) An automatic assignment of a value to a NULL object raises this exception.
Explanation:
ACCESS_INTO_NULL exception is raised when an automatic assignment of a value to a NULL object raises this exception.
Discuss this Question
120. Which exception is rose when there is no other clause in the "WHEN" clause of a CASE statement, and none of the choices in the "WHEN" clause have been selected?
- INVALID_CURSOR
- DUP_VAL_ON_INDEX
- VALUE_ERROR
- CASE_NOT_FOUND
Answer: D) CASE_NOT_FOUND
Explanation:
CASE_NOT_FOUND exception is rose when there is no other clause in the "WHEN" clause of a CASE statement, and none of the choices in the "WHEN" clause have been selected.
Discuss this Question
121. When COLLECTION_IS_NULL exception is raised?
- A unique index column with duplicate values is raised when this error occurs.
- The exception is thrown when an uninitialized nested table or varray is attempted to be populated with collection methods other than exist, or when an element of an uninitialized nested table or varray is attempted to be assigned values.
- If a select into statement fails to return any rows, it raises this error.
- This error message appears when a number is divided by zero.
Answer: B) The exception is thrown when an uninitialized nested table or varray is attempted to be populated with collection methods other than exist, or when an element of an uninitialized nested table or varray is attempted to be assigned values.
Explanation:
COLLECTION_IS_NULL exception is raised when an uninitialized nested table or varray is attempted to be populated with collection methods other than exist, or when an element of an uninitialized nested table or varray is attempted to be assigned values.
Discuss this Question
122. When DUP_VAL_ON_INDEX exception does is raised?
- A unique index column with duplicate values is raised when this error occurs.
- The error is raised if an attempt is made to close an unopened cursor or perform a cursor operation without permission.
- When character strings are converted to numbers, it is raised if the string did not represent a valid number.
- An invalid username or password is used to log on to the database by a program.
Answer: A) A unique index column with duplicate values is raised when this error occurs.
Explanation:
DUP_VAL_ON_INDEX exception is raised when an attempt is made to close an unopened cursor or perform a cursor operation without permission.
Discuss this Question
123. An exception which occurs when attempting to access a database without connecting to it is –
- PROGRAM_ERROR
- NOT_LOGGED_IN
- NOT_LOGGED_ON
- NULL_LOGGED-ON
Answer: C) NOT_LOGGED_ON
Explanation:
An exception which occurs when attempting to access a database without connecting to it is NOT_LOGGED_ON.
Discuss this Question
124. Which exception is raised when there is an internal problem in PL/SQL?
- VALUE_ERROR
- INTERNAL_ERROR
- PROBLEM_ERROR
- PROGRAM_ERROR
Answer: D) PROGRAM_ERROR
Explanation:
PROGRAM_ERROR is raised when there is an internal problem in PL/SQL.
Discuss this Question
125. When ROWTYPE_MISMATCH exception is raised?
- When a member method is invoked on an object type, but its instance has not been initialized, this exception is raised.
- Error in PL/SQL occurs when memory is exhausted or corrupt.
- Cursors raise this exception when they seek values in variables of incompatible types.
- None of the above
Answer: C) Cursors raise this exception when they seek values in variables of incompatible types.
Explanation:
Cursors raise the exception ROWTYPE_MISMATCH when they seek values in variables of incompatible types.
Discuss this Question
126. When SELF_IS_NULL exception is raised?
- Errors are raised when dividing by zero is attempted.
- When a member method is invoked on an object type, but its instance has not been initialized, this exception is raised.
- Error in PL/SQL occurs when memory is exhausted or corrupt.
- It is raised when more than one row is returned by a SELECT INTO statement.
Answer: B) When a member method is invoked on an object type, but its instance has not been initialized, this exception is raised.
Explanation:
SELF_IS_NULL exception is raised when a member method is invoked on an object type, but its instance has not been initialized, this exception is raised.
Discuss this Question
127. A PL/SQL exception, which occurs when a memory error occurs?
- ZERO-DIVIDE
- VALUE_ERROR
- MEMORY_ERROR
- STORAGE_ERROR
Answer: D) STORAGE_ERROR
Explanation:
A PL /SQL exception, which occurs when a memory error occurs, is STORAGE_ERROR.
Discuss this Question
128. The exception thrown when more than one row is returned from a SELECT INTO statement?
- MORE_THAN_ONE_ROW
- MORE_ROWS
- TOO_MANY_ROWS
- MANY_ROWS
Answer: C) TOO_MANY_ROWS
Explanation:
The exception thrown when more than one row is returned from a SELECT INTO statement is TOO_MANY_ROWS.
Discuss this Question
129. When VALUE_ERROR exception is raised?
- Errors relating to arithmetic, conversion, truncation, or size constraints raise this signal.
- This error message appears when a number is divided by zero.
- Both A. and B.
- None of the above
Answer: A) Errors relating to arithmetic, conversion, truncation, or size constraints raise this signal.
Explanation:
VALUE_ERROR exception is raised when errors relating to arithmetic, conversion, truncation, or size constraints occur.
Discuss this Question
130. When ZERO_DIVIDE exception is raised?
- This error message appears when a number is multiplied by zero.
- This error message appears when a number is divided by zero.
- This error message appears when a number is integrated by zero.
- This error message appears when a number is zero.
Answer: B) This error message appears when a number is divided by zero.
Explanation:
This error message appears when a number is divided by zero.
Discuss this Question