Oracle FN_STRING_SPLITTER“ORU-10027:缓冲区溢出,限制为20000字节”

时间:2016-11-22 01:01:35

标签: oracle stored-procedures reporting-services plsql ssrs-2008

我被分配为SSRS报告创建Oracle存储过程。 我想出了以下代码来检索数据:

SELECT DISTINCT
                     b.branch_name,
                     cu.unit_name,
                     c.CLAIM_DESC,
                     dp.legal_name,
                     c.claim_number,
                     c.date_of_loss,
                     FN_FORMAT_NAME(s.first_name, s.last_name, s.middle_name) AS staff_name,
                     c.state,
                     c.county,
                     cc.first_modified,
                     dp.policy_search_nbr,
                     c.city,
                     col.cause_name,
        CASE trim(SUBSTR (cp.last_name || ', ' || cp.first_name, 1, 78))
                   WHEN ',' THEN SUBSTR (cp.business_name, 1, 78)
                   ELSE trim(SUBSTR (cp.last_name || ', ' || cp.first_name, 1, 78))
               END
        AS claimant_name,
        cp.cms_party
        FROM claimant_coverage cc
        JOIN claim c ON cc.claim=c.claim
        JOIN DEC_POLICY dp  ON dp.dec_policy=c.dec_policy
        LEFT JOIN cms_party cp ON cc.claimant=cp.claimant
        LEFT JOIN cms_col_adjuster cca ON cca.claimant=cc.claimant
        AND cca.cause_of_loss=cc.cause_of_loss AND cca.coverage = cc.coverage
        LEFT JOIN staff s ON cca.staff=s.staff
        LEFT JOIN branch b  ON b.branch= s.branch
        LEFT JOIN cms_unit cu  ON b.branch= cu.branch
        LEFT JOIN cause_of_loss col ON cc.cause_of_loss=col.cause_of_loss
        --The code below is somewhat convoluted due to a lack of LIKE IN statement in pl/sql
        --Basically, the code filters for results that fulfill the LIKE criteria for any items in the list
        JOIN (
          SELECT (branch_search_term.COLUMN_VALUE) branch_name
          FROM (
            TABLE(FN_STRING_SPLITTER('Claim Service Center,Home Office,Northern Region,Property Claims Branch,Property Claim Service Center,Southern Region',','))
          ) branch_search_term
        ) branch_search_filter
            ON b.branch_name like  ('%' || branch_search_filter.branch_name || '%')
        JOIN (
          SELECT ( unit_search_term.COLUMN_VALUE ) unit_name
          FROM (
            TABLE(FN_STRING_SPLITTER('Auto Subrogation,Border Entry,CSC,Casualty,Home Office,Intake,Litigation,Med Pay,Multi-line,PCSC,Primary Auto,Property,Property Subrogation,Split,Subrogation,Support,TCR,Total Loss',','))
          ) unit_search_term
        ) unit_search_filter
            ON  cu.unit_name like ('%' || unit_search_filter.unit_name || '%') OR b.branch_name like ('%(' || unit_search_filter.unit_name || ')%')
        WHERE
          cc.status IN ('Open','Reopen')
          AND (( TRUNC(sysdate - cc.status_date) >= 90 ))

UNION SELECT DISTINCT
                             b.branch_name,
                             cu.unit_name,
                             c.CLAIM_DESC,
                             cmp.legal_name,
                             c.claim_number,
                             c.date_of_loss,
                             FN_FORMAT_NAME(s.first_name, s.last_name, s.middle_name) AS staff_name,
                             c.state,
                             c.county,
                             cc.first_modified,
                             cmp.policy_search_nbr,
                             c.city,
                             col.cause_name,
        CASE trim(SUBSTR (cp.last_name || ', ' || cp.first_name, 1, 78))
                   WHEN ',' THEN SUBSTR (cp.business_name, 1, 78)
                   ELSE trim(SUBSTR (cp.last_name || ', ' || cp.first_name, 1, 78))
               END
        AS claimant_name,
        cp.cms_party
        FROM claimant_coverage cc
        JOIN claim c ON cc.claim=c.claim
        JOIN cms_claim_policy ccp on ccp.claim = c.claim
        JOIN cms_policy cmp on cmp.cms_policy = ccp.cms_policy
        LEFT JOIN cms_party cp ON cc.claimant=cp.claimant
        LEFT JOIN cms_col_adjuster cca ON cca.claimant=cc.claimant
        AND cca.cause_of_loss=cc.cause_of_loss AND cca.coverage = cc.coverage
        LEFT JOIN staff s ON cca.staff=s.staff
        LEFT JOIN branch b  ON b.branch= s.branch
        LEFT JOIN cms_unit cu  ON b.branch= cu.branch
        LEFT JOIN cause_of_loss col ON cc.cause_of_loss=col.cause_of_loss
        JOIN (
          SELECT (branch_search_term.COLUMN_VALUE) branch_name
          FROM (
            TABLE(FN_STRING_SPLITTER('Claim Service Center,Home Office,Northern Region,Property Claims Branch,Property Claim Service Center,Southern Region',','))
          ) branch_search_term
        ) branch_search_filter
            ON b.branch_name like  ('%' || branch_search_filter.branch_name || '%')
        JOIN (
          SELECT ( unit_search_term.COLUMN_VALUE ) unit_name
          FROM (
            TABLE(FN_STRING_SPLITTER('Auto Subrogation,Border Entry,CSC,Casualty,Home Office,Intake,Litigation,Med Pay,Multi-line,PCSC,Primary Auto,Property,Property Subrogation,Split,Subrogation,Support,TCR,Total Loss',','))
          ) unit_search_term
        ) unit_search_filter
            ON  cu.unit_name like ('%' || unit_search_filter.unit_name || '%') OR b.branch_name like ('%(' || unit_search_filter.unit_name || ')%')
        WHERE
          cc.status IN ('Open','Reopen')
          AND (( TRUNC(sysdate - cc.status_date) >= 90 ));

当我在开发数据库的SQL工作表中运行此代码时,它按预期工作,没有错误。 Results from query 但是,当我将代码打包到存储过程中并运行它时, 存储过程不返回任何数据,而是输出以下错误消息:

<html><font color=red>ORA-20000: ORU-10027: buffer overflow, limit of 20000 bytes
ORA-06512: at "SYS.DBMS_OUTPUT", line 32
ORA-06512: at "SYS.DBMS_OUTPUT", line 97
ORA-06512: at "SYS.DBMS_OUTPUT", line 112
ORA-06512: at "CIGADMIN.FN_STRING_SPLITTER", line 16
</font></html>

出于测试目的,我编写了如下存储过程:

(PG_REPORTS.sps):

/*
 Procedure Name      : SP_GET_CLAIMANT_INACTIVE
 Version             : 1.0
 Description         : Returns a list of claims that have been inactive for 90 days (by default).
                       Used for CMS Inactivity Report
 Owner               : Joseph Faulkner
 Input               : p_days_inactive,p_branch_list,p_unit_list
 Output              : v_claimant_inactive_cur
 Date                : 11/21/2016
 LastModified        :
*/

    PROCEDURE SP_GET_CLAIMANT_INACTIVE
    (
    p_days_inactive               IN NUMBER := 90,
    p_branch_list                 IN VARCHAR,
    p_unit_list                   IN VARCHAR,
    v_claimant_inactive_cur       OUT SYS_REFCURSOR
    );

(PG_REPORTS.sql):

    PROCEDURE SP_GET_CLAIMANT_INACTIVE
    (
    p_days_inactive               IN NUMBER := 90,
    p_branch_list                 IN VARCHAR,
    p_unit_list                   IN VARCHAR,
    v_claimant_inactive_cur       OUT SYS_REFCURSOR
    )
    IS
    BEGIN
    OPEN v_claimant_inactive_cur FOR
    SELECT DISTINCT
                         b.branch_name,
                         cu.unit_name,
                         c.CLAIM_DESC,
                         dp.legal_name,
                         c.claim_number,
                         c.date_of_loss,
                         FN_FORMAT_NAME(s.first_name, s.last_name, s.middle_name) AS staff_name,
                         c.state,
                         c.county,
                         cc.first_modified,
                         dp.policy_search_nbr,
                         c.city,
                         col.cause_name,
            CASE trim(SUBSTR (cp.last_name || ', ' || cp.first_name, 1, 78))
                       WHEN ',' THEN SUBSTR (cp.business_name, 1, 78)
                       ELSE trim(SUBSTR (cp.last_name || ', ' || cp.first_name, 1, 78))
                   END
            AS claimant_name,
            cp.cms_party
            FROM claimant_coverage cc
            JOIN claim c ON cc.claim=c.claim
            JOIN DEC_POLICY dp  ON dp.dec_policy=c.dec_policy
            LEFT JOIN cms_party cp ON cc.claimant=cp.claimant
            LEFT JOIN cms_col_adjuster cca ON cca.claimant=cc.claimant
            AND cca.cause_of_loss=cc.cause_of_loss AND cca.coverage = cc.coverage
            LEFT JOIN staff s ON cca.staff=s.staff
            LEFT JOIN branch b  ON b.branch= s.branch
            LEFT JOIN cms_unit cu  ON b.branch= cu.branch
            LEFT JOIN cause_of_loss col ON cc.cause_of_loss=col.cause_of_loss
            JOIN (
              SELECT (branch_search_term.COLUMN_VALUE) branch_name
              FROM (
                TABLE(FN_STRING_SPLITTER('Claim Service Center,Home Office,Northern Region,Property Claims Branch,Property Claim Service Center,Southern Region',','))
              ) branch_search_term
            ) branch_search_filter
                ON b.branch_name like  ('%' || branch_search_filter.branch_name || '%')
            JOIN (
              SELECT ( unit_search_term.COLUMN_VALUE ) unit_name
              FROM (
                TABLE(FN_STRING_SPLITTER('Auto Subrogation,Border Entry,CSC,Casualty,Home Office,Intake,Litigation,Med Pay,Multi-line,PCSC,Primary Auto,Property,Property Subrogation,Split,Subrogation,Support,TCR,Total Loss',','))
              ) unit_search_term
            ) unit_search_filter
                ON  cu.unit_name like ('%' || unit_search_filter.unit_name || '%') OR b.branch_name like ('%(' || unit_search_filter.unit_name || ')%')
            WHERE
              cc.status IN ('Open','Reopen')
              AND (( TRUNC(sysdate - cc.status_date) >= 90 ))

    UNION SELECT DISTINCT
                                 b.branch_name,
                                 cu.unit_name,
                                 c.CLAIM_DESC,
                                 cmp.legal_name,
                                 c.claim_number,
                                 c.date_of_loss,
                                 FN_FORMAT_NAME(s.first_name, s.last_name, s.middle_name) AS staff_name,
                                 c.state,
                                 c.county,
                                 cc.first_modified,
                                 cmp.policy_search_nbr,
                                 c.city,
                                 col.cause_name,
            CASE trim(SUBSTR (cp.last_name || ', ' || cp.first_name, 1, 78))
                       WHEN ',' THEN SUBSTR (cp.business_name, 1, 78)
                       ELSE trim(SUBSTR (cp.last_name || ', ' || cp.first_name, 1, 78))
                   END
            AS claimant_name,
            cp.cms_party
            FROM claimant_coverage cc
            JOIN claim c ON cc.claim=c.claim
            JOIN cms_claim_policy ccp on ccp.claim = c.claim
            JOIN cms_policy cmp on cmp.cms_policy = ccp.cms_policy
            LEFT JOIN cms_party cp ON cc.claimant=cp.claimant
            LEFT JOIN cms_col_adjuster cca ON cca.claimant=cc.claimant
            AND cca.cause_of_loss=cc.cause_of_loss AND cca.coverage = cc.coverage
            LEFT JOIN staff s ON cca.staff=s.staff
            LEFT JOIN branch b  ON b.branch= s.branch
            LEFT JOIN cms_unit cu  ON b.branch= cu.branch
            LEFT JOIN cause_of_loss col ON cc.cause_of_loss=col.cause_of_loss
            JOIN (
              SELECT (branch_search_term.COLUMN_VALUE) branch_name
              FROM (
                TABLE(FN_STRING_SPLITTER('Claim Service Center,Home Office,Northern Region,Property Claims Branch,Property Claim Service Center,Southern Region',','))
              ) branch_search_term
            ) branch_search_filter
                ON b.branch_name like  ('%' || branch_search_filter.branch_name || '%')
            JOIN (
              SELECT ( unit_search_term.COLUMN_VALUE ) unit_name
              FROM (
                TABLE(FN_STRING_SPLITTER('Auto Subrogation,Border Entry,CSC,Casualty,Home Office,Intake,Litigation,Med Pay,Multi-line,PCSC,Primary Auto,Property,Property Subrogation,Split,Subrogation,Support,TCR,Total Loss',','))
              ) unit_search_term
            ) unit_search_filter
                ON  cu.unit_name like ('%' || unit_search_filter.unit_name || '%') OR b.branch_name like ('%(' || unit_search_filter.unit_name || ')%')
            WHERE
              cc.status IN ('Open','Reopen')
              AND (( TRUNC(sysdate - cc.status_date) >= 90 ));
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
      RAISE NO_DATA_FOUND;
      WHEN OTHERS THEN
      RAISE_APPLICATION_ERROR (-20001, 'Error In SP_GET_CLAIMANT_INACTIVE. ' || sqlerrm);
    END SP_GET_CLAIMANT_INACTIVE;

Error Result

我在网上搜索了一下可能导致这个问题的原因并且空手而归。 同样,我可以让这段代码在SQL工作表中工作,我只是无法让它在存储过程中工作。

我应该解释为什么我按照我的方式实现了以下代码:

JOIN (
          SELECT (branch_search_term.COLUMN_VALUE) branch_name
          FROM (
            TABLE(FN_STRING_SPLITTER('Claim Service Center,Home Office,Northern Region,Property Claims Branch,Property Claim Service Center,Southern Region',','))
          ) branch_search_term
        ) branch_search_filter
            ON b.branch_name like  ('%' || branch_search_filter.branch_name || '%')

基本上,这是我试图实现'LIKE IN'语句的尝试,该语句在Oracle中没有本机实现。数据库中有多个实例,其中分支名称与列表中的项目不完全匹配。

0 个答案:

没有答案