i'm a beginner at pl-sql and i am trying to write a code of a function to read in a coursename and display the lecturerName, coursename, and the title for which matches with the coursename.
However i am unable to get a decent output disregarding the different methods which i've tried, and i have gotten quite a few different error, currently below is the code that is able to compile but does not give any results.
Can anyone help me with this function and tell me where did i go wrong?.
Set echo on
set serveroutput on
CREATE OR REPLACE FUNCTION Courses(coursename IN VARCHAR2) RETURN VARCHAR2
IS
results VARCHAR2(100);
l VARCHAR2(30);
c VARCHAR2(30);
t VARCHAR2(30);
BEGIN
FOR course IN(select lecturerName, coursename, title into l,c,t from course where Coursename = coursename)
LOOP
results := results || l || c || t;
END LOOP;
RETURN results;
END Courses;
/
SELECT Courses('SQL') from dual;
Courses('SQL')