PLSQL Multiple Choice Questions :-
1. Which of the following statements is true about implicit cursors?
A. Implicit cursors are used for SQL statements that are not nameD.
B. Developers should use implicit cursors with great carE.
C. Implicit cursors are used in cursor for loops to handle data processing.
D. Implicit cursors are no longer a feature in OraclE.
Answer: A
2. Which of the following is not a feature of a cursor FOR loop?
A. Record type declaration.
B. Opening and parsing of SQL statements.
C. Fetches records from cursor.
D. Requires exit condition to be defineD.
Answer: B
3. A developer would like to use referential datatype declaration on a variablE. The variable name is EMPLOYEE_LASTNAME, and the corresponding table and column is EMPLOYEE, and LNAME, respectively. How would the developer define this variable using referential datatypes?
A. Use employeE.lname%typE.
B. Use employeE.lname%rowtypE.
C. Look up datatype for EMPLOYEE column on LASTNAME table and use that.
D. Declare it to be type LONG.
Answer: A
4. Which three of the following are implicit cursor attributes?
A. %found
B. %too_many_rows
C. %notfound
D. %rowcount
E. %rowtype
Answer: C
5. If left out, which of the following would cause an infinite loop to occur in a simple loop?
A. LOOP
B. END LOOP
C. IF-THEN
D. EXIT
Answer: B
6. Which line in the following statement will produce an error?
A. cursor action_cursor is
B. select name, rate, action
C. into action_record
D. from action_table;
E. There are no errors in this statement.
Answer: C
7. The command used to open a CURSOR FOR loop is
A. open
B. fetch
C. parse
D. None, cursor for loops handle cursor opening implicitly.
Answer: D
8. What happens when rows are found using a FETCH statement
A. It causes the cursor to close
B. It causes the cursor to open
C. It loads the current row values into variables
D. It creates the variables to hold the current row values
Answer: B
9. What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs?
A. Only one
B. All that apply
C. All referenced
D. None
Answer: A
10. For which trigger timing can you reference the NEW and OLD qualifiers?
A. Statement and Row
B. Statement only
C. Row only
D. Oracle Forms trigger
Answer: D
11. PL/SQL subprograms, unlike anonymous blocks, are compiled each time they are executeD. True or False?
A. True
B.False
Answer: A
12. Subprograms and anonymous blocks can be called by other applications.
A.True
B.False
Answer: A
13. A nested subprogram can be called from the main procedure or from the calling environment. Trueor False?
A. True
B. False
Answer: B
14. When modifying procedure code, the procedure must be re-executed to validate and store it in thedatabasE.
A. True
B. False
Answer: A
15. Which of the following can be used as an argument for a procedure parameter?
A.The name of a variablE.
B.A literal valuE.
C.An expression.
D.All of the abovE.
E.None of the above
Answer: D
PL/SQL Objective type Questions with Answers
16. If you don’t specify a mode for a parameter, what is the default mode?
A.OUT
B.IN
C.COPY
D.DEFAULT
E.R(ead)
Answer: B
17. Which kind of parameters cannot have a DEFAULT value?
A.OUT
B.IN
C.CONSTANT
D.R(ead)
E.W(rite)
Answer: A
18. What are the three parameter modes for procedures?
A.IN, OUT, IN OUT
B.R(ead), W(rite), A(ppend)
C.CONSTANT, VARIABLE, DEFAULT
D.COPY, NOCOPY, REF
Answer: A
19. Which one of the following statements about formal and actual parameters is true?
A.Formal and actual parameters must have the same namE.
B.Formal and actual parameters must have different names.
C.A formal parameter is declared within the called procedure, while an actual parameter is declared in thecalling environment.
D.An actual parameter is declared within the called procedurE.
Answer: C
20. What is the correct syntax to create procedure MYPROC that accepts two number parameters X and Y?
A.CREATE PROCEDURE myproc (x NUMBER, y NUMBER) IS …
B.CREATE PROCEDURE (x NUMBER, y NUMBER) myproc IS …
C.CREATE PROCEDURE myproc IS (x NUMBER, y NUMBER) …
D.CREATE PROCEDURE IS myproc (x NUMBER, y NUMBER) ….
Answer: A
21. Functions in PL/SQL are a collection of ________and PL/SQL statements that perform a task and should return a value to the calling environment.
A. Microsoft SQL Server
B. SQL
C. Query language
D. IBM DB2
Answer: B
22. As a procedural language by definition, PL/SQL provides several iteration constructs, including basic LOOP statements, WHILE loops, ________, and Cursor FOR loops.
A. Imperative programming
B. Programming language
C. Control flow
D. For loop
Answer: D
23. The StepSqlite product is a PL/SQL compiler for the popular small database ________.
A. JavaScript
B. Java (programming language)
C. Mozilla Firefox
D. SQLite
Answer: D
24. PL/SQL is available in Oracle Database (since version 7), TimesTen in-memory database (since version 11.2.1),[1] ________ (since version 9.7)[2].
A. IBM DB2
B. IBM PureQuery
C. IBM Informix
D. Microsoft SQL Server
Answer: A
25. The Fyracle project aims to enable the execution of PL/SQL code in the________ Firebird databasE.
A. Open source
B. Linux
C. Free software
D. Open-source software
Answer: A
26. PL/SQL (Procedural Language/Structured Query Language) is________’s procedural extension language for SQL and the Oracle relational databasE.
A. Intel Corporation
B. Oracle Corporation
C. Dell
D. Google
Answer: B
27. PL/SQL functions analogously to the embedded procedural languages associated with other ________.
A. Relational model
B. Database normalization
C. Relational database
D. Relation (database)
Answer: C
28. This resembles usages in object-oriented programming languages like________, C++ and Java.
A. Pascal (programming language)
B. Free Pascal
C. Object Pascal
D. Embarcadero Delphi
Answer: C
29. The structure of a PL/SQL package closely resembles the basic Pascal program structure or a ________ unit.
A. Free Pascal
B. Lazarus (software)
C. Embarcadero Delphi
D. Turbo Pascal
Answer: C
30. What is the maximum number of ELSE clauses that can be included in an IF clause that is not nested?
A. 0
B. 1
C. 15
D. Any number
Answer: B
31. Select the best answer below. What are the components of a package?
A. Box, wrapping and binding
B. Header and body
C. Specification and content
D. Specification and body
E. None of the above
Answer: D
32. PL/SQL subprograms, unlike anonymous blocks, are compiled each time they are executed. True or False?
a. True
b.False
Answer: A
33. Subprograms and anonymous blocks can be called by other applications. True or False?
a.True
b.False
Answer: A
34. A nested subprogram can be called from the main procedure or from the calling environment. Trueor False?
a. True
b. False
Answer: B
35. When modifying procedure code, the procedure must be re-executed to validate and store it in the database. True or False?
a. True
b. False
Answer: A
36. Which of the following can be used as an argument for a procedure parameter?
a.The name of a variable.
b.A literal value.
c.An expression.
d.All of the above.
e.None of the above
Answer: D
37. If you don’t specify a mode for a parameter, what is the default mode?
a.OUT
b.IN
c.COPY
d.DEFAULT
e.R(ead)
Answer: B
38. Which kind of parameters cannot have a DEFAULT value?
a.OUT
b.IN
c.CONSTANT
d.R(ead)
e.W(rite)
Answer: A
39. What are the three parameter modes for procedures?
a.IN, OUT, IN OUT
b.R(ead), W(rite), A(ppend)
c.CONSTANT, VARIABLE, DEFAULT
d.COPY, NOCOPY, REF
Answer: A
40. Which one of the following statements about formal and actual parameters is true?
a.Formal and actual parameters must have the same name.
b.Formal and actual parameters must have different names.
c.A formal parameter is declared within the called procedure, while an actual parameter is declared in thecalling environment.
d.An actual parameter is declared within the called procedure.
Answer: C
41. What is the correct syntax to create procedure MYPROC that accepts two number parameters X and Y?
a.CREATE PROCEDURE myproc (x NUMBER, y NUMBER) IS …
b.CREATE PROCEDURE (x NUMBER, y NUMBER) myproc IS …
c.CREATE PROCEDURE myproc IS (x NUMBER, y NUMBER) …
d.CREATE PROCEDURE IS myproc (x NUMBER, y NUMBER) …
Answer: A
42. In the context of MS SQL SERVER, with the exception of ………… column(s), any column can participate in the GROUP BY clause.
A) bit
B) text
C) ntext
D) image
E) All of above
Answer: E
43. The sequence of the columns in a GROUP BY clause has no effect in the ordering of the output.
A) True
B) False
Answer: B
44. You want all dates when any employee was hired. Multiple employees were hired on the same date and you want to see the date only once.
Query – 1
Select distinct hiredate
From hr.employee
Order by hiredate;
Query – 2
Select hiredate
From hr.employees
Group by hiredate
Order by hiredate;
Which of the above query is valid?
A) Query – 1
B) Query – 2
C) Both
Answer: C
45. GROUP BY ALL generates all possible groups – even those that do not meet the query’s search criteria.
A) True
B) False
Answer: A
46. All aggregate functions ignore NULLs except for …………
A) Distinct
B) Count (*)
C) Average()
D) None of above
Answer: B
47. Using GROUP BY ………… has the effect of removing duplicates from the data.
A) with aggregates
B) with order by
C) without order by
D) without aggregates
Answer: D
48. Below query is run in SQL Server 2012, is this query valid or invalid:
Select count(*) as X
from Table_Name
Group by ()
A) Valid
B) Invalid
Answer: A
49. For the purposes of …………, null values are considered equal to other nulls and are grouped together into a single result row.
A) Having
B) Group By
C) Both of above
D) None of above
Answer: B
50. If you SELECT attributes and use an aggregate function, you must GROUP BY the non-aggregate attributes.
A) True
B) False
Answer: A