Sie sind auf Seite 1von 14

1. Which of the following tools can NOT be used to develop and test PL/SQL code?

Oracle JSQL

2. Which keywords must be included in every PL/SQL block? (Choose two.)


End; Begin

3. In a PL/SQL block, which of the following should not be followed by a semicolon?


Declare

4. This PL/SQL anonymous block will execute successfully. True or False?


DECLARE
v_date DATE := SYSDATE;
DBMS_OUTPUT.PUT_LINE(v_date);
END;

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

7. When multiple SQL statements are combined into PL/SQL blocks,


performance improves. True or False?
True

8. Which of the following can be done using PL/SQL?


All of these can be done

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

11. PL/SQL is an Oracle proprietary, procedural, fourth-generation programming


language
False
12. SQL is a common access language for many types of databases, including
Oracle. True or False?
True

13. Third-generation programming languages include all except _____ and _____.
C++ Java

14. Examine the following code:


DECLARE
v_first_name varchar2 (30);
v_salary number (10);
BEGIN
SELECT first_name, salary
INTO v_first_name, v_salary
FROM employees
WHERE last_name = 'King';
END;
Which programming guideline would improve this code?
Indent the code to make it more readable.

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.

18. Look at this PL/SQL block:


DECLARE
v_count NUMBER;
BEGIN
SELECT COUNT(*) INTO v_count
FROM employees WHERE salary > 50000;
END;
No employees earn more than $50000. Which of the following statements are
true?
The SELECT returns exactly one row.
The SELECT will return value 0 into V_COUNT.

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

24. A PL/SQL block includes the following statement:


SELECT last_name INTO v_last_name
FROM employees
WHERE employee_id=100;
What is the value of SQL%FOUND immediately after the SELECT statement is
executed?
True

25. Which one of the following is correct syntax for an IF statement?


IF condition THEN
statement1;
statement2;
END IF;

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.

31. Consider the following code:


DECLARETYPE dept_info_type IS RECORD
(department_id departments.department_id%TYPE,department_name
departments.department_name%TYPE);
TYPE emp_dept_type IS RECORD
(first_name employees.first_name%TYPE,last_name
employees.last_name%TYPE),
dept_info dept_info_type);v_emp_dept_rec emp_dept_type;How many fields can
be addressed in v_emp_dept_rec?

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;

33. Consider the following code:


DECLARE
TYPE dept_info_type IS RECORD
(department_id departments.department_id%TYPE,
department_name departments.department_name%TYPE);
TYPE emp_dept_type IS RECORD
(first_name employees.first_name%TYPE,
last_name employees.last_name%TYPE),
dept_info dept_info_type);

v_dept_info_rec dept_info_type;
v_emp_dept_rec emp_dept_type;

How many fields can be addressed in v_dept_info_rec?


Two
34. Consider the following code:
DECLARE
TYPE dept_info_type IS RECORD
(department_id departments.department_id%TYPE,
department_name departments.department_name%TYPE);
TYPE emp_dept_type IS RECORD
(first_name employees.first_name%TYPE,
last_name employees.last_name%TYPE),
dept_info dept_info_type);

v_emp_dept_rec emp_dept_type;

How many fields can be addressed in v_emp_dept_rec?


Four

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.

36. You can use %ROWTYPE with tables and views.


False

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

38. An INDEX BY TABLE must have a primary key.


True

39. An INDEX BY TABLE primary key cannot be negative.


False

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

42. In an INDEX BY table of records the record can be


Either One
43. Which of the following successfully declares an INDEX BY table of records which
could be used to store copies of complete rows from the departments table?
DECLARE
TYPE t_depttab IS TABLE OF departments%ROWTYPE
INDEX BY BINARY_INTEGER;

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

47. Identify the valid collection types:


INDEX BY TABLE OF RECORDS
INDEX BY TABLE

48. You can use %ROWTYPE with tables and views.


True

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

50. What is missing from the following cursor declaration?


CURSOR emp_curs
IS
SELECT * FROM departments
WHERE location_id = p_loc_id;
Mark for Review
A parameter is missing. The parameter should be coded as: (p_loc_id NUMBER)

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

58. The following line of code is correct. True or False?


RAISE_APPLICATION_ERROR(-21001,’My error message’);
False

59. What is the datatype of a user-defined exception?


Exception
60. What is a user-defined exception?
An exception which is not raised automatically by the Oracle server, but must be
declared and raised explicitly by the PL/SQL programmer.

61. Which kind of error can NOT be handled by PL/SQL?


Syntax errors

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

64. What is wrong with the following code?


BEGIN
UPDATE employees
SET salary = 20000
WHERE job_id = 'CLERK';
IF SQL%ROWCOUNT = 0 THEN
RAISE NO_DATA_FOUND; -- Line A
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No employee was updated');
END;
Nothing is wrong; the code will execute correctly

65. When creating a procedure, where in the code must the parameters be listed?
After The Product Name

66. What are the types of parameter modes?


In,Out,In Out
67. You have created procedure MYPROC with a single parameter PARM1 NUMBER.
Now you want to add a second parameter to the procedure. Which of the
following will change the procedure successfully?
CREATE OR REPLACE PROCEDURE myproc
(parm1 NUMBER, parm2 NUMBER)
IS
BEGIN

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?

1. Type the procedure code in the SQL Commands window


2. Click on the "Save" button and save the procedure code
3. Retrieve the saved code from "Saved SQL" in SQL Commands
4. Modify the code in the SQL Commands window
5. Execute the code to re-create the procedure
Execute the code to create the procedure

71. The following procedure has been created:


CREATE OR REPLACE PROCEDURE myproc
(p_p1 NUMBER, p_p2 VARCHAR2)
IS BEGIN ...
Which one of the following calls to the procedure will NOT work?
myproc(p_p1 => 80, 'Smith');

72. The following procedure has been created:


CREATE OR REPLACE PROCEDURE myproc
(A IN NUMBER := 20,
B IN NUMBER,
C IN NUMBER DEFAULT 30)
IS .....
Which of the following will invoke the procedure correctly?
None of these.
73. You are always able to view and reload your PL/SQL stored procedure's code at a
later point by clicking on the History button in the APEX SQL Commands window.
True or False?
False

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

75. Which of the following is NOT a benefit of user-defined functions?


They can do the same job as built-in system functions such as UPPER and
ROUND.

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

79. Procedure GET_EMPS includes a SELECT…FROM EMPLOYEES. The procedure


was created using Invoker's Rights. Which of the following statements are true?
(Choose three.)
The user who executes the procedure needs SELECT privilege on EMPLOYEES.
The creator of the procedure needs SELECT privilege on EMPLOYEES.
The user who executes the procedure needs EXECUTE privilege on the
procedure.

80. Which of the following is a benefit of user-defined functions? (Choose 3)


They can often be used inside SQL statements.
They can be used in a WHERE clause to filter data and thereby increase
efficiency.
They can add business rules to the database and can be reused many times.

81. A stored function:


must return one and only one value.

82. User MARY executes this SQL statement:


SELECT COUNT(*) FROM USER_VIEWS;
A value of 15 is returned. Which of the following statements is true?
There are 15 views in Mary's schema

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

88. Examine the following package code:


CREATE OR REPLACE PACKAGE over_pack IS
PROCEDURE do_work1 (p1 IN VARCHAR2, p2 IN NUMBER);
PROCEDURE do_work2 (p1 IN VARCHAR2, p2 IN NUMBER);
PROCEDURE do_work1 (param1 IN CHAR, param2 IN NUMBER);
FUNCTION do_work2 (param1 IN VARCHAR2, param2 IN NUMBER) RETURN
DATE;
END over_pack;
Which of the following calls will be successful? (Choose three.)
over_pack.do_work1(p1=>'Smith',p2=>20);
v_date := over_pack.do_work2('Smith',20);
over_pack.do_work2('Smith',20);

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

91. Examine the following code:


CREATE OR REPLACE PACKAGE emppack IS
PROCEDURE upd_emp (p_empno IN NUMBER, p_salary IN NUMBER);
END emppack;
CREATE OR REPLACE PACKAGE BODY emppack IS
-- Line A
PROCEDURE upd_emp (p_empno IN NUMBER, p_salary IN NUMBER) IS
BEGIN
IF NOT sal_ok(p_salary) THEN
RAISE_APPLICATION_ERROR(-20201,'Invalid salary');
END IF;
END upd_emp;
FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN IS
BEGIN
IF pf_salary > 50000 THEN RETURN FALSE;
ELSE RETURN TRUE;
END IF;
END sal_ok;
END emppack;
What must be coded at Line A for this package to compile successfully?
FUNCTION sal_ok(pf_salary NUMBER) RETURN BOOLEAN;

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.

94. In which component of a package is the full definition of a public procedure


written?
Body

95. Which of the following can be included in a package?


All of these.

96. The following package specification has been created:


CREATE OR REPLACE PACKAGE mypack IS
FUNCTION myfunc(p_funcparam DATE) RETURN BOOLEAN;
PROCEDURE myproc(p_procparam IN NUMBER);
END mypack;
Which of the following will correctly invoke the package subprograms? (Choose
two.)
mypack.myproc(35);
IF NOT mypack.myfunc(SYSDATE) THEN
DBMS_OUTPUT.PUT_LINE('Message');
END IF;

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.

98. A local variable declared within a procedure in a package can be referenced by


any other component of that package. True or False?
False

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

100. Examine the following package specification:


CREATE OR REPLACE PACKAGE taxpack IS
CURSOR empcurs IS SELECT * FROM employees;
PROCEDURE taxproc;
END mypack;
The package body of TAXPACK also includes a function called TAXFUNC. Which
one of the following statements is NOT true?
The package will not compile because you cannot declare a cursor in the
specification.

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;

Das könnte Ihnen auch gefallen