Section 9 Quiz

Share Embed Donate


Short Description

Oracle Academy...

Description

Section 9 Quiz (Answer all questions in this section) 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;

Mark for Review (1) Points

Which of the following will execute successfully? SELECT upd_dept(80) FROM dual; SELECT upd_dept(department_id) FROM employees; DELETE FROM departments WHERE department_id = upd_dept(department_id); DELETE FROM employees WHERE department_id = upd_dept(80); (*) Correct 2. The function avg_ann_sal returns the average annual salary for a particular department. The example below is a valid use of this function. True or False?

Mark for Review (1) Points

SELECT first_name, last_name FROM employees WHERE avg_ann_sal(20) > 15000; True (*) False

Correct 3.  A benefit of user-defined functions is that the function can accept any SQL or PL/SQL data type. True or False?

Mark for Review (1) Points

True False (*)

Correct

4. How do you specify that you want a procedure MYPROCA to use Invoker's Rights?

Mark for Review (1) Points

Invoker's Rights are the default, therefore no extra code is needed. CREATE OR REPLACE PROCEDURE myproca  AUTHID OWNER IS... GRANT INVOKER TO myprocA;  ALTER PROCEDURE myproca TO INVOKER; CREATE OR REPLACE PROCEDURE myproca  AUTHID CURRENT_USER IS... (*) Correct 5. What will happen when the fo llowing procedure is executed? PROCEDURE log_usage (p_card_id NUMBER, p_loc NUMBER) IS PRAGMA AUTONOMOUS_TRANSACTION BEGIN INSERT INTO log_table (card_id, location, tran_date)  VALUES (p_card_id, p_loc, SYSDATE); COMMIT; END log_usage; The subprogram will fail because it is missing AUTHID CURRENT_USER before IS. The subprogram will fail because the PRAGMA statement must be before IS. The compilation will fail b ecause a semicolon after AUTONOMOUS_TRANSACTION is required. (*) The program will compile successfully.

Correct 6. You want to display the names of all tables in your schema, but you have forgotten which Dictionary view to query. Which of the following will remind

Mark for Review (1) Points

Mark for Review (1) Points

you of the name of the correct Dictionary view? SELECT * FROM USER_OBJECTS WHERE table_name LIKE '%TABLE%'; SELECT * FROM DICTIONARY WHERE table_name LIKE 'USER%TAB%'; (*) HELP DICTIONARY SELECT * FROM DICTIONARY WHERE table_name LIKE 'user%table%'; SELECT * FROM DICTIONARY WHERE table_name LIKE 'DBA%TABLE%'; Correct 7. User JOHN wants to see the names of all the tables in his schema. He does NOT want to see the names of any tables in other users' schemas. Which Dictionary view should he query?

Mark for Review (1) Points

JOHN_TABLES DBA_TABLES USER_TABLES (*)  ALL_TABLES DICTIONARY 

Incorrect. Refer to Section 9 Lesson 3. 8. Which of the following statements about the "super-view" DICTIONARY is true?

Mark for Review (1) Points

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

9.  You want to see the names, modes, and data types of the formal parameters of function MY_FUNC in your schema. How can you do this? (Choose two)

Mark for Review (1) Points

(Choose all correct answers) Query USER_FUNCTIONS Query USER_PARAMETERS DESCRIBE my_func; (*) SHOW PARAMETER my_func; Query USER_SOURCE (*)

Correct 10. Which view would you query to see the detailed code of a procedure?

Mark for Review (1) Points

user_objects user_procedures user_dependencies user_source (*) user_errors

Correct 11. To create a function successfully, the following steps should be performed.  A Reexecute the code until it compiles correctly B Write the code containing the CREATE or REPLACE FUNCTION followed by the function code C Test the

Mark for Review (1) Points

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?  A,B,E,F,D,C D,B,E,F,A,C B,E,F,D,A,C (*) B,C,E,F,D,A 

Correct 12. 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 fol lowing 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? v_mynum := find_sal(100); (*) find_sal(100,v_mynum);

Mark for Review (1) Points

find_sal(v_mynum,100); v_mydate := find_sal(100);

Correct 13.  A function must have at least one IN parameter, and must return exactly one value.

Mark for Review (1) Points

True False (*)

Incorrect. Refer to Section 9 Lesson 1. 14.  You have created a function called USEFUL. You want every database user to be able to invoke the function. Which command would you use to do this?

Mark for Review (1) Points

GRANT EXECUTE ON useful TO PUBLIC; (*) GRANT TO PUBLIC EXECUTE ON useful; GRANT useful TO PUBLIC; GRANT EXECUTE ON useful TO *; GRANT useful TO WORLD;

Correct 15.  You want to allow user JOE to query the CD_DETAILS table in your schema. Which command should you use?

Mark for Review (1) Points

GRANT cd_details TO joe; GRANT SELECT ON cd_details TO joe; (*) GRANT SELECT TO joe ON cd_details; GRANT QUERY ON cd_details TO joe; GRANT SELECT ON joe TO cd_details;

Correct

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF