Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Debug the following View FUNCTION Statement. Use the Virtual Machine you have be

ID: 3908494 • Letter: D

Question

Debug the following View FUNCTION Statement. Use the Virtual Machine you have been provided to do this. List everything that you had to do in order to fix it. Only list the line that was fixed and what you did to it.

The code for the Function is as follows:

CREATE OR REPLACE FUNCTION Final_Function (v_Name VARCHAR2, v_types VARCHAR2) RETURN VARCHAR2 IS

V_A_Name VARCHAR2(32);

BEGIN

IF Upper(v_type) = 'LAST' THEN

select (substr(v_name,(instr(v_name,' ',1)+1),Length(v_name)- instr(v_name,' ',1))) into v_A_Name

from dual;

ELSIF Upper(v_Type) = 'FIRST' THEN

select (substr(v_name,1,(instr(v_name,' ',1)-1))) into v_A_name

from dual;

ELSE

RETURN 'Error';

END IF;

Return v_As_Name;

END Final_Function;

Explanation / Answer

Hi Sir, After debugging the code, please find the errors and the correct implementation for the same errors:-

ERROR:- CREATE OR REPLACE FUNCTION Final_Function (v_Name VARCHAR2, v_types VARCHAR2) RETURN VARCHAR2 IS

FIX:-  CREATE OR REPLACE FUNCTION Final_Function (v_Name IN VARCHAR2, v_types IN VARCHAR2) RETURN VARCHAR2 IS [U should mention the Mode of Params being passed IN/OUT/IN OUT]

ERROR:- RETURN 'Error';

FIX:-  v_A_name = 'Error'; [Remember, you should return only at the end of function and return only 1 value ie Return v_As_Name;]

Please let me know in case of any clarifications required. Thanks!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote