如何动态更新特定列

时间:2014-04-30 15:49:57

标签: plsql oracle11g

我使用下表

book_Catalog contains
  book name,
  book_id,
  book_title,
  created_by(contains the detail which user created this entry),      
  updated_by(contains the detail which user updates this entry)
  created_by column uses the system date

请提出一个主意 应使用什么查询来填充update_by列?

提前致谢,

Ashmitha

2 个答案:

答案 0 :(得分:1)

您可以使用类似

的内容
CREATE PROCEDURE UPDATE_BOOK_CATALOG_UPDATED_BY
    (pin_BOOK_ID BOOK_CATALOG.UPDATED_BY%TYPE)
IS
BEGIN
  UPDATE BOOK_CATALOG
    SET UPDATED_BY = UID
    WHERE BOOK_ID = pin_BOOK_ID;
END UPDATE_BOOK_CATALOG_UPDATED_BY;

分享并享受。

答案 1 :(得分:0)

您可以使用AFTER UPDATE TRIGGER执行此操作。

CREATE OR REPLACE TRIGGER My_Trigger
AFTER INSERT 
ON TABLE
FOR EACH ROW
DECLARE
BEGIN
END;/