Free 1Z0-147 Braindumps


  • Exam Number: 1Z0-147
  • Provider: Oracle
  • Questions: 132
  • Updated On: 17-Nov-2018

QUESTION: 1
Examine this function:

CREATE OR REPLACE FUNCTION CALC_PLAYER_AVG
(V_ID in PLAYER_BAT_STAT.PLAYER_ID%TYPE)
RETURN NUMBER
IS
V_AVG NUMBER;
BEGIN
SELECT HITS / AT_BATS
INTO V_AVG
FROM PLAYER_BAT_STAT
WHERE PLAYER_ID = V_ID;
RETURN (V_AVG);
END;

Which statement wil successfully invoke this function in SQL *Plus?

A. SELECT CALC_PLAYER_AVG (PLAYER_ID)
FROM PLAYER_BAT_STAT;
B. EXECUTE CALC_PLAYER_AVG (31);
C. CALC_PLAYER ('RUTH');
D. CALC_PLAYER_AVG (31);
E. START CALC_PLAYER_AVG (31)
Answer(s): A
Explanation:
A function can be invoked in SELECT Statement provided that the function does not modify any
database tables. The function must use positional notation to pass values to the formal
parameters. The formal parameters must be of the IN mode. They should return data types
acceptable to SQL and they should not include any transaction, session, or system control
statements.
Incorrect Answers are:
B: You can't call a function in this way, in this way you can call a procedure, because function
must return a value, to call a function using EXECUTE command you should declare a bind
variable using the VARIABLE command then assign the value returned from the function to this
variable, in the following way:SQL> VARIABLE v_get_value NUMBERSQL>
C: v_get_value := CALC_PLAYER_AVG (31)PL/SQL procedure successfully completed.SQL>
PRINT v_get_valueV_GET_VALUE----------- 1
Again this way can't be use for calling a function in PL/SQL block because the function return a
value and this values must be assigned to PL/SQL variable or to bind variable. Like this
DECLARE
v_get_from_fn NUMBER; BEGIN v_get_from := CALC_PLAYER_AVG (31); END; /
D: Same as C.
E: v_get_value := CALC_PLAYER_AVG (31)PL/SQL procedure successfully completed.SQL>
PRINT v_get_valueV_GET_VALUE----------- 1
v_get_value := CALC_PLAYER_AVG (31)PL/SQL procedure successfully completed.SQL>
PRINT
V_get_valueV_GET_VALUE----------- 1
v_get_value := CALC_PLAYER_AVG (31)PL/SQL procedure successfully completed.SQL>
PRINT
2

Get The Premium Version

Allbraindumps.com
 Test Questions PDF from Myitguides.com

 Test Questions PDF from Myitguides.com