I'm trying to reference a preceding column
c1 in a default value of another column
c2 in the
xmltable() function, but I get an error: column
c1 does not exist.
SELECT * FROM xmltable( '.' PASSING '<r/>' COLUMNS c1 Text PATH 'name()', c2 Text DEFAULT c1 );
I wonder why, as this precise usage is permitted by the documentation (emphasis's mine):
If the path expression does not match for a given row but
default_expressionis specified, the value resulting from evaluating that expression is used. If no
DEFAULTclause is given for the column, the field will be set to
NULL. It is possible for a
default_expressionto reference the value of output columns that appear prior to it in the column list, so the default of one column may be based on the value of another column.