I have this error for my code :
insert into Giocatore(ID_giocatore,username) Values('4','pluto')
Report error -
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "MONOPOLY3.INSERISCI_LOG", line 6
ORA-06512: at "MONOPOLY3.T2", line 2
ORA-04088: error during execution of trigger 'MONOPOLY3.T2'
we want to save the value inserted on tab Giocatore( ID_giocatore) into the variable "a" for see that value in the tab log_giocatore in the column id_giocatore of log_giocatore. This is procedure :
create or replace PROCEDURE inserisci_log
AS
a integer ;
BEGIN
SELECT ID_giocatore
INTO a
FROM (select ID_giocatore from Giocatore order by ID_GIOCATORE desc)
where rownum <2;
INSERT INTO Log_giocatore ( ID_mossa , ID_partita , ID_giocatore , ID_patrimonio ,ID_proprietà , ID_turno)
VALUES ('1' , '1' , a , '1' ,'1','1');
END inserisci_log;
And this is the trigger that call the procedure:
create or replace TRIGGER t2
AFTER INSERT OR UPDATE ON Giocatore
begin
inserisci_log;
end;