Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-06
2
Medium Priority
?
1,944 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 1000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
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.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

730 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