1

我已经应用了有关如何克服变异表错误的休闲说明:

http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551198119097816936

但在我的最后一个触发器中,我得到了错误:

SQL> create or replace trigger Factura_Detalle_ai
after insert or update of PRODUCTO on Factura_Detalle
begin
                for i in 1 .. state_pkg.newRows.count loop

                        UPDATE Factura_Detalle
                        SET Precio = (SELECT pre.PRECIO
                        FROM PRECIO pre
                        WHERE pre.PRODUCTO = state_pkg.newRows(i));

                end loop;
end;
/
  2    3    4    5    6    7    8    9   10   11   12   13  
Warning: Trigger created with compilation errors.

SQL> show errors trigger factura_detalle_ai
Errors for TRIGGER FACTURA_DETALLE_AI:

LINE/COL ERROR
-------- -----------------------------------------------------------------
4/4      PL/SQL: SQL Statement ignored
7/23     PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got
         ROWID

有任何想法吗?

问候

4

1 回答 1

1

用这个替换你的 where 子句:

WHERE ROWID = state_pkg.newRows(i));

ROWID是每行地址的伪列,是一种数据类型。

编辑:

或者可能是这样的:

UPDATE Factura_Detalle
SET Precio = 
(
    SELECT pre.PRECIO
    FROM PRECIO pre
    WHERE pre.PRODUCTO = Factura_Detalle.PRODUCTO
)
WHERE ROWID = state_pkg.newRows(i);
于 2011-05-02T02:38:09.543 回答