ORA-01410:无效的ROWID

时间:2017-04-05 11:55:03

标签: oracle plsql datastage

当我尝试使用以下代码获取源表上的更新时,我正在

**Error code: 1,410, Error message: ORA-01410: invalid ROWID
ORA-06512: at "DS2ODS_DW_PRODUCT", line 43** 

错误和更新的行无法镜像到目标。 (注意:我成功了INSERTS)第43行引用 UPDATE DW PRODUCT ... 行。你看到有什么错误吗?

注意:我正在尝试使用以下代码将源表更新应用于目标表。

CREATE OR REPLACE PROCEDURE DS2ODS_DW_PRODUCT(
DM_OPERATION_TYPE       IN  char,
BEFORE_PRODUCT_ID       IN  NUMBER,
BEFORE_DESCRIPTION      IN  CHAR,
BEFORE_PRICE            IN  NUMBER,
AFTER_PRODUCT_ID        IN  NUMBER,
AFTER_DESCRIPTION       IN  CHAR,
AFTER_PRICE             IN  NUMBER
)
IS
dummy number;
BEGIN
CASE DM_OPERATION_TYPE
WHEN 'I' THEN
INSERT INTO DW_PRODUCT (
PRODUCT_ID,
DESCRIPTION,
PRICE)
VALUES
(AFTER_PRODUCT_ID,
AFTER_DESCRIPTION,
AFTER_PRICE);
WHEN 'D' THEN 
DECLARE CURSOR CURSOR_FOR_DELETE  is SELECT 1 
FROM DW_PRODUCT
WHERE PRODUCT_ID=BEFORE_PRODUCT_ID AND DESCRIPTION=BEFORE_DESCRIPTION AND 
PRICE=BEFORE_PRICE FOR UPDATE;
    BEGIN
    OPEN CURSOR_FOR_DELETE;
    loop 
    FETCH  CURSOR_FOR_DELETE INTO dummy;
      DELETE FROM DW_PRODUCT WHERE CURRENT OF CURSOR_FOR_DELETE;
   end loop;
    CLOSE CURSOR_FOR_DELETE;
  END;
WHEN 'U' THEN
DECLARE CURSOR CURSOR_FOR_UPDATE  is SELECT 1 
FROM DW_PRODUCT
WHERE PRODUCT_ID=BEFORE_PRODUCT_ID AND DESCRIPTION=BEFORE_DESCRIPTION AND 
PRICE=BEFORE_PRICE FOR UPDATE;
    BEGIN
    OPEN CURSOR_FOR_UPDATE;
    loop
    FETCH CURSOR_FOR_UPDATE INTO dummy;
      UPDATE DW_PRODUCT SET PRODUCT_ID=AFTER_PRODUCT_ID,DESCRIPTION=AFTER_DESCRIPTION,PRICE=AFTER_PRICE
      WHERE CURRENT OF CURSOR_FOR_UPDATE;
     end  loop;
    CLOSE CURSOR_FOR_UPDATE;
  END;
END CASE;
END;
/

1 个答案:

答案 0 :(得分:1)

如果这是您的真实代码,那么就像这样:

CREATE OR REPLACE PROCEDURE DS2ODS_DW_PRODUCT(
DM_OPERATION_TYPE       IN  char,
BEFORE_PRODUCT_ID       IN  NUMBER,
BEFORE_DESCRIPTION      IN  CHAR,
BEFORE_PRICE            IN  NUMBER,
AFTER_PRODUCT_ID        IN  NUMBER,
AFTER_DESCRIPTION       IN  CHAR,
AFTER_PRICE             IN  NUMBER
)
IS

BEGIN
CASE DM_OPERATION_TYPE
WHEN 'I' THEN
   INSERT INTO DW_PRODUCT (PRODUCT_ID,DESCRIPTION,PRICE)
   VALUES (AFTER_PRODUCT_ID,AFTER_DESCRIPTION,AFTER_PRICE);
WHEN 'D' THEN 
   DELETE FROM DW_PRODUCT 
   WHERE PRODUCT_ID=BEFORE_PRODUCT_ID 
      AND DESCRIPTION=BEFORE_DESCRIPTION 
      AND PRICE=BEFORE_PRICE;
WHEN 'U' THEN
   UPDATE DW_PRODUCT SET  
      PRODUCT_ID=AFTER_PRODUCT_ID, 
      DESCRIPTION=AFTER_DESCRIPTION, 
      PRICE=AFTER_PRICE
   WHERE PRODUCT_ID=BEFORE_PRODUCT_ID 
      AND DESCRIPTION=BEFORE_DESCRIPTION 
      AND PRICE=BEFORE_PRICE;
END CASE;
END;
/