'insert into new column values generated from trigger
I want to create a trigger which generates an 18 digit code based on the value of several other columns in the table.
R-MU-WEST-RJS-9697 So basically my last 4 digit code is the STORE_CODE based on which I want to compare and insert that 18 digit code against it the column named as CODE_18DIGIT
Below is the select statement that generates the code
SELECT 'R-'
|| CASE
WHEN INSTR (TRIM (r.state), ' ') > 1
THEN
SUBSTR (r.state, 1, 1)
|| SUBSTR (r.state, INSTR (r.state, ' ') + 1, 1)
ELSE
UPPER (SUBSTR (r.state, 1, 2))
END
|| '-'
|| UPPER (SUBSTR (r.zone_name, 1, 4))
|| '-'
|| r.format_code
|| '-'
|| SUBSTR (r.store_code, 1, 4)
FROM tbl_rrsoc_store_info r
WHERE r.ISACTIVE = 'Y';
and the table description of tbl_rrsoc_store_info is below
Name Null Type
--------------------------- -------- --------------
RRSOC_ID NOT NULL NUMBER
STORE_CODE NOT NULL NVARCHAR2(55)
STATE NVARCHAR2(55)
CITY NVARCHAR2(55)
CODE_18DIGIT NVARCHAR2(18)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
