Now take a look at above code and find out what's wrong with the code.
After your analysis, you have decided what's wrong with code, let's find out what PL/SQL compiler will tell us.
I am going to enable warning in my SESSION using below code
ALTER SESSION SET plsql_warnings = 'enable:all'
Now this one will not only give compiler error but also feedback how can I improve my function.
So I compile the function and I get some interesting feedback
[Warning] PLW-05005:subprogram WHATS_WRONG returns without value at line 21.
Now line 21 is the last line of the function, so its not actually telling where in function there is a gap in the logic, it simply telling me that by the time I am at line 21, there is a possibility that a return statement may not be executed. So I get a function returns without value.
Now you probably have figured it out that there a return at line 13 and at line 16 but there is no return at line 18.
In the simple program it's not hard to find this but in a real code with hundreds of thousands of lines it can be very difficult to sort it out.
So in this case compile time warning system tells me automatically if I have my warnings enabled.
Did you sort it out ? I hope you did. If not or in any case I encourage you to automatically turn on warnings in SQL developer.
If you like dEexams.com and would like to contribute, you can also write your article here or mail your article to firstname.lastname@example.org . See your article appearing on the dEexams.com main page and help others to learn.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.