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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access