DB Fetch names and replacement var conflicts
Posted: Thu Nov 09, 2023 5:40 pm
We have some general purpose routines that fetch a user-specified list of variables from a database. Unfortunately some of the variables in the database can have the % character in them, which leads to some undesirable conflicts with program variables:
The only viable workaround I have found for this so is replace the "%" with "?"
I was a little surprised the recursive replacements aren't a bit more intentional by requiring the curly braces in the string like:
Just noting in case anyone runs into this.
Code: Select all
%A = "some unrelated variable"
%VAR_TO_FETCH = "IR%AC*"
fetch {%VAR_TO_FETCH} ' Attempts to fetch "IRsome unrelated variableC" -- if I don't do the replacement then I get an error because of the * wildcard.
Code: Select all
%A = "some unrelated variable"
%VAR_TO_FETCH = "IR%AC*"
%VAR_TO_FETCH = @replace(%VAR_TO_FETCH,"%","?")
fetch {%VAR_TO_FETCH} ' Attempts to fetch "IRsome unrelated variableC"
Code: Select all
%A = "[INTENDED_SUBSTITUTION]"
%VAR_TO_FETCH2 = "IR{%A}C*"