Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to remove hard coding inside a trigger and fetch the values from a table instead

Priyanka S20 hours ago — edited 18 hours ago

Hi All,

I have a trigger block which executes when there is an insert or update in a table say TableA.

Inside the trigger they are refering hard coded data (we can call as run codes ) .These run codes can vary in range example of 100-150 and there is some logic being executed in trigger based on these run codes sets. Now I am removing these hard coded reference of run code from trigger by addingthese value into a different table -Table B Run codes are comma seperated values.

Run code 1:100,101,102,110,121

Run code 2:122,139

Run code 3:140,145

I currently created 2 variables each for the run codes.

"select run code into var1 from table B where condition 1” .then in next variable Var2 used instr function to see if the run code being referred is present in var1.(In instr I wrapped the values in comma so that they are considered as a single value ) and flagged 1(if present)/0(not avilable ) and used this Var2 in place of hard coded reference in sql block

Kindly suggest if there is any other approach or any issues with the above

Comments
Post Details
Added 20 hours ago
6 comments
67 views