Solved

PL/SQL code - ORA-01795: maximum number of expressions in a list is 1000

Posted on 2008-10-06
2
1,917 Views
Last Modified: 2013-12-07
When this query runs, it sometimes was fine, but it sometimes produced this error.  Please advise.
BEGIN

  SELECT

ORA-01795: maximum number of expressions in a list is 1000
ORA-06512: at line 13
**************************************************************************
DECLARE
  v_cnt NUMBER;
  v_ban_list VARCHAR2(30000) := ' ';
BEGIN
  SELECT COUNT(*) INTO v_cnt FROM clm_actual_usage_${INST};

  -- insert 500 rows at a time
  FOR r IN (SELECT ban, ROWNUM AS rownum_id FROM clm_actual_usage_${INST} ORDER BY ban) LOOP
    v_ban_list := v_ban_list || r.ban || ',';
    IF MOD(r.rownum_id, 500) = 0 OR r.rownum_id = v_cnt THEN
      EXECUTE IMMEDIATE '
      INSERT /*+ APPEND */
        INTO tmp_clm_all_${INST}
             (ban, bill_cycle, ar_usage_threshold, customer_type, num_of_product, deposit_ind,
              credit_class,clm_skip_ind, ban_status,start_srvc_dt, billing_type, bc_carrier_id,
              bc_carrier_acct_id, bl_spcl_ban_code, act_usage, clm_typ_cd)
      SELECT /*+ PARALLEL(b, 20) */
             b.ban, b.bill_cycle, b.ar_usage_threshold, b.customer_type,
             NVL(b.num_of_product, 1) AS num_of_product,
             CASE WHEN (b.deposit_ind=''R'' AND ''${CINST}''=''AMT'') OR
                       (b.deposit_ind=''N'' AND ''${CINST}''=''PCT'') OR
                       (b.deposit_ind=''Z'' AND ''${CINST}''=''SWT'') OR
                       (b.deposit_ind=''R'' AND ''${CINST}''=''BLS'') THEN ''N'' ELSE b.deposit_ind END AS deposit_ind,
             b.credit_class, b.clm_skip_ind, b.ban_status, b.start_service_date,
             b.billing_type, b.bc_carrier_id, b.bc_carrier_acct_id, b.bl_spcl_ban_code, NULL AS act_usage,
             DECODE(ar_usage_threshold, NULL, ''G'', ''R'') AS clm_typ_cd
        FROM billing_account@${DB_NAME} b
       WHERE b.ban IN (' || SUBSTR(v_ban_list, 1, LENGTH(v_ban_list) - 1) || ')
      ';
      COMMIT;
      v_ban_list := ' ';
    END IF;
  END LOOP;
END;
/
0
Comment
Question by:scpig
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
johnsone earned 250 total points
ID: 22651863
The v_ban_list that is being pulled contains more than 1,000 items.  There is a restriction in Oracle that and in list can only contain 1,000 items.

One way round this is to create a global temporary table and load the individual items of the list into that table and then instead of using an in list, use a sub query.
0
 

Author Closing Comment

by:scpig
ID: 31503491
yes this works.
and another way to work is to change 500 to 250, which works fine too.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question