将事件历史添加到 Oracle SQL 的过程

Procedure to add history of an event to Oracle SQL

我需要在 Oracle SQL 中编写一个过程,将来自三个 table 的数据插入到一个单独的 table 中,无需任何键。这是我的数据库的模型:

。 (所有的列名都是波兰语,抱歉)。

我已经为历史创建了一个table:

create table art_historia(
data_koncertu date default sysdate,   --Concert date
miejsce_koncertu varchar2(40),        --Place of concert
nazwa_zespolu varchar2(30),           --Name of band
liczba_widzow number(5),              --Number of viewers
bilans_finansowy number (8,2));       --Finance balance

我想用这个程序插入的值我可以用这个 select:

select s.miasto, a.nazwa_zespolu, k.ilosc_sprzedanych_biletow, k.zysk
    from art_sala s, art_koncert k, art_artysta a
    where k.kod_sali_koncertowej = s.kod_sali_koncertowej and
    k.kod_artysty = a.kod_artysty and
    k.id_koncertu = (variable of concert id);

我该怎么做?

试试这个

CREATE PROCEDURE INSERT_ART_HIST_P (p_in_concert_id number) IS
BEGIN
INSERT INTO art_historia
select s.miasto, a.nazwa_zespolu, k.ilosc_sprzedanych_biletow, k.zysk
    from art_sala s, art_koncert k, art_artysta a
    where k.kod_sali_koncertowej = s.kod_sali_koncertowej and
    k.kod_artysty = a.kod_artysty and
    k.id_koncertu = p_in_concert_id;
END;