PLSQL Section 1-10
PLSQL Section 1-10
Oracle JSQL
False
5. Which component of Oracle Application Express is used toenter and run SQL
statements and PL/SQL blocks?
SQL Workshop
6. Comparing PL/SQL with other languages such as C and Java, which of the
following statements is true?
PL/SQL is easier to learn and more efficient
9. Procedural constructs give you better control of your SQL statements and
their execution. True or False?
True
10. PL/SQL can be used not only with an Oracle database, but also with any kind of
relational database. True or False?
False
13. Third-generation programming languages include all except _____ and _____.
C++ Java
15. Which of the following are examples of good programming practice? (Choose
two.)
Use meaningful names for identifiers.
Use the %TYPE attribute to declare a variable according to another previously
declared variable or database column.
16. Is it possible to insert more than one row at a time using an INSERT statement
with a VALUES clause?
No, you can only create one row at a time when using the VALUES clause.
17. You want to modify existing rows in a table. Which of the following are NOT
needed in your SQL statement?
A MODIFY clause.
19. When used in a PL/SQL block, which SQL statement must return exactly one
row?
Select
20. The MERGE statement will INSERT or DELETE rows in a target table based on
matching values in a source table. True or False?
False
21. It is good programming practice to create identifiers having the same name as
column names
False
22. When explicitly inserting a row into a table, the VALUES clause must include a
value for every column of the table
False
23. When INSERTing a row, the NULL keyword can be included in the VALUES (....)
list. True or False?
True
26. Which one of these tasks is best done using a LOOP statement?
Calculating and displaying the sum of all integers from 1 to 100
27. In a WHILE loop, the controlling condition is checked at the start of each
iteration.
True
28. How many DML statements can be included in a single transaction?
As many as needed
29. What would be the result of the following statement: DELETE FROM employees;
All rows in the employees table will be deleted
30. Which of the following statements about user-defined PL/SQL records is NOT
true?
It must contain one or more components, but all the components must have
scalar datatypes.
Four
32. Which of the following will successfully create a record type containing two
fields, and a record variable of that type?
TYPE person_type IS (l_name VARCHAR2(20),
gender CHAR(1));
person_rec TYPE person_type;
v_dept_info_rec dept_info_type;
v_emp_dept_rec emp_dept_type;
v_emp_dept_rec emp_dept_type;
35. Which of the following statements about user-defined PL/SQL records is NOT
true?
It must contain one or more components, but all the components must have
scalar datatypes.
37. Which of these PL/SQL data structures could store a complete copy of the
employees table, i.e., 20 complete table rows?
An INDEX BY table of records
40. To declare an INDEX BY table, we must first declare a type and then declare a
collection variable of that type. True or False?
False
41. Which of the following methods can be used to reference elements of an INDEX
BY table? (Choose three.)
Exit, Frist, Count
44. Which of these PL/SQL data structures can NOT store a collection?
A PL/SQL record
45. An INDEX BY TABLE type can only have one data field.
True
46. What is the largest number of elements (i.e., records) that an INDEX BY table of
records can contain?
Many millions of records because a BINARY_INTEGER or PLS_INTEGER can have
a very large value
49. You can store a whole record in a single variable using %ROWTYPE or by
creating your own record structure as a type and then declaring a variable of
that type.
True
51. When using a cursor FOR loop, OPEN, CLOSE, and FETCH statements should not
be explicitly coded. True Or False
True
52. Assume that you have declared a cursor called C_EMP. Which of the following
statements about C_EMP is correct?(Choose Two)
You can use c_emp%NOTFOUND to exit a loop.
You can use c_emp%ROWCOUNT to return the number of rows returned by the
cursor so far.
53. How must you reference one field which is part of a PL/SQL record?
record_name.field_name
54. Examine the following code. The UPDATE statement will raise an ORA-02291
exception.
BEGIN
UPDATE employees
SET department_id = 45;
EXCEPTION
WHEN OTHERS THEN
INSERT INTO error_log_table VALUES (SQLCODE);
END;
What will happen when this code is executed?
The code will fail because we cannot use functions like SQLCODE directly in a
SQL statement.
55. While a PL/SQL block is executing, more than one exception can occur at the
same time
False
56. Which of the following are good practice guidelines for exception handling?
(Choose three.)
Use an exception handler whenever there is any possibility of an error occurring.
Test your code with different combinations of data to see what potential errors
can happen.
Handle specific named exceptions where possible, instead of relying on WHEN
OTHERS.
57. Exceptions declared in a block are considered local to that block, and global to all
its sub-blocks. True or False?
True
62. A PL/SQL block executes and an Oracle Server exception is raised. Which of the
following contains the text message associated with the exception?
SQLERRM
63. The following exception handler will successfully insert the Oracle error number
and error message into a log table whenever an Oracle Server error occurs. True
or False?
EXCEPTION
WHEN OTHERS THEN
INSERT INTO err_log_table (num_col, char_col)
VALUES (SQLCODE, SQLERRM);
END;
(Assume that err_log_table has been created with suitable columns and
datatypes.)
False
65. When creating a procedure, where in the code must the parameters be listed?
After The Product Name
68. What is the correct syntax to create procedure MYPROC that accepts two
number parameters X and Y?
CREATE PROCEDURE myproc (x NUMBER, y NUMBER) IS
69. You want to create a procedure which accepts a single parameter. The
parameter is a number with a maximum value of 9999.99. Which of the following
is a valid declaration for this parameter?
(v_num NUMBER)
70. The following are the steps involved in creating, and later modifying and re-
creating, a PL/SQL procedure in Application Express. Which step is missing?
74. User-defined functions can extend the power of SQL statements where Oracle
does not provide ready-made functions such as UPPER and LOWER. True or
False?
True
76. You try to create a function named MYFUNC. The function does not compile
correctly because there are errors in your code. Which Dictionary view can you
query to see the errors?
USER_ERRORS
77. The database administrator has granted the DROP ANY PROCEDURE privilege to
user KIM. This allows Kim to remove other users' procedures and functions from
the database. How would Kim now drop function GET_EMP, which is owned by
user MEHMET?
DROP FUNCTION mehmet.get_emp
78. USERB creates a function called SEL_PROC which includes the statement:
SELECT ... FROM usera.employees ...;
USERC needs to execute UserB's procedure. What privileges are needed for this
to work correctly? (Choose two.)
UserC needs EXECUTE on userB.sel_proc
UserB needs SELECT on userA.employees
83. You want to find out how many Dictionary views will list objects in your schema
(but not in other users' schemas). Which of the following queries should you use
to do this?
SELECT COUNT(*)
FROM DICTIONARY
WHERE TABLE_NAME LIKE 'USER%';
84. JOE's schema contains a COUNTRIES table. The following commands are
executed by JOE and TOM:
(JOE): GRANT SELECT ON countries TO tom WITH GRANT OPTION;
(TOM): GRANT SELECT on joe.countries TO dick WITH GRANT OPTION;
Now, JOE executes:
REVOKE SELECT ON countries FROM tom;
What happens to the grant to DICK?
DICK also loses his SELECT privilege.
85. How do you specify that you want a procedure MYPROCA to use Invoker's
Rights?
CREATE OR REPLACE PROCEDURE myproca
AUTHID CURRENT_USER IS
86. We never need to use a forward declaration when invoking a public subprogram.
True Or False?
True
87. Functions called from a SQL query or DML statement must not end the
current transaction, or create or roll back to a savepoint. True or False?
True
89. We never need to use a forward declaration when invoking a public subprogram.
True or False?
True
90. How would you invoke the constant km_to_mile from the global_consts bodiless
package at VARIABLE A?
SELECT trail_name, distance_in_km * VARIABLE A
FROM trails
WHERE park_name = 'YOSEMITE';
global_consts.km_to_mile
92. Functions called from a SQL query or DML statement must not end the current
transaction, or create or roll back to a savepoint. True or False?
True
93. Which of the following are good reasons to group a set of procedures and
functions into a package?
All of these.
97. What is wrong with the following syntax for creating a package specification?
CREATE OR REPLACE mypack IS
g_constant1 NUMBER(6) := 100;
PROCEDURE proc1 (p_param1 IN VARCHAR2);
PROCEDURE proc2;
END mypack;
The keyword PACKAGE is missing.
99. We want to remove the specification (but not the body) of package BIGPACK
from the database. Which of the following commands will do this?
None of these
101. A package contains both public and private subprograms. Which one of
the following statements is true?
The whole package is loaded into memory when the first call is made to any
subprogram in the package.
102. Which of the following will display the detailed code of the subprograms in
package DEPTPACK in your schema ?
SELECT text FROM USER_SOURCE
WHERE name = 'DEPTPACK'
AND type = 'PACKAGE BODY'
ORDER BY line;