How to create the correct trigger instead of insert or update? ORACLE. Trigger. pl/sql

The tables look like this.

 CREATE TABLE Users(id_user INTEGER GENERATED ALWAYS AS IDENTITY(START with 1 INCREMENT by 1 NOCACHE) PRIMARY KEY,
                surname VARCHAR2(30) NOT NULL,
                name VARCHAR2(30) NOT NULL,
                patronymic VARCHAR2(30) NULL,
                tel_no VARCHAR2(17) NOT NULL,
              
                CONSTRAINT ch_telno_users
                           CHECK(REGEXP_LIKE(tel_no, '^\+375\(\d{2}\)\d{3}-\d{2}-\d{2}$')),
                CONSTRAINT uni_telno_users
                           UNIQUE(tel_no)
                 );


CREATE TABLE Software(id_sw INTEGER GENERATED ALWAYS AS IDENTITY(START with 1 INCREMENT by 1 NOCACHE) PRIMARY KEY,
                  name_sw VARCHAR2(40) NOT NULL,
                  version VARCHAR2(10) NULL,
                  license_period VARCHAR2(10) NOT NULL,
                  id_mfr INTEGER NOT NULL,
                  release_date DATE NOT NULL,
                  price NUMBER(9,2),
                  total_amount INTEGER NOT NULL,
                CONSTRAINT id_mfr_fk
                           FOREIGN KEY(id_mfr)
                           REFERENCES Manufacturer,           
                  );

    CREATE SYNONYM sw for Software;


CREATE TABLE Sales(id_sale INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
               id_user INTEGER NOT NULL,
               id_sw INTEGER NOT NULL,
               quantity INTEGER NOT NULL,
               total_cost NUMBER(9,2),
               order_date DATE NOT NULL CHECK (order_date >= to_date('01/01/2019', 'dd/mm/yyyy')),
               expiration_date DATE NOT NULL,
             CONSTRAINT id_user_fk
                        FOREIGN KEY(id_user)
                        REFERENCES Users,
             CONSTRAINT id_sw_fk
                        FOREIGN KEY(id_sw)
                        REFERENCES Software
            );

The view itself looks like this

    CREATE OR REPLACE VIEW SalesView AS
    SELECT Sales.id_sale,sw.name_sw||' '||sw.version sw_full_name,        
    Users.surname||' '||Users.name||' '||Users.patronymic user_full_name,  
    sales.quantity,         sales.order_date
    FROM sw INNER JOIN (Users INNER JOIN Sales ON Sales.id_user = Users.id_user)  ON sw.id_sw = sales.id_sw;

I tried to create a trigger like this. But for some reason it is not created.( Error at line 86: PL/SQL: SQL Statement ignored Error at line 94: PL/SQL: ORA-00917: missing comma)

it seems to me that I went the hard way. help fix this code.

    CREATE OR REPLACE TRIGGER sales_view_instead_of_trig INSTEAD OF
    UPDATE OR INSERT ON salesview
    FOR EACH ROW
      DECLARE
      sw_new        sw.id_sw%TYPE;
      user_new      Users2.id_user%TYPE;
      check_excep_sw   VARCHAR2(51);
      check_excep_user VARCHAR2(92);
    BEGIN
        IF updating THEN --* update
    IF :new.sw_full_name != :old.sw_full_name THEN
        SELECT
            sw.name_sw||' '||sw.version
        INTO check_excep_sw
        FROM
            sw
        WHERE
            sw.name_sw||' '||sw.version = :new.sw_full_name;
        SELECT
            id_sw
        INTO sw_new
        FROM
            sw
        WHERE
            sw.name_sw||' '||sw.version = :new.sw_full_name;
      ELSE
        SELECT
            id_sw
        INTO sw_new
        FROM
            sw
        WHERE
            sw.name_sw||' '||sw.version = :old.sw_full_name;
       END IF;
       IF :new.user_full_name != :old.user_full_name THEN
        SELECT
            Users2.surname||' '||Users2.name||' '||Users2.patronymic
        INTO check_excep_user
        FROM
            Users2
        WHERE
            Users2.surname||' '||Users2.name||' '||Users2.patronymic = :new.user_full_name;
        SELECT
            id_user
        INTO user_new
        FROM
            Users2
        WHERE
            Users2.surname||' '||Users2.name||' '||Users2.patronymic = :new.user_full_name;
       ELSE
        SELECT
            id_user
        INTO user_new
        FROM
            Users2
        WHERE
            Users2.surname||' '||Users2.name||' '||Users2.patronymic = :old.user_full_name;
        END IF;
       UPDATE sales
       SET
        id_user = user_new,
        id_sw = sw_new,
        quantity = :new.quantity,
        order_date = :new.order_date,
        expiration_date = :new.expiration_date,
        total_cost = :new.total_cost
    WHERE
        id_sale = :old.id_sale;
   END IF;
    IF inserting THEN --* insert
   SELECT sw.name_sw||' '||sw.version INTO check_excep_sw
        FROM sw
        WHERE sw.name_sw||' '||sw.version = :new.sw_full_name;
        SELECT id_sw
        INTO sw_new
        FROM sw
        WHERE sw.name_sw||' '||sw.version = :new.sw_full_name;
    SELECT
        Users2.surname||' '||Users2.name||' '||Users2.patronymic
    INTO check_excep_user
    FROM
        Users2
    WHERE
        Users2.surname||' '||Users2.name||' '||Users2.patronymic = :new.user_full_name;
     SELECT id_user
        INTO user_new
        FROM Users2
        WHERE Users2.surname||' '||Users2.name||' '||Users2.patronymic = :new.user_full_name;
    INSERT INTO sales(
        id_user,
        id_sw,
        quantity,
        order_date,
        expiration_date,
        total_cost
     ) VALUES (
        id_user = user_new,
        id_sw = sw_new,
        quantity = :new.quantity,
        order_date = :new.order_date,
        expiration_date = :new.expiration_date,
        total_cost = :new.total_cost
     );
        END IF;
    EXCEPTION
        WHEN no_data_found THEN
    dbms_output.put_line('-------------------------------------------');
    dbms_output.put_line('| ERROR!   |');
    dbms_output.put_line('-------------------------------------------');
    END;
    /
Back To Top