Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> PROBLEM WITH CREATING A FUNCTION
Hi
Bit of a PL/SQL newbie here. Could anyone tell me what's wrong with
this code? I'm gettin a message telling me that the "ELSE" is
unexpected. I want to call this function in a pass-thru query. The
returned rows will have a value for the progress_code, event_code, and
live_weeks, and based on these values I want to get a value for
expected_hours:
CREATE FUNCTION exp_hrs
(fes_progress_code STRING, event_code STRING, live_weeks NUMBER) RETURN NUMBER IS expected_hours NUMBER; BEGIN IF fes_progress_code = 'S' then SELECT COUNT(stud_attend_and_prog.event_code) * AVG(live_weeks) INTO expected_hours ELSE SELECT COUNT(stud_attend_and_prog.event_code) * week_num INTO expected_hours; RETURN (expected_hours);