create or replace trigger trg_insertb
After insert on a for each row
declare
v_a number(10,2);
v_y number(10,2);
v_m number(10,2);
begin
dbms_output.put_line(:new.Y);
if (:new.m<12) then
v_m:=:new.M+1;
v_y:=:new.Y;
elsif (:new.m=12) then
v_m:=1;
v_y:=:new.Y+1;
end if;
insert into b values(v_a,v_Y,v_M);
end;SQL> select * from mljc_z1;   MLJC_Q1    MLJC_Q2    MLJC_Q3    MLJC_Z1          Y          M
---------- ---------- ---------- ---------- ---------- ----------
-46.336667 -46.336667 -46.336667       -141       2008          7
-22.666667 -22.666667 -22.666667        -70       2008          7SQL> exec jc_z1;
BEGIN jc_z1; END;
*
 ERROR 在行 1:
ORA-01422: 精確擷取傳回的列數超過所要求的列數
ORA-06512: 在 "SYSMAN.JC_Z1", line 9
ORA-06512: 在 line 1請問各位大俠怎樣讓連接視圖中保持0數據。連接視圖據說是不可以修改的。但是我利用存儲過程
傳遞視圖值﹐視圖中只能有當前查詢出來的數據啊﹐不然﹐ 就不能傳遞。數據列數過超。除了過程每有別的辦法了嗎? 游標可以嗎??? 怎么做。

解决方案 »

  1.   

     對不起啦﹗
    是我不會表達﹐想說的清楚些反而看不懂﹗reate or replace trigger trg_insertb 
    After insert on a for each row 
    declare 
    v_a number(10,2); 
    v_y number(10,2); 
    v_m number(10,2); 
    begin 
    dbms_output.put_line(:new.Y); 
    if (:new.m <12) then 
    v_m:=:new.M+1; 
    v_y:=:new.Y; 
    elsif (:new.m=12) then 
    v_m:=1; 
    v_y:=:new.Y+1; 
    end if; 
    insert into b values(v_a,v_Y,v_M); 
    end; SQL> select * from mljc_z1;   MLJC_Q1    MLJC_Q2    MLJC_Q3    MLJC_Z1          Y          M 
    ---------- ---------- ---------- ---------- ---------- ---------- 
    -46.336667 -46.336667 -46.336667      -141      2008          7 
    -22.666667 -22.666667 -22.666667        -70      2008          7 SQL> exec jc_z1; 
    BEGIN jc_z1; END; 

    ERROR 在行 1: 
    ORA-01422: 精確擷取傳回的列數超過所要求的列數 
    ORA-06512: 在 "SYSMAN.JC_Z1", line 9 
    ORA-06512: 在 line 1 這樣出錯那就是利用存儲過程傳遞視圖中的數據就是失敗嗎? 無解???
      

  2.   

    上面的Trigger创建表a,查询是再表mljc_z1,然后运行存储过程exec jc_z1报错,
    说明jc_z1有问题,你不贴存储过程jc_z1的源码,
    反而贴trigger和查询语句,真是晕。樓主,我真是崇拜你
      

  3.   

    create or replace procedure sysman.JC_Z1 is
    a number(10,2);
    b number(10,2);
    c number(10,2);
    d number(10,2);
    e number(10,2);
    f number(10,2);
    begin
    select * into a,b,c,d,e,f from sysman.mljc_z1;
    insert into  sysman.BYJC_z1 values(a,b,c,d,e,f);
    insert into  sysman.sYJC_z1 values(a,b,c,d,e,f);
    end JC_Z1;
    SQL> select * from mljc_z1;   MLJC_Q1    MLJC_Q2    MLJC_Q3    MLJC_Z1          Y          M
    ---------- ---------- ---------- ---------- ---------- ----------
    -46.336667 -46.336667 -46.336667       -141       2008          7
    -22.666667 -22.666667 -22.666667        -70       2008          7SQL> exec jc_z1;
    BEGIN jc_z1; END;*
     ERROR 在行 1:
    ORA-01422: 精確擷取傳回的列數超過所要求的列數
    ORA-06512: 在 "SYSMAN.JC_Z1", line 9
    ORA-06512: 在 line 1
      

  4.   

    a,b,c,d,e,f 是单个变量无法把sysman.mljc_z1的返回值多于一个的情况使用。需要用数组或者cursor。
      

  5.   

    改成如下试试:CREATE OR REPLACE PROCEDURE SYSMAN.JC_Z1 IS
    BEGIN
      FOR C IN (SELECT TRUNC(MLJC_Q1, 2) a,
                       TRUNC(MLJC_Q2, 2) b,
                       TRUNC(MLJC_Q3, 2) c,
                       MLJC_Z1 d,
                       Y e,
                       M f
                  FROM SYSMAN.MLJC_Z1) LOOP
        INSERT INTO SYSMAN.BYJC_Z1 VALUES (c.A, c.B, c.C, c.D, c.E, c.F);
        INSERT INTO SYSMAN.SYJC_Z1 VALUES (c.A, c.B, c.C, c.D, c.E, c.F);
      END LOOP;
      COMMIT;
    END JC_Z1;
    /
      

  6.   


    create or replace procedure sysman.JC_Z1
    as 
    begin 
      for REC in(select MLJC_Q1,MLJC_Q2,MLJC_Q3,MLJC_Z1,y,m from sysman.mljc_z1)
      loop
        insert into  sysman.BYJC_z1 values(rec.MLJC_Q1,rec.MLJC_Q2,rec.MLJC_Q3,rec.MLJC_Z1,rec.Y,rec.m); 
        insert into  sysman.sYJC_z1 values(rec.MLJC_Q1,rec.MLJC_Q2,rec.MLJC_Q3,rec.MLJC_Z1,rec.Y,rec.m);
      end loop;
    end JC_Z1; 
    /
      

  7.   

    晕  看到你的mljc_z1表里没有重复值啊   你要消除什么 ?create or replace procedure sysman.JC_Z1 is 
    a number(10,2); 
    b number(10,2); 
    c number(10,2); 
    d number(10,2); 
    e number(10,2); 
    f number(10,2); 
    begin 
    select * into a,b,c,d,e,f from sysman.mljc_z1;     这句是从sysman.mljc_z1表中查询出所有的数据,在存储过程中select ... into ... from ..中只允许有一条查询结果否则就报LZ你在执行存储过程时的那个错误,解决这个问题的方法就是使用游标。
    insert into  sysman.BYJC_z1 values(a,b,c,d,e,f); 
    insert into  sysman.sYJC_z1 values(a,b,c,d,e,f); 
    end JC_Z1; 修改后的代码为:
    ---------------------- start change proc-------------------------------
    create or replace procedure sysman.JC_Z1 is 
    a number(10,2); 
    b number(10,2); 
    c number(10,2); 
    d number(10,2); 
    e number(10,2); 
    f number(10,2); 
    Cursor x_values is select * from sysman.mljc_z1;Begin 
      For x In x_values Loop
        insert into  sysman.BYJC_z1 values(x.a,x.b,x.c,x.d,x.e,x.f); 
        insert into  sysman.SYJC_z1 values(x.a,x.b,x.c,x.d,x.e,x.f); 
        commit;
      End Loop;
    End;
    ---------------------- end change proc---------------------------------
      

  8.   

    删除重复数据(行)的方法例子:
    DELETE FROM EMP E WHERE E.ROWID > (SELECT MIN(X.ROWID) FROM EMP X WHERE X.EMP_NO = E.EMP_NO);