PL/SQL Parameters   «Prev  Next»

Procedures, Functions, Cursors, and Parameters - Quiz

Each question is worth one point. Select the best answer or answers for each question.
 
1. Examine the following code snippet. Which line has a syntax error?
1 DECLARE
2 CURSOR READ_CUSTOMER
3  (I_CITY OUT NUMBER,  I_STATE VARCHAR2 := 'CA')
4  AS SELECT FIRSTNAME, LASTNAME
5  FROM CUSTOMER
6  WHERE CUST_ID = I_CITY  AND STATE = I_STATE;

Please select the best answer.
  A. Line 2
  B. Line 3
  C. Line 4
  D. Line 6

2. Why might you convert an existing procedure into a function?
Please select the best answer.
  A. A procedure with only one OUT variable should always be a function.
  B. A function is more efficient than a procedure.
  C. Functions can use default values in the parameters.
  D. Unlike a procedure, a function can be used within a query.

3. You wish to define a procedure that accepts an incoming number, an incoming date, and a date that is brought in and returned after making changes to it if needed. In addition, a number is returned that is set by the procedure. Which code snippet best satisfies these requirements?
Please select the best answer.
  A.
CREATE PROCEDURE DOES_SOMETHING
(P1 IN NUMBER, P2 IN DATE, P3 OUT DATE, P4 OUT NUMBER) AS....
  B.
CREATE PROCEDURE DOES_SOMETHING
(P1 OUT NUMBER, P2 IN OUT DATE, P3 IN DATE, P4 IN NUMBER) AS....
  C.
CREATE PROCEDURE DOES_SOMETHING
(P1 IN OUT NUMBER, P2 IN OUT DATE, P3 IN DATE, P4 IN NUMBER) AS....
  D.
CREATE PROCEDURE DOES_SOMETHING
(P1 IN NUMBER, P2 IN OUT DATE, P3 IN DATE, P4 IN NUMBER) AS.....

4. Examine the following snippet of a procedure's definition. Which two commands correctly call the procedure from within a PL/SQL block?
CREATE OR REPLACE PROCEDURE MY_NEW_CAR
(I_MODEL IN VARCHAR2, O_PRICE OUT NUMBER,
I_COLOR IN VARCHAR2 := 'WHITE' , 
I_YEAR IN NUMBER DEFAULT '2000', ) AS 
Please select all the correct answers.
  A.
MY_NEW_CAR('ROLLS ROYCE', V_PRICE, 'GOLD', '1999');
  B.
MY_NEW_CAR('ROLLS ROYCE', 'GOLD'=>I_COLOR, V_PRICE =>O_PRICE);
  C.
MY_NEW_CAR('GOLD'=>I_COLOR, '1999'=>I_YEAR, 'ROLLS ROYCE'=> I_MODEL);
  D.
MY_NEW_CAR('ROLLS ROYCE', 'GOLD', '1999', V_PRICE,=>O_PRICE);