Solved

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

Posted on 2008-10-06
2
1,928 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
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.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example, show how to take different types of Oracle backups using RMAN.
Suggested Courses

630 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