100 Question of PL/SQL
100 Question of PL/SQL
No Negative Marking
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: D
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
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: C
12. What is the value of customer_id within the nested block in the example below?
/* Start main block */
DECLARE
customer_id NUMBER(9) := 678;
credit_limit NUMBER(10,2) := 10000;
BEGIN
/* Start nested block */
DECLARE
customer_id VARCHAR2(9) := 'AP56';
current_balance NUMBER(10,2) := 467.87;
BEGIN
-- what is the value of customer_id at this point?
NULL;
END;
END;
Please select the best answer.
A. 678
B. 10000
C. 'AP56'
D. 467.87
Answer: C
13. For which task is it best to use a character string enclosed by double quotes? Please
select the best answer.
A. Referring to a column in the database
B. Using a reserved word to declare an identifier
C. Using a hyphen to concatenate two columns
D. Referring to a number variable by using a logical operator
Answer: B.
14. What is the maximum number of exception handlers processed before the PL/SQL
block is exited, provided an exception occurs? Please select the best answer.
A. None
B. All exceptions that are referenced in the block
C. One
D. All exceptions that apply
Answer: C.
15. Which functions can be used with any data type? Please select all the correct
answers.
A. SUM
B. MIN
C. COUNT
D. AVG
Answer: C.
18. List the correct sequence of commands to process a set of records when using
explicit cursors
A. INITIALIZE, GET, CLOSE
B. CURSOR, GET, FETCH, CLOSE
C. OPEN, FETCH, CLOSE
D. CURSOR, FETCH, CLOSE
E. GET, SEEK, HIDE
ANSWER: C
19. Which of the following is not true about large object data types and in PL/SQL?
A. BFILE is used to store large binary objects in operating system files outside the
database.
B. BLOB is used to store character data in the database.
C. CLOB is used to store large blocks of character data in the database.
D. NCLOB is used to store large blocks of NCHAR data in the database.
Answer: B
23. Assuming the date and time is 09/09/2009 09:09:09, what value will the following
statement return SELECT TO_CHAR(TRUNC(SYSDATE),'MM/DD/YYYY
HH24:MI:SS')MFROM dual;
A. 09/09/2009 09:09:09
B. 09/09/2009 09:09:09AM
C. 09/09/2009
D. 09/09/2009 00:00:00
E. None of the above
ANSWER: D
27. Select the best answer. Which listed attribute is an invalid attribute of an Explicit
cursor.
A. %NOTFOUND
B. %FOUND
C. %ROWCOUNT
D. %ISOPEN
E. None of the above. All of these are valid.
ANSWER: E
30. What command can you use to see the errors from a recently created view or stored
procedure?
A. SHOW MISTAKES;
B. DISPLAY MISTAKES;
C. DISPLAY ERRORS;
D. SHOW ERRORS;
E. None of the above.
ANSWER: D
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: B
33. Subprograms and anonymous blocks can be called by other applications. True or
False?
A. True
B. False
ANSWER: B
34. A nested subprogram can be called from the main procedure or from the calling
environment. True or False?
A. True
B. False
ANSWER: A
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. Read
ANSWER: B
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 the calling 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: A
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: 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
51. What is/are the Naming Rules for the PL/SQL Variables?
52. In order to initialize a variable with the value other than NULL, it can be done
using which method?
53. 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.
A. Condition
B. Cursor
C. Continue
D. Check
Answer: C) Continue
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.
A. JUMP
B. GOTO
C. CONTINUE
D. BLINK
Answer: B) GOTO
55. What is the difference between PL/SQL Function and PL/SQL Procedure?
A. PL/SQL function may or may not return the value whereas PL/SQL
Procedure must have to return the value.
B. PL/SQL Procedure may or may not return the value whereas PL/SQL
Function must have to return the value.
C. PL/SQL Function may or may not return the function whereas PL/SQL
Procedure must have to return the function.
D. 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
A. Content Areas
B. Context Areas
C. Context Ids
D. Content Ids
A. SERVERERROR
B. STARTUP
C. SHUTDOWN
D. All of the above
A. BEFORE
B. AFTER
C. INSTEAD OF
D. None of the above
Answer: C) INSTEAD OF
59. Which keyword is used to query the table in the same trigger?
A. BEFORE
B. AFTER
C. SAME
D. EXACT
Answer: B) AFTER
61. Which of the following clause does not comes in the syntax while raising an
exception?
A. DECLARE
B. WHEN
C. CLOSE
D. END
Answer: C) CLOSE
A. A unique index column with duplicate values is raised when this error
occurs.
B. An invalid username or password is used by a program to connect to a
database.
C. An automatic assignment of a value to a NULL object raises this exception.
D. It is raised when more than one row is returned by a SELECT INTO
statement.
A. VALUE_ERROR
B. INTERNAL_ERROR
C. PROBLEM_ERROR
D. PROGRAM_ERROR
Answer: D) PROGRAM_ERROR
68. Which of the following is not true about PL/SQL decision making structures?
A - The IF statement associates a condition with a sequence of statements
enclosed by the keywords THEN and END IF.
B - The IF statement also adds the keyword ELSE followed by an alternative
sequence of statement.
C - The IF-THEN-ELSIF statement allows you to choose between several
alternatives.
D - PL/SQL does not have a CASE statement.
Answer: D
73. Which of the following code is the correct syntax for creating an index-by
table named salary that will store integer values along with names and the name
field will be the key?
A - TYPE salary IS TABLE OF NUMBER INDEX BY VARCHAR2(20);
B - CREATE TABLE salary OF NUMBER INDEX BY VARCHAR2(20);
C - TYPE salary IS INDEXED TABLE OF NUMBER INDEX BY VARCHAR2(20);
D - None of the above.
Answer: A
DECLARE
x number := 4;
BEGIN
LOOP
dbms_output.put_line(x);
x := x + 1;
exit WHEN x > 5;
END LOOP;
dbms_output.put_line(x);
END;
A-4
5
6
B-4
5
C-4
D - None of the above.
Answer: D
DECLARE
a number;
PROCEDURE squareNum(x IN OUT number) IS
BEGIN
x := x * x;
END;
BEGIN
a:= 5;
squareNum(a);
dbms_output.put_line(a);
END;
A-5
B - 10
C - 25
D-0
Answer: B
77. Which of the following is true about the following code snippet?
DECLARE
a number(3) := 100;
BEGIN
IF (a = 50 ) THEN
dbms_output.put_line('Value of a is 10' );
ELSIF ( a = 75 )
dbms_output.put_line('Value of a is 20' );
ELSE
dbms_output.put_line('None of the values is matching');
END IF;
dbms_output.put_line('Exact value of a is: '|| a );
END;
A - It has syntax error.
B - It will print 'None of the values is matching'.
C- It will print
None of the values is matching
Exact value of a is: 100
D - None of the above.
Answer: A
DECLARE
c_id := 1;
c_name customers.name%type;
c_addr customers.address%type;
BEGIN
SELECT name, address INTO c_name, c_addr
FROM customers
WHERE id = c_id;
END;
A - You cannot use the SELECT INTO statement of SQL to assign values to PL/SQL
variables.
B - The SELECT INTO statement here is wrong. It should be: SELECT c_name,
c_address INTO name, addr
C - The WHERE statement is wrong. It should be: WHERE id := c_id;
D - The variable c_id should be declared as a type-compatible variable as −
c_id customers.id%type := 1;
Answer: B
79. Which of the following is true for querying a table in the same trigger?
A -The AFTER keyword should be used, because triggers can query the table or
change it again only after the initial changes are applied and the table is back in a
consistent state.
B -The BEFORE keyword should be used, because triggers can query the table or
change it again only after the initial changes are applied and the table is back in a
consistent state.
C - None of the points in a. and b.
D - Both of the points in a. and b.
Answer: A
80. Which of the following is true about the inheritance for PL/SQL Objects?
A - PL/SQL allows creating object from existing base objects.
B - To implement inheritance, the base objects should be declared as NOT FINAL.
C - The NOT INSTANTIABLE clause allows you to declare an abstract object.
D - All of the above.
Answer: D
81. Which of the following is true about the inheritance for PL/SQL Objects?
A - PL/SQL allows creating object from existing base objects.
B - To implement inheritance, the base objects should be declared as NOT FINAL.
C - The NOT INSTANTIABLE clause allows you to declare an abstract object.
D - All of the above.
Answer: D
82. Which of the following is true about the following PL/SQL CASE statement
syntax?
CASE selector
WHEN 'value1' THEN S1;
WHEN 'value2' THEN S2;
WHEN 'value3' THEN S3;
...
ELSE Sn; -- default case
END CASE;
A - It is wrongly written
B - It is perfectly written.
C - It is you can specify the literal NULL for all the S expressions and the default Sn.
D - All the expressions like the selector, the value and the returns values, need not
be of the same data type.
Answer : B
Answer: D
DECLARE
grade char(1) := 'B';
BEGIN
case
when grade = 'A' then dbms_output.put_line('Excellent');
when grade = 'B' then dbms_output.put_line('Very good');
when grade = 'C' then dbms_output.put_line('Well done');
when grade = 'D' then dbms_output.put_line('You passed');
when grade = 'F' then dbms_output.put_line('Better try again');
else dbms_output.put_line('No such grade');
end case;
END;
A - It has syntax error, so there will not be any output.
B-B
C - Very good
D - No such grade
Answer: C
85. Which of the following code is the correct syntax for creating a nested table
named salary that will store integer values?
A - TYPE salary IS TABLE OF INTEGER;
B - TYPE salary IS NESTED TABLE OF INTEGER;
C - TABLE salary IS NESTED BY INTEGER;
D - TABLE salary IS INDEXED BY INTEGER;
Answer: A
A. Begin
B. End
C. Both A and B
D. None of the above
Answer: C
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
Answer: A
A. IN Operator
B. BETWEEN Operator
C. LIKE Operator
D. IS NULL Operator
Answer: A
Answer: D
92. Which Operator Returns TRUE if a subquery returns at least one row?
a. EXISTS
b. IN
c. IS NULL
d. LIKE
Answer: A
Answer: D
a. “User-defined Exception”
b. 1
c. 0
d. None of the above
Answer: A
95. Which of the following is handled with the help of exception-handling section
in an PL/SQL block. For eg, SELECT INTO statement, which does not return any
rows.
a. A runtime error
b. A syntax error
c. Both A & B
d. None of the above
Answer: C
Answer: C
Answer: A
Answer: E
99. What are the different datatypes that can be defined in a PL/SQL block?
a. Scalar
b. Composite
c. Reference
d. LOB
e. All mentioned above
Answer: E
100. Which of the following results are true, when a ROLLBACK statement is
issued to the database, the transaction has ended?
a. All work done by the transaction is undone, as if it hadn't been issued.
b. Any locks acquired by the transaction are released.
c. Both A & B
d. None of the above
Answer: C
=========
©Jobs&internshipPortal Youtube Channel
Thank You!
Click below to visit our channel for more such content
https://www.youtube.com/@JobsInternshipPortal
Sharing with unauthorized person is strictly prohibited.