Oracle Database: Program with PL/SQL — Question 7
Examine this Java method in class Employee, loaded into the Oracle database:
Public static int updateSalary (String name, float salary) {}
Which PL/SQL specification can be used to publish this method?
Answer options
- A. CREATE FUNCTION update_salary (p_nm VARCHAR2, p_sal NUMBER) RETURN PLS_INTEGER AS LANGUAGE JAVA LIBRARY "Employee" NAME "updateSalary" PARAMETERS (p_nm java.lang. String, p_sal float, RETURN int);
- B. CREATE FUNCTION update_salary (p_nm VARCHAR2, p_sal NUMBER) RETURN PLS_INTEGER AS LANGUAGE JAVA NAME "Employee.updateSalary" PARAMETERS (p_nm java.lang.String, p_sal float, RETURN int);
- C. CREATE FUNCTION update_salary (p_nm VARCHAR2, p_sal NUMBER) RETURN PLS_INTEGER AS LANGUAGE JAVA NAME "Employee.updateSalary" PARAMETERS ("name" java.lang.String, "salary" float, RETURN int);
- D. CREATE FUNCTION update_salary (p_nm VARCHAR2, p_sal NUMBER) RETURN PLS_INTEGER AS LANGUAGE JAVA NAME Employee.updateSalary (java.lang.String, float) return int;
- E. CREATE FUNCTION update_salary (p_nm VARCHAR2, p_sal NUMBER) RETURN PLS_INTEGER AS LANGUAGE JAVA
Correct answer: C
Explanation
Option C is the correct answer because it correctly specifies the method name with the appropriate Java parameters and follows the PL/SQL syntax. Options A and B incorrectly use 'LIBRARY' or have the wrong method naming convention, while option D does not adhere to the correct parameter naming convention. Option E is incomplete as it does not provide the necessary details for parameterization.