"Jonathan Ellis" <jellis@advocast.com> writes:
> I have a pl/tcl function that doesn't work, but the same function in a
> plain-vanilla tcl script does. (The function emulates Oracle's "replace"
> function.)
> bf2=# create function replace2 (varchar, varchar, varchar) returns varchar
> as '
> regsub -all {&} "$3" {\\\&} 3
> regsub -all {\\[0-9]} "$3" {\\\0} 3
> eval "regsub -all \{$2\} \{$1\} \{$3\} rval"
> return $rval
> ' language 'pltcl';
Those backslashes all need to be protected by backslashes ...
the SQL parser will strip off one level of backslashing as it parses
the command.
regards, tom lane