Oracle 合并拒绝行计数

发布于 2024-09-03 20:37:14 字数 138 浏览 6 评论 0原文

给定一个具有拒绝限制的 Oracle Merge 语句,是否有一种简便方法可以识别有多少行被拒绝,而不必被迫查询拒绝目标?

拒绝目的地有预合并的记录,因此目前必须计数两次并取差值,但似乎应该有一个暴露的计数器,因为它必须知道它是否超出了拒绝限制。

Given an Oracle Merge statement with a rejection limit, is there a shorthand way to identify how many rows were rejected, without being forced to query the rejection destination?

The rejection destination has records pre-merge, so would currently have to be counted twice and the difference taken, but it seems like there should be a counter exposed, given that it has to be aware of whether it has exceeded the rejection limit.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三生池水覆流年 2024-09-10 20:37:14

没有暴露的拒绝计数器。

DML 错误日志记录的主要目的是支持 ETL 流程。它允许我们加载大量数据,而不会出现导致整个加载回滚的错误。我猜潜在的理由是,在我们针对该表发出更多 DML 之前,将手动解决错误:它并不是真正旨在提供永久错误日志。

但是,如果为每个 DML 语句指定一个唯一的标记,您就可以计算它所产生的拒绝的确切数量。

declare
    l_tag varchar2(46);
    reject_cnt pls_integer;
begin

    ....

    l_tag := 'merging from source_table::'||to_char(sysdate, 'yyyymmddhh24miss');

    merge into target_table a
        using source_table b
        on (a.id = b.id)
      ....
      log errors into err$_target_table (l_tag) reject limit 10;

    select count(*)
    into reject_cnt
    from   err$_target_table
    where  ora_err_tag$ = l_tag;

    ....

There is no exposed rejection counter.

The main purpose of DML Error Logging is to support ETL processes. It allows us to load huge amounts of data without a couple of errors forcing the entire load to rollback. I guess the underlying rationale is that errors will be resolved manually before we issue more DML against that table: it's not really intended to provide a permanent error log.

However, if you give each DML statement a unique tag you can count the exact number of rejections it has spawned.

declare
    l_tag varchar2(46);
    reject_cnt pls_integer;
begin

    ....

    l_tag := 'merging from source_table::'||to_char(sysdate, 'yyyymmddhh24miss');

    merge into target_table a
        using source_table b
        on (a.id = b.id)
      ....
      log errors into err$_target_table (l_tag) reject limit 10;

    select count(*)
    into reject_cnt
    from   err$_target_table
    where  ora_err_tag$ = l_tag;

    ....
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文