3.3. Supplying Backward Compatibility

Having created a very flexible twice function and tested it successfully with my new UPPER-lower and lower-UPPER requirements, I can now step back into the stream of application development. (I consider work on twice as part of the process of building my generic PL/SQL toolset.) So I continue to code and, after a while, come back to one of my earlier uses of twice:

v_prodtype:= twice (UPPER (v_prodtype));

While I don't change this line of code, I do have to modify others in the same procedure. I then recompile that procedure and am shocked to get this error:

PLS-00306: wrong number or types of arguments in call to 'TWICE'

Suddenly code that was working earlier in the day is no longer even able to compile. What went wrong?

When I enhanced the twice function, I added a second parameter—and I certainly needed to do that. I did not, unfortunately, take into account existing uses of twice. The way that I changed the parameter list actually invalidated those prior instances. Since I did not provide a default value for the action_in parameter, it became necessary for all executions of twice to include two values in the argument list. This is an unacceptable way to enhance existing code.

If I am going to make changes to programs currently in use across my production applications (or in any version of previously existing programs), I want to do so in a way that allows that code to continue to work as it did before without any changes. Otherwise ...

Get Advanced Oracle PL/SQL Programming with Packages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.