1. What is wrong with the following code? CREATE FUNCTION annual_comp (sal employees.salary%TYPE, comm_pct IN employees.

commission%TYPE) RETURN NUMBER(5,2 ) IS RETURN (sal*12) + NVL(comm_pct,0)*12*sal; END annual_comp; Mark for Review (1) Points The sal parameter should specify the IN keyword. The RETURN NUMBER has a scale and precision. (*) There should be parentheses (brackets) around NVL(comm_pct,0)*12*sal The END; statement should not include the function name.

Correct 2. What will happen when the following subprogram is compil ed? PROCEDURE at_proc IS PRAGMA AUTONOMOUS_TRANSACTION; dept_id NUMBER := 90; BEGIN UPDATE ... INSERT ... END at_proc; Mark for Review (1) Points The subprogram will fail because it is missing AUTHID CURRENT_USER befor e IS. The autonomous transaction subprogram will fail because it must include COMMIT or ROLLBACK. (*) The compilation will fail because a semicolon after AUTONOMOUS_TRANSACTI ON is not needed. The program will compile successfully.

Correct 3. Function MYFUNC1 has been created, but has failed to co mpile because it contains syntax errors. We now try to create procedure MYPROC1 which invokes this function. Which of the following statements is true? Mark for Review (1) Points

MYPROC1 will compile correctly, but will fail when it is executed. MYPROC1 will compile and execute succesfully. MYPROC1 will fail to compile because the function is invalid. (*) MYPROC1 will compile and execute successfully, except that the call to M YFUNC1 will be treated as a comment and ignored.

Incorrect. Refer to Section 9 Lesson 1. 4. CREATE FUNCTION get_sal (p_id employees.employee_id%TYPE)) RETURN number IS v_sal employees.salary%TYPE := 0; BEGIN SELECT salary INTO v_sal FROM employees WHERE employee_id = p_id; RETURN v_sal; END get_sal; Which variable is passed to the function and which variable is returned from the function? Mark for Review (1) Points GET_SAL is passed and V_SAL is returned. SALARY is passed and P_ID is returned. EMPLOYEE_ID is passed and SALARY is returned. P_ID is passed and V_SAL is returned. (*)

Incorrect. Refer to Section 9 Lesson 1. 5. Procedure p1 has a single OUT parameter of type DATE. F unction f1 returns a DATE. What is the difference between p1 and f1? Mark for Review (1) Points p1 can be invoked from an anonymous block but f1 cannot

f1 can be used within a SQL statement but p1 cannot (*) p1 can have as many IN parameters as needed but f1 cannot have more than two IN parameters There is no difference because they both return a single value of the sa me datatype

Incorrect. Refer to Section 9 Lesson 1. 6. Which of the following is found in a function and not a Mark for Review

procedure? (1) Points

An exception section. IN parameters. Local variables in the IS/AS section. Return statement in the header. (*)

Incorrect. Refer to Section 9 Lesson 1. 7. (1) Points must have at least one IN parameter. cannot be called in a SQL statement. must return one and only one value. (*) is called as a standalone executable statement. A stored function: Mark for Review

Incorrect. Refer to Section 9 Lesson 1. 8. An autonomous transaction subprogram may be in the same package as the calling subprogram or may be in a separate subprogram. True or Fa lse? Mark for Review

(1) Points True False (*)

Incorrect. Refer to Section 9 Lesson 6. 9. Function GET_JOB accepts an employee id as input and re turns that employee's job id. Which of the following calls to the function will NOT work? Mark for Review (1) Points DBMS_OUTPUT.PUT_LINE(get_job(100)); IF get_job(100) = 'IT_PROG' THEN ... get_job(100,v_job_id); (*) v_job_id := get_job(100);

Incorrect. Refer to Section 9 Lesson 1. 10. A PL/SQL function can have IN OUT parameters. True or F alse? Mark for Review (1) Points True False (*)

Incorrect. Refer to Section 9 Lesson 1. 11. The following function has been created: CREATE OR REPLACE FUNCTION find_sal (p_emp_id IN employees.employee_id%TYPE) RETURN NUMBER IS ... We want to invoke this function from the following anonymous block: DECLARE v_mynum NUMBER(6,2); v_mydate DATE;

BEGIN ... Line A END; Which of the following would you include at Line A? Mark for Review (1) Points find_sal(100,v_mynum); v_mynum := find_sal(100); (*) v_mydate := find_sal(100); find_sal(v_mynum,100);

Incorrect. Refer to Section 9 Lesson 1. 12. To create a function successfully, the following steps s hould be performed: A Re-execute the code until it compiles correctly B Write the code containing the CREATE or REPLACE FUNCTION followed by the func tion code C Test the function from a SQL statement or an anonymous block D If the function fails to compile, correct the errors E Load the code into Application Express F Execute the code in Application Express What is the correct order to perform these steps? Mark for Review (1) Points B,E,F,D,A,C (*) D,B,E,F,A,C B,C,E,F,D,A A,B,E,F,D,C

Incorrect. Refer to Section 9 Lesson 1. 13. When using Invoker's rights, the invoker needs privileg es on the database objects referenced within the subprogram, as well as GRANT pr

ivilege on the procedure. True or False? (1) Points True False (*)

Mark for Review

Incorrect. Refer to Section 9 Lesson 6. 14. Based on the following function definition: Create func tion annual_comp (sal employees.salary%type, comm_pct In employees.commission%ty pe) ... Which one of the following is an incorrect call for annual_comp? Mark for Review (1) Points Execute dbms_output.put_line(annual_comp (1000,.2)) Select employee_id, annual_comp(salary, commission_pct) from employees; Declare Ann_comp number (6,2); Begin ... Ann_comp := annual_comp(1000,.2 ); ... End; Select employee_id, annual_comp(salary) from employees; (*)

Incorrect. Refer to Section 9 Lesson 1. 15. You have created a function called GET_COUNTRY_NAME whi ch accepts a country_id as an IN parameter and returns the name of the country. Which one of the following calls to the function will NOT work? Mark for Review (1) Points v_name := get_country_name(100); DBMS_OUTPUT.PUT_LINE(get_country_name(100)); SELECT get_country_name(100) FROM dual; BEGIN get_country_name(100, v_name); END; (*)

Incorrect. Refer to Section 9 Lesson 1. 1. The following function has been created

: CREATE OR REPLACE FUNCTION upd_dept (p_dept_id IN departments.department_id%TYPE) RETURN NUMBER IS BEGIN UPDATE departments SET department_name = 'Accounting' WHERE department_id = p_dept_id; RETURN p_dept_id; END; Which of the following will execute successfully? Mark for Review (1) Points DELETE FROM departments WHERE department_id = upd_dept(department_id); SELECT upd_dept(department_id) FROM employees; DELETE FROM employees WHERE department_id = upd_dept(80); (*)

SELECT upd_dept(80) FROM dual;

Incorrect. Refer to Section 9 Lesson 2. 2. User-defined functions can extend the power of SQL stat ements where Oracle does not provide ready-made functions such as UPPER and LOWE R. True or False? Mark for Review (1) Points True (*) False

Correct 3. Function DOUBLE_SAL has been created as follows: CREATE OR REPLACE FUNCTION double_sal (p_salary IN employees.salary%TYPE) RETURN NUMBE R IS BEGIN RETURN(p_salary * 2); END; Which of the following calls to DOUBLE_SAL will NOT work? Mark for Review (1) Points

SELECT * FROM employees WHERE double_sal(salary) > 20000; SELECT * FROM employees ORDER BY double_sal(salary) DESC; UPDATE employees SET salary = double_sal(salary); SELECT last_name, double_sal(salary) FROM employees; None of the above; they will all work (*)

Incorrect. Refer to Section 9 Lesson 2. 4. Which of the following is NOT a benefit of user-defined Mark for Review

functions? (1) Points

They can add business rules to the database and can be reused many times . They can be used in a WHERE clause to filter data. They can do the same job as built-in system functions such as UPPER and ROUND. (*) They can often be used inside SQL statements.

Incorrect. Refer to Section 9 Lesson 2. 5. You want to create a function which can be used in a SQ L statement. Which one of the following can be coded within your function? Mark for Review (1) Points RETURN BOOLEAN One or more IN parameters (*) An OUT parameter COMMIT;

Incorrect. Refer to Section 9 Lesson 2. 6. Which of the following is NOT a legal location for a fu nction call in a SQL statement? Mark for Review (1) Points FROM clause of a SELECT statement (*) WHERE clause in a DELETE statement SET clause of an UPDATE statement VALUES clause of an INSERT statement

Correct 1. User BOB is not a database administrator. BOB wants to see the names of all the tables in his schema, as well as all the tables in othe r users' schemas which he has privileges to use. Which Data Dictionary view woul d BOB query to do this? Mark for Review (1) Points USER_TABLES ALL_TABLES (*) DBA_TABLES USER_TAB_COLUMNS None of the above.

Correct 2. A user executes the following statement: CREATE INDEX fn_index ON employees(first_name); What output will the following statement now display: SELECT index_name FROM user_indexes WHERE index_name LIKE 'fn%'; Mark for Review (1) Points

fn_index FN_INDEX fn_index FN_INDEX No output will be displayed (*)

Incorrect. Refer to Section 9 Lesson 3. 3. User MARY executes the SQL statement: SELECT COUNT(*) FROM USER_VIEWS; A value of 15 is returned. Which of the following statements is true? Mark for Review (1) Points There are 15 views in Mary's schema. (*) Mary has created views on 15 of her tables. There are 15 views in the database. Other users have granted Mary SELECT privilege on 15 of their views.

Correct 4. " DICTIONARY is true? (1) Points Which of the following statements about the "super-view Mark for Review

It lists all the dictionary views. It can be thought of as a "catalog of the master catalog". We can use it like a Web search engine to remind ourselves of the names of dictionary views. All of the above. (*)

None of the above.

Incorrect. Refer to Section 9 Lesson 3. 5. You have forgotten the name of the Dictionary view USER _TABLES. Which of the following statements is the best and quickest way to remin d yourself? Mark for Review (1) Points SELECT * FROM dictionary WHERE table_name LIKE USER%; Read the online Oracle documentation at http://technet.oracle.com. SELECT * FROM dict WHERE table_name LIKE 'USER%TAB%'; (*)

SELECT * FROM dictionary WHERE table_name = 'USER_TABLES'; Phone the database administrator.

Correct 6. Which of the following best describes the Data Dictiona ry? Mark for Review (1) Points It is a set of tables which can be updated by any user who has the neces sary privileges. It is an automatically managed master catalog of all the objects stored in the database. (*) It contains a backup copy of all the data in the database. It contains a list of all database tables which are not in any schema.

Incorrect. Refer to Section 9 Lesson 3.

7. Which of the following will display how many objects of each type are in a user's schema? Mark for Review (1) Points SELECT COUNT(*) FROM user_objects; SELECT object_type, COUNT(*) FROM user_objects GROUP BY object_type; (*)

SELECT object_type, COUNT(*) FROM all_objects GROUP BY object_type; DESCRIBE user_objects GROUP BY object_type;

Incorrect. Refer to Section 9 Lesson 3. 8. Which of the following is NOT a benefit of the Data Dic Mark for Review

tionary? (1) Points

It allows us to remind ourselves of the names of our tables, in case we have fogotten them. It allows us to check which system privileges have been granted to us. It will speed up the execution of SELECT statements in which the WHERE c lause column is not indexed. (*) It allows the PL/SQL compiler to check for object existence; for example , when creating a procedure which references a table, the PL/SQL compiler can ch eck that the table exists.

Incorrect. Refer to Section 9 Lesson 3. 1. proc_a has been created as follows: CREATE OR REPLACE PROCEDURE proc_a IS v_last_name employees.last_name%TYPE; BEGIN SELECT last_name INTO v_last_name FROM employees WHERE employee_id = 999; /* This SELECT will raise an exception because employee_id 999 does not exis

t */ DBMS_OUTPUT.PUT_LINE('This SELECT failed'); END; proc_b is now created as follows: CREATE OR REPLACE PROCEDURE proc_b IS BEGIN proc_a; DBMS_OUTPUT.PUT_LINE('proc_a was invoked'); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('An exception occurred'); END; What will be displayed when proc_b is executed? Mark for Review (1) Points An exception occurred (*)

This SELECT failed proc_a was invoked An exception occurred This SELECT failed This SELECT failed proc_a was invoked Nothing will be displayed

Incorrect. Refer to Section 9 Lesson 4. 2. ams in your schema? (1) Points user_source user_procedures user_objects (*) user_dependencies Which dictionary view will list all the PL/SQL subprogr Mark for Review

user_subprograms

Incorrect. Refer to Section 9 Lesson 4. 3. Which view would you query to see the detailed code of Mark for Review

a procedure? (1) Points

user_source (*) user_procedures user_objects user_dependencies user_errors

Incorrect. Refer to Section 9 Lesson 4. 4. The database administrator has granted the DROP ANY PRO CEDURE 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? Mark for Review (1) Points DROP FUNCTION get_emp FROM mehmet DROP FUNCTION mehmet.get_emp (*) DROP PROCEDURE mehmet.get_emp DROP PROGRAM mehmet.get_emp None of the above

Incorrect. Refer to Section 9 Lesson 4. 5. You need to remove procedure BADPROC from your schema.

What is the correct syntax to do this? Mark for Review (1) Points DELETE PROCEDURE badproc; DROP PROGRAM badproc; ALTER PROCEDURE badproc DISABLE; DROP PROCEDURE badproc; (*)

Incorrect. Refer to Section 9 Lesson 4. 6. Procedure ins_emp accepts an employee_id as an IN param eter and attempts to insert a row with that employee_id into the EMPLOYEES table . Ins_emp does not contain an exception section. A second procedure is created a s follows: CREATE OR REPLACE PROCEDURE call_ins_emp IS BEGIN ins_emp(99); -- this employee does not exist ins_emp(100); -- this employee already exists ins_emp(999); -- this employee does not exist EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('An exception occurred'); END; When call_ins_emp is executed, which rows will be inserted into the EMPLOYEES ta ble? Mark for Review (1) Points 99 only (*) 99 and 999 All three rows will be inserted 999 only No rows will be inserted

Incorrect. Refer to Section 9 Lesson 4. 1. User DIANE owns a DEPARTMENTS table. User JOEL needs to update the location_id column of Diane's table, but no other columns. Which SQL

statement should Diane execute to allow this? Mark for Review (1) Points GRANT UPDATE ON departments TO joel; GRANT UPDATE ON departments(location_id) TO joel; GRANT UPDATE ON departments.location_id TO joel; GRANT UPDATE(location_id) ON departments TO joel; (*) GRANT UPDATE ON location_id OF departments TO joel;

Incorrect. Refer to Section 9 Lesson 5. 2. USERB creates a function called SEL_PROC (using Definer 's Rights) 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.) Mark for Review (1) Points (Choose all correct answers) UserB needs SELECT on userA.employees (*) UserC needs SELECT on userA.employees UserC needs EXECUTE on userB.sel_proc (*) UserA needs EXECUTE on userB.sel_proc UserC needs EXECUTE on Userb

Incorrect. Refer to Section 9 Lesson 5. 3. User TOM needs to grant both SELECT and INSERT privileg es on both his EMPLOYEES and DEPARTMENTS tables to both DICK and HARRY. What is the smallest number of GRANT statements needed to do this? Mark for Review (1) Points

1 2 (*) 3 4 8

Incorrect. Refer to Section 9 Lesson 5. 4. User SVETLANA creates a view called EMP_VIEW that is ba sed on a SELECT from her EMPLOYEES table. Svetlana now wants user PHIL to be abl e to query the view. What is the smallest set of object privileges that Svetlana must grant to Phil? Mark for Review (1) Points SELECT on EMP_VIEW and SELECT on EMPLOYEES SELECT and EXECUTE on EMP_VIEW SELECT on EMP_VIEW (*) SELECT on EMP_VIEW and REFERENCES on EMPLOYEES

Incorrect. Refer to Section 9 Lesson 5. 5. User COLLEEN owns an EMPLOYEES table and wants to allow user AYSE to create indexes on the table. Which object privilege must Colleen g rant to Ayse? Mark for Review (1) Points SELECT on EMPLOYEES INDEX on EMPLOYEES (*) ALTER on EMPLOYEES CREATE on EMPLOYEES

None of the above

Correct 6. User FRED creates a procedure called DEL_DEPT using Def iner's Rights, which deletes a row from Fred's DEPARTMENTS table. What privilege (s) will user BOB need to be able to execute Fred's procedure? Mark for Review (1) Points EXECUTE on DEL_DEPT (*) EXECUTE on DEL_DEPT and DELETE on DEPARTMENTS EXECUTE on DEL_DEPT and DELETE on FRED.DEPARTMENTS DELETE on FRED.DEPARTMENTS

Correct 1. Procedure GET_EMPS includes a SELECT ... FROM EMPLOYEES . The procedure was created using Invoker's Rights. Which of the following state ments are true? (Choose three.) Mark for Review (1) Points (Choose all correct answers) The user who executes the procedure needs EXECUTE privilege on the proce dure. (*) The creator of the procedure needs SELECT privilege on EMPLOYEES. (*) The user who executes the procedure does not need any privileges. The user who executes the procedure needs SELECT privilege on EMPLOYEES. (*)

Incorrect. Refer to Section 9 Lesson 6. 2. When using Invoker's rights, the invoker needs privileg es on the database objects referenced within the subprogram, as well as GRANT pr ivilege on the procedure. True or False? Mark for Review (1) Points

True False (*)

Incorrect. Refer to Section 9 Lesson 6. 3. An autonomous transaction subprogram may be in a the sa me package as the calling subprogram or may be in a separate subprogram. True or False? Mark for Review (1) Points True False (*)

Incorrect. Refer to Section 9 Lesson 6. 4. Users SYS (the DBA), TOM, DICK and HARRY each have an E MPLOYEES table in their schemas. SYS creates a procedure DICK.SEL_EMP using Invo ker's Rights which contains the following code: SELECT ... FROM EMPLOYEES ... ; HARRY now executes the procedure. Which employees table will be queried? Mark for Review (1) Points SYS.EMPLOYEES DICK.EMPLOYEES HARRY.EMPLOYEES (*) None of the above

Incorrect. Refer to Section 9 Lesson 6. 5. What will happen when the following subprogram is compi led? PROCEDURE at_proc IS PRAGMA AUTONOMOUS_TRANSACTION; dept_id NUMBER := 90; BEGIN UPDATE ...

INSERT ... END at_proc; Mark for Review (1) Points The subprogram will fail because it is missing AUTHID CURRENT_USER befor e IS. The autonomous transaction subprogram will fail because it must include COMMIT or ROLLBACK. (*) The compilation will fail because a semicolon after AUTONOMOUS_TRANSACTI ON is not needed. The program will compile successfully.

Correct 6. Which of the following is the correct syntax to create a procedure using Invoker's Rights? Mark for Review (1) Points CREATE PROCEDURE myproc IS AUTHID CURRENT_USER BEGIN ... CREATE PROCEDURE myproc AUTHID CURRENT_USER IS BEGIN ... (*)

CREATE PROCEDURE AUTHID CURRENT_USER myproc IS BEGIN ... CREATE PROCEDURE myproc IS BEGIN AUTHID CURRENT_USER ...

Correct 7. User SALLY's schema contains a NEWEMP table. Sally uses Invoker's rights to create procedure GET_NEWEMP which includes the line: SELECT ... FROM NEWEMP ... ;

Sally also grants EXECUTE privilege on the procedure to CURLY, but no other priv ileges. What will happen when Curly executes the procedure? Mark for Review (1) Points The procedure will execute successfully. The procedure will fail because Curly does not have SELECT privilege on NEWEMP. The procedure will fail because there is no NEWEMP table in Curly's sche ma. (*) The procedure will fail because Curly does not have the EXECUTE ANY PROC EDURE system privilege.

Incorrect. Refer to Section 9 Lesson 6.

Sign up to vote on this title
UsefulNot useful