I am creating a trigger in oracle which gets triggered before any insert statement. I want to insert a value in column2 using that trigger, but the problem is, I have to first get the the value of another column which is column 1 , of the new row being inserted and based on that value ,I will write business logic to insert the value in column2.
I am unable to access the value of column1 for the new row which will be inserted. How can I access the values of the new row being inserted.
Scenario is like this: Value for column2 has to be inserted using trigger. But, to popluate value in column2 , first value for column1 from the row which is going to be inserted, is required. and Based on the value of column1, value for column2 will be calculated and inserted. Please help me with syntax and proper resolution.
Use Case is:
Suppose column1 value is TS-1 then column2 value has to be TS-1-1, for the next time column2 value will be TS-1-2 and so on. SO there could be multiple values for TS-1 in the table, and for that every time vales for column2 will increase as TS-1-,TS-1-2, TS-1-3 and so on, last digit gets incremented for column2.
So I will have the fetch the maximum value of last number getting incremented and increase it by 1 for each insert.
Please help