A
A
Askold19942019-10-25 11:38:44
Oracle
Askold1994, 2019-10-25 11:38:44

Create trigger to insert into view?

There is a table stations (st_id, st_name)
The second table rotes (route_id, start_station, end_station)
Created a view

CREATE VIEW routes_view AS
    SELECT r.route_id, s1.st_name, s2.st_name
    FROM routes r
    JOIN stations s1  ON (r.start_station = s1.st_id)
    JOIN stations s1  ON (r.end_station = s2.st_id) ;

Now, since the view cannot insert data, I need to create a trigger for it. I start and then I can't write. help me please
CREATE OR REPLACE TRIGGER routes_view_insert
     INSTEAD OF INSERT ON routes_view ....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Cherepakhin, 2019-10-25
@AltZ

In order for this trigger to work for you, at least you need to list the required fields in the view. Those. from stations you need to add 2 st_id (primary keys). And you can take everything else from the documentation https://docs.oracle.com/cd/B19306_01/server.102/b1... in the examples.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question