PLS-00306: wrong number or types of arguments in call to 'TO_CHAR '
693688Apr 7 2009 — edited Apr 7 2009Hi guys, I am learning Pl/SQL. Trying to write a simple function which calculates some dates. It takes contract_date and determines the date of the following Sunday.
My code current has the compiler error: PLS-00306: wrong number or types of arguments in call to 'TO_CHAR 'which I believe has to do with the to_char(trunc(contract_date,'D')) := contract_weekday;
I do not understand what is wrong with my statement there..
Here is my code: Thanks for any help!
show errors
create or replace FUNCTION
contract_dates(contract_date IN DATE)
RETURN DATE
IS
starting_sunday DATE;
--ending_saturday DATE := starting_sunday + 6;
contract_weekday varchar(32);
days_add NUMBER;
BEGIN
to_char(trunc(contract_date,'D')) := contract_weekday;
case contract_weekday
when 1 then days_add := 6;
when 2 then days_add := 5;
when 3 then days_add := 4;
when 4 then days_add := 3;
when 5 then days_add := 2;
when 6 then days_add := 1;
else days_add := 7;
end case;
starting_sunday := contract_date + days_add;
RETURN to_date(starting_sunday);
END;