We help IT Professionals succeed at work.
Get Started

Invalid identifier when calling a function in oracle

nguki
nguki asked
on
7,882 Views
Last Modified: 2013-12-18
Hello,
I keep getting the ORA-00904 Invalid identifier error when I call my function in Oracle.
I'm wondering if oracle is being picky with dates and strings.

I have tried multiple combinations with passing the date instead of the string using to_date('01-JUN-2010','DD-MON-YYYY') in my function call and changing the input on the function to (fromdate IN DATE) with no luck

here is the call:
select .., fn_myfunction('01-JUN-2010') as Days_Unread from tablename;

here is my function:
CREATE OR REPLACE  FUNCTION fn_myfunction
 (fromDate IN varchar2
  )
 RETURN NUMBER
IS
countval number;
BEGIN
select count(*) into countval
    from (select rownum rnum
         from tablename
          where rownum <= to_date(sysdate) - to_date(fromDate)+1
          )
    where to_char( to_date(fromDate)+rnum-1, 'DY' ) not in ( 'SAT', 'SUN' );
    return countval;
END;
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE