简体   繁体   English

ORA-01422:-ORA-06512:

[英]ORA-01422: - ORA-06512:

I have this error for my code : 我的代码有这个错误:

insert into Giocatore(ID_giocatore,username) Values('4','pluto') 插入Giocatore(ID_giocatore,username)值('4','pluto')
Report error - 报告错误-
ORA-01422: exact fetch returns more than requested number of rows ORA-01422:精确获取返回的行数超过了请求的行数
ORA-06512: at "MONOPOLY3.INSERISCI_LOG", line 6 ORA-06512:位于“ MONOPOLY3.INSERISCI_LOG”的第6行
ORA-06512: at "MONOPOLY3.T2", line 2 ORA-06512:位于“ MONOPOLY3.T2”的第2行
ORA-04088: error during execution of trigger 'MONOPOLY3.T2' ORA-04088:执行触发器'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. 我们希望将在Giocatore(ID_giocatore)选项卡上插入的值保存到变量“ a”中,以便在log_giocatore的id_giocatore列的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;

I suggest you might want to rewrite your procedure to accept the ID_GIOCATORE value as a parameter, as in: 我建议您可能要重写过程以接受ID_GIOCATORE值作为参数,如下所示:

create or replace PROCEDURE inserisci_log(pin_ID_GIOCATORE IN INTEGER)
  AS
  BEGIN
    INSERT INTO Log_giocatore
      ( ID_mossa , ID_partita , ID_giocatore , ID_patrimonio ,ID_proprietà , ID_turno)
    VALUES
      ('1' , '1' , pin_ID_GIOCATORE , '1' ,'1','1');
  END inserisci_log;

Then you can change your trigger to pass the ID_GIOCATORE value from the new row: 然后,您可以更改触发器以从新行传递ID_GIOCATORE值:

create or replace TRIGGER  t2
  AFTER INSERT OR UPDATE ON Giocatore
  FOR EACH ROW
begin
  inserisci_log(:NEW.ID_GIOCATORE);
end t2;

Best of luck. 祝你好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM