I have prepared a trigger where the column name is in a variable:
m_FldName := 'ALTID';
Now I need to use something like "DBMS_OUTPUT.PUT_LINE(:NEW.m_FldName)", much like a macro substitution. How can I achieve this?
To use the variable value, just use the variable name. In your example, the code would look like the following:
The ":NEW." is not necessary in this case.
But using DBMS_OUTPUT in a trigger does not make sense. In order for DBMS_OUTPUT to make sense, there must be something that will capture that output. Calls to DBMS_OUTPUT from a trigger will write the data to a dead end, and you'll never see the output. I'm not sure what you are trying to do here, so I really can't give you any advice on how to change this specific line of code.
Dig Deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.