Does PL/SQL support pointers, aliases, or references? I'm writing code for an environment I also support, and I'm trying to design it to handle future changes.

The current requirement is that two fields should be identical, but I used to be a user of the software I'm supporting, and I have a hunch there may be a requirement to separate the two fields at some point.

Let's start with this example:

DECLARE
   x_ VARCHAR2(32767);
BEGIN
   x_ := 'ABC';
   do_thing_1(x_);
   do_thing_2(x_);
END;


If someone changes their mind on the spec, I'll have to rewrite it like the code below.

DECLARE
   x_ VARCHAR2(32767);
   y_ VARCHAR2(32767);
BEGIN
   x_ := 'ABC';
   y_ := 'DEF';
   do_thing_1(x_);
   do_thing_2(y_);
END;


So, I have a couple of bad options. (1) I could write the code today for the original spec I have in my hands now, or (2) I could write the code with redundant variables to handle the changes I suspect are coming.

The problem with option (1) is that I'll have to rip out what I've done later, and some of the design intent I have in my head today will be lost without a lot of verbose documentation. The problem with option (2) is that, if the changes never come, the redundant variables amount to dead code, and memory and logical reads will be wasted during run time. Option (2) would be equivalent to passing a function argument by value when a reference parameter would be more efficient. Option (2), from a developer's perspective, is partially a violation of the DRY principle, too.

-- Change never materialized. x_ and y_ are redundant.
DECLARE
   x_ VARCHAR2(32767);
   y_ VARCHAR2(32767);
BEGIN
   x_ := 'ABC';
   y_ := 'ABC';
   do_thing_1(x_);
   do_thing_2(y_);
END;


Does something like this exist?

DECLARE
   x_ VARCHAR2(32767);
   y_ DBMS_POINTER_THINGY.REFERENCE;
BEGIN
   x_ := 'ABC';
   y_ := DBMS_POINTER_THINGY.POINTER_TO(x_);
   do_thing_1(x_);
   do_thing_2(y_);
END;


If I use a DEFINE, I'll lose the magic when it goes server-side.

If I use conditional compilation, can I assign a value to a directive within my code without having to set it at the session level?

DECLARE
   x_ VARCHAR2(32767);
   -- something defining $$y_ here?
   $$y_ := x_
BEGIN
   x_ := 'ABC';
   do_thing_1(x_);
   do_thing_2($$y_);
END;
Since it is a database you can create a table with key and value. You can create a package that has a CONSTANT which points to a key. You can create a function that takes a key and returns a value from your key/value table. Then you would just look up and use that values from the key/value table and rather than changing code you change data.