简体   繁体   中英

how to fix ORA-06575: Package or function is in an invalid state error

I'm looking to create a package, already have a working procedure. Working on a function, step by step and I have encountered a 'ORA-06575: Package or function PROJECT_LENGTH is in an invalid state' error.

The aim of this is to eventually be able to show how long my project lasted, from startdate to enddate in months. How do I fix this issue?

I have tried various different approaches and examples. I have checked all variables are correct.

create or replace FUNCTION project_length   
    (startDate IN DATE,   
    endDate IN DATE)   
return number   
is   
begin   
return floor(months_between(startDate,endDate)/12);   
end;   
/

TESTING

SELECT  projectname, project_length(startDate,endDate)  
FROM project 
WHERE project_length(startDate,endDate) > 0; 

I'm expecting an output which will consist of the projectName and Project Length, displaying the amount of months a project took

Just use

alter function project_length compile;

This issue occurs one of the dependent objects got a DDL on it. Perhaps you have a statement inside this function, not revealed here , referencing the table project and recently a column added to the table project ( a DDL applied to the table )

Actually there's no dependent object in the code presented here. So something must be missing in this function's code.

I found this error also comes up when there is a syntax error in your function. Debug it step by step until it actually works. Weird that compiler does not validate the syntax when you create the function...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM