Solved

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

Posted on 2008-10-22
3
5,294 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now