How to upgrade are the value of the column and the new column value created

Hi all

create the table xxc_temp

as

Select donnees_1 'AB103', 'AAA' data_2 data_3 '123', 'RED' data_4, NULL status in all the double union

Select donnees_1 'AB105', 'BBB' data_2, '222' data_3, data_4 'BLUE', NULL status in all the double union

Select donnees_1 'AB106', 'CCC' data_2, '333' data_3, data_4 'BLUE', the double NULL status

create the table xxc_base

as

Select donnees_1 'AB103', 'AAA' data_2, '123' data_3 data_4 'RED', 'Inactive' status of Union double all the

Select donnees_1 'AB105', 'BBB' data_2, '222' data_3 data_4 'BLUE' status 'Active' of all the double union

Select donnees_1 'AB106', 'CCC' data_2, '333' data_3, data_4 'BLUE', 'Inactive' status of double

I need to update the status column xxc_temp with xxc_base value of the status column and also if the user tries to insert new values/lines in the xxc_temp

So how can I update the status column? I mean automatically set to day and also new values/lines

I need to update only that are Inactive then these lines should be updated in the temporary table

We can do this by using the stored function, but I need to update the new status of lines also

Please help me

Here's another way to do it, using VIRTUAL function column as expression to get the status of the other table

CREATE or REPLACE FUNCTION GET_STATUS (pDATA_1 IN TANK) RETURN VARCHAR2 DETERMINISTIC

AS

vstatus VARCHAR2 (8);

BEGIN

SELECT status in vstatus FROM xxc_base WHERE donnees_1 = pDATA_1;

RETURN vstatus;

END;

/

DROP TABLE 'XXC_TEMP ';

CREATE TABLE 'XXC_TEMP '.

('DONNEES_1' CHAR (5),

"DATA_2" TANK (3).

"DATA_3" TANK (3).

"DATA_4' VARCHAR2 (4).

'STATUS' VARCHAR2 (8) GENERATED ALWAYS AS (SUBSTR (GET_STATUS (DATA_1), 1, 8)) VIRTUAL

) ;

INSERT INTO 'XXC_TEMP' (data_3, donnees_1, data_2, data_4))

Select "AB103' donnees_1, data_2 'AAA', '123' data_3, 'RED' data_4 of any double union

Select donnees_1 'AB105', 'BBB' data_2, '222' data_3 data_4 'BLUE' of all the double union

Select donnees_1 'AB106', 'CCC' data_2 data_3 '333', 'BLUE' double data_4);

Tags: Database

Similar Questions

Maybe you are looking for