Link to home
Start Free TrialLog in
Avatar of scpig
scpig

asked on

PL/SQL: ORA-00909: invalid number of arguments

I have a query that I get this error: PL/SQL: ORA-00909: invalid number of arguments
The purpose of this query is:
-- If execution (current) date is MON then get previous THU into v_begin_date.
-- If execution (current) date is THU then get previous MON into v_begin_date.
-- v_end_date is set to previous day.
-- date range will be THU through SUN for a MON execution.
-- date range will be MON through WED for a THU execution.

SELECT NEXT_DAY(TRUNC(SYSDATE,
  CASE TO_CHAR(SYSDATE, 'DY') WHEN 'MON' THEN 'THU' ELSE 'MON' END)) -7,
  TRUNC(SYSDATE-1) INTO v_begin_date, v_end_date FROM dual;

What do I do wrong for this query (PL/SQL: ORA-00909: invalid number of arguments)?
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sean Stuber
Sean Stuber

you were missing the parentheses after TRUNC(SYSDATE)  and instead had an extra paretheses at the end of the case
also note your "if" conditions and your case don't quite match.

the case as written does
if today is Monday then return previous Thursday
otherwise return previous Monday  (no special check for Thursday)

your if's didn't have a condition described for days other than Monday or Thursday.