Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PLS-00306: wrong number or types of arguments in call to 'TO_CHAR '

693688Apr 7 2009 — edited Apr 7 2009
Hi 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;
This post has been answered by Hoek on Apr 7 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 5 2009
Added on Apr 7 2009
10 comments
2,444 views