TOTAL 50 QUESTIONS
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
DECLARE CURSOR emp_curs IS SELECT * FROM employees;BEGIN FOR emp_rec IN emp_curs LOOP DBMS_OUTPUT.PUT_LINE( -- what goes here ? ); END LOOP;END;
DECLARE CURSOR dept_curs IS SELECT * FROM departments;BEGIN FOR dept_rec IN dept_curs LOOP DBMS_OUTPUT.PUT_LINE(dept_curs%ROWCOUNT || dept_rec.department_name): END LOOP; DBMS_OUTPUT.PUT_LINE(dept_rec.department_id);END;
DECLARE CURSOR c IS SELECT * FROM employees FOR UPDATE; c_rec c%ROWTYPE;BEGIN OPEN c; FOR i IN 1..20 LOOP FETCH c INTO c_rec; IF i = 6 THEN UPDATE employees SET first_name = 'Joe' WHERE CURRENT OF c; END IF; END LOOP; CLOSE c;END;
Which employee row or rows will be updated when this block is executed?
CURSOR c IS SELECT * FROM employees FOR UPDATE WAIT 5;
What will happen when SAEED's session tries to fetch the row that MARY has locked?
DECLARE CURSOR country_curs IS SELECT country_name FROM wf_countries WHERE region_id = 13; v_country_name wf_countries.country_name%TYPE;BEGIN OPEN country_curs; WHILE country_curs%FOUND LOOP FETCH country_curs INTO v_country_name; DBMS_OUTPUT.PUT_LINE(v_country_name); END LOOP; CLOSE country_curs;END;
A FETCH emp_cursor INTO v_empno,v_last_name;B OPEN emp_cursor;C END LOOP;D CLOSE emp_cursor;E LOOP
In which order should you code these statements?
CURSOR country_curs IS SELECT * FROM wf_countries ORDER BY country_name;
There are over 200 rows in the WF_COUNTRIES table, but you want to fetch and display only the first 25 rows.
How would you exit from the FETCH loop?
DECLARE CURSOR emp_cursor IS SELECT employee_id, last_name, salary FROM employees; v_empcurs emp_cursor%ROWTYPE;
What is the data type of V_EMPCURS?
DECLARE CURSOR bigdept_cur IS SELECT * FROM bigdepts; CURSOR bigemp_cur IS SELECT * FROM bigemps;BEGIN FOR dept_rec IN bigdept_cur LOOP DBMS_OUTPUT.PUT_LINE (dept_rec.department_name); FOR emp_rec IN bigemp_cur LOOP IF emp_rec.department_id=dept_rec.department_id THEN DBMS_OUTPUT.PUT_LINE (emp_rec.last_name); END IF; END LOOP; END LOOP;END;
Why is this code inefficient?
DECLARE v_dept_rec departments%ROWTYPE;...
<< outer>>DECLARE v_myvar NUMBER;BEGIN v_myvar := 25; DECLARE v_myvar NUMBER := 100; BEGIN outer.v_myvar := 30; v_myvar := v_myvar / 0; outer.v_myvar := 35; END; v_myvar := 40;EXCEPTION WHEN ZERO_DIVIDE THEN DBMS_OUTPUT.PUT_LINE(v_myvar);END;
DECLARE e_not_null EXCEPTION;BEGIN PRAGMA EXCEPTION_INIT(e_not_null, -1400); INSERT INTO departments (department_id, department_name) VALUES(null, 'Marketing');EXCEPTION WHEN e_not_null THEN DBMS_OUTPUT.PUT_LINE('Cannot be null');END;
BEGIN add_dept;END;
CREATE OR REPLACE PROCEDURE emp_proc IS v_salary employees.salary%TYPE;BEGIN SELECT salary INTO v_salary FROM employees WHERE employee_id = 999; DBMS_OUTPUT.PUT_LINE('The salary is: ' || v_salary);END;
SELECT first_name, last_nameFROM employeesWHERE avg_ann_sal(20) > 15000;
PROCEDURE at_proc IS PRAGMA AUTONOMOUS_TRANSACTION; dept_id NUMBER := 90; BEGIN UPDATE ... INSERT ... END at_proc;
CREATE OR REPLACE PROCEDURE parent ISBEGINchild1;child2;END;You now want user JOE to be able to invoke PARENT. Which of the following gives JOE the privileges he needs, but no unnecessary privileges?
SELECT ... FROM usera.employees ...;
USERC needs to execute UserB's procedure. What privileges are needed for this to work correctly? (Choose two.)
A Re-execute the code until it compiles correctlyB Write the code containing the CREATE or REPLACE FUNCTION followed by the function codeC Test the function from a SQL statement or an anonymous blockD If the function fails to compile, correct the errorsE Load the code into Application ExpressF Execute the code in Application Express
What is the correct order to perform these steps?
Which Data Dictionary views are updated automatically?
Comments
Post a Comment