Solved

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

Posted on 2008-10-22
3
5,375 Views
Last Modified: 2013-12-07
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)?
0
Comment
Question by:scpig
  • 3
3 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 125 total points
ID: 22780539
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;
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 22780545
you were missing the parentheses after TRUNC(SYSDATE)  and instead had an extra paretheses at the end of the case
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 22780584
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.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question