[英]Oracle Transactions PLSQL
我正在研究 Oracle 11g 和 12c 中基于 PLSQL 的程序。
当我在我的一个过程/函数中发出提交命令时,我想保留表名和行数的日志。
这是用于审计日志。
你能建议我如何做到这一点吗?
您的 PL/SQL 代码将需要跟踪其活动并记录它。 没有办法问 Oracle “你现在提交了多少行以及哪些表?”
所以,例如,
DECLARE
l_row_count NUMBER;
BEGIN
UPDATE table_1 SET column_a = 'whatever' WHERE column_b = 'some condition';
l_row_count := SQL%ROWCOUNT;
INSERT INTO my_audit ( action, cnt ) VALUES ('Updated table_1', l_row_count);
-- Notice the audit is part of the transaction; if I don't commit the UPDATE,
-- I won't commit the log of the update.
-- ... do other similar updates / inserts / deleted, using SQL%ROWCOUNT to
-- to determine the number of rows affected and log each one ...
COMMIT;
END;
同样,执行一堆 DML 语句(插入、更新、删除)然后在“到目前为止我在此事务中做了什么?”之后询问 Oracle 是不切实际的。 您需要将其记录为 go。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.