Try it here
Subscribe
PL/SQL PLW-5005

Smarter than PL/SQL Compiler? Test Yourself - PLW-5005

smarter_than_pl/sql_compiler_test_yourself_-_plw-5005

Do you think you are smarter than PL/SQL compiler ?

$IMG0

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.

Writer profile pic

Admin on Apr 20, 2019 at 12:01 am


If you like dEexams.com and would like to contribute, you can write your article here or mail your article to admin@deexams.com . See your article appearing on the dEexams.com main page and help others to learn.



Post Comment

Comments( 0)

WEB TECHNOLOGY

Articles

×

Forgot Password

Please enter your email address below and we will send you information to change your password.