CREATE FUNCTION get_id(NAME IN
Courses.NAME%TYPE ,COURSE_ID_O[] OUT ARRAY )
RETURN COURSE_ID_O
BEGIN
IF NAME LIKE '_J%' OR NAME LIKE '_Z%'
THEN
SELECT COURSE_ID INTO COURSE_ID_O FROM
COURSES WHERE COURSE_NAME=NAME ;
ELIF NAME='' OR NAME=NULL
THEN
DBMS_OUTPUT.PUT_LINE('Please enter a valid string.');
END IF
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No record found If it is blank
or null: Please input a valid string');
END EXCEPTION
END
You might refer the correct syntax but for the above as general case it means the function get_id will take name and will return course_id_o array as there are multiple rows in it as O/p if the input course name is J then it will print else the default error message.
4
solved Proper formatting of an SQL function using Workbench [closed]