Home » SQL & PL/SQL » SQL & PL/SQL » Error with a function
Error with a function [message #242893] Tue, 05 June 2007 07:46 Go to next message
jordivos
Messages: 2
Registered: June 2007
Junior Member
Hi all,

I'm having some issues with a function and hope you can help me out.

I'm using the Oracle Database Server 10g Release 2 and APEX 3.0

I'm getting the following error while compiling the function:

Error at line 30: PLS-00103: Encountered the symbol ";" when expecting one of the following:

   if
1. create or replace function get_hc_planned (
2.   period in number, clsname in varchar2)
3. return number
4. as
5.   planned number;


This is the function:

create or replace function get_hc_planned (
  period in number, clsname in varchar2)
return number
as
  planned number;
  amount number;

begin
  select count(pmg_hc_planned) into planned
  where cls_name = clsname
  and get_fy(pmg_period) = get_fy(period)
  and substr(pmg_period, 5, 2) = '08';
  
  if substr(period, 5, 2) = '08'
  then
    amount := (planned - number_of_employees_cluster(clsname, period)) 
    / 12 + number_of_employees_cluster(clsname, period);

  elsif substr(period, 5, 2) = '07'
  then  
    amount := planned;

  else
    amount:= (planned - number_of_employees_cluster(clsname, period))
    / 12 + (planned - number_of_employees_cluster(clsname, period)) 
           / 12 + number_of_employees_cluster(clsname, period);
  endif;

  return amount;
end;


I'm calling other functions in the function so I may have to give more input about those, but leave it like this because it may be something simple..

Thanks in advance,

Jordi
Re: Error with a function [message #242900 is a reply to message #242893] Tue, 05 June 2007 08:06 Go to previous messageGo to next message
jordivos
Messages: 2
Registered: June 2007
Junior Member
I already found the problem.

It's 'end if' not endif'

Didn't see the mistake..
Re: Error with a function [message #242904 is a reply to message #242893] Tue, 05 June 2007 08:07 Go to previous message
techno
Messages: 44
Registered: October 2003
Member
the key word endif should be end if in your code

regards

Techno
Previous Topic: enable and diasable of constraints
Next Topic: output in pl/sql
Goto Forum:
  


Current Time: Sat Dec 03 22:22:22 CST 2016

Total time taken to generate the page: 0.07099 seconds