Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Is the PL/SQL GOTO statement deprecated and should not be used?

SebaVastaMar 20 2022

I love the GOTO statement and have been using it for ages.
I love it because it reduces the number of IF statements. This makes reading code easier IMHO.
I also like it in functions when the function has many return statements in many places. I just put the return value into a variable do a a GOTO to the last line, and so have only one return statement.
However, I join a new company and used this and was told by senior developer during peer review not to use it. Apparently the DBA who deploys the code to the other environments sometimes reads code and he does not like GOTO statements. So I had to remove the GOTO and put IF/ELSE.
The weird thing is , the senior developer has been with the company for 20 years and the DBA only 11 years. But the developer is worried about what the DBA has to say about code.
Since I was new I had no choice so I recoded with IF/ELSE.
My question is, is the GOTO statement not be used in PL/SQL??
Is it deprecated?
Should you use IF instead of GOTO??
Or is there nothing wrong with using GOTO??

Comments
Post Details
Added on Mar 20 2022
16 comments
1,678 views