I have the following table structure that holds error codes and related error messages:
ERR_CODE ERR_MESSAGE
CN001 Invalid Username :USERNM
CN002 Invalid Password :PWD
In my PLSQL code, i would like to dynamically substitute the values for username and password.
I understand that EXECUTE IMMEDIATE can do substitutions by the USING clause but the query has to be static in that case.
I am looking for a flavor similar to execute immediate wherein can do this:
SIMILAR_EXECUTE_IMMDIATE q'{select ERR_MESSAGE from ERROR_MESSAGES where ERR_CODE = 'CN001'}' INTO l_err_msg USING l_curr_user;
OR maybe i can break it down in to 2 steps:
select ERR_MESSAGE into err_msg_var from ERROR_MESSAGES where ERR_CODE='CN001';
EXECUTE_IMMDIATE err_msg_var INTO l_err_msg USING l_curr_user;
Basically, I am trying to reduce the number of steps involved or maybe get a better performing query or approach.
Thanks in advance !