Solved

ORA-06550 error

Posted on 2007-04-11
4
763 Views
Last Modified: 2013-12-18
When I ran this script I got ORA-06550 Error __ Please help

DECLARE
  n_param3           NUMBER(20,2)       :=0;
  n_count_subords    NUMBER(10)         :=0;
BEGIN

FOR skudc_planorder_cursor IN
  (
    SELECT /*+ RULE */ DISTINCT s.loc, s.item
      FROM stsc.sku s, stsc.item i
     WHERE s.scen = 0 AND i.scen = 0
       AND s.item = i.item
       AND s.loc IN ( SELECT NVL(TRIM(si_alt_loc),' ' )
                        FROM stsc.loc
                       WHERE scen = 0 AND NVL(TRIM(si_loc_type), ' ' ) =
'DC'
                    )
       AND i.inv_class IN ( SELECT inv_class FROM siviews.si_fg_cls)
       AND i.product_group IN ( SELECT 1 FROM
springs.si_jde_user_proc_params
                                 WHERE UPPER(TRIM(key1)) = 'ADJPLANLT'
                                   AND UPPER(TRIM(key2)) = 'OVERRIDE'
                                   AND UPPER(TRIM(key3)) IS NULL
                                   AND UPPER(TRIM(param1)) =
i.product_group
                              )
       AND EXISTS ( SELECT 1 FROM stsc.bom b
                     WHERE scen = 0 AND s.item = b.item
                       AND EXISTS ( SELECT 1 FROM stsc.loc
                                     WHERE scen = 0 AND b.loc =
NVL(TRIM(si_alt_loc),loc)
                                       AND TRIM(si_seq_ind) = 'Y'
                                  )
                  )
       AND NOT EXISTS ( SELECT 1 FROM stsc.bom b1, stsc.bom b2
                         WHERE  b1.item = b2.subord AND b2.scen = 0)
  )
LOOP
  FOR inner_loop IN ( SELECT DISTINCT subord
                        FROM stsc.bom
                       START WITH skudc_planorder_cursor.item
                     CONNECT BY PRIOR subord =
skudc_planorder_cursor.item
                    )
    LOOP
      IF inner_loop.subord IN ( SELECT item FROM stsc.item
                                 WHERE scen = 0
                                   AND item.product_type IN
                              ( SELECT param2 FROM
springs.si_jde_user_proc_params
                                 WHERE UPPER(TRIM(key1)) = 'ADJPLANLT'
                                   AND UPPER(TRIM(key2)) = 'OVERRIDE'
                                   AND TRIM(key3) IS NULL)
                              ) THEN
       n_count_subords := n_count_subords + 1;
      END IF;
    END LOOP;
      IF n_count_subords = 0 THEN
         UPDATE stsc.sku
            SET planleadtime = ( n_param3 * 1440 )
          WHERE scen = 0 AND item = skudc_planorder_cursor.item
            AND loc = skudc_planorder_cursor.loc;
      END IF;
      n_count_subords := 0;
END LOOP;
END;
0
Comment
Question by:ramumorla
[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
4 Comments
 
LVL 12

Assisted Solution

by:jwahl
jwahl earned 100 total points
ID: 18890658
i think subqueries outside of SQL are not allowed.

as workaround

1)
define a cursor:

CURSOR item_c (p_subord IN VARCHAR2) IS
    SELECT item
    FROM   stsc.item
    WHERE  scen = 0
    AND    item = p_subord
    AND    item.product_type IN (
        SELECT param2
        FROM   springs.si_jde_user_proc_params
        WHERE UPPER(TRIM(key1)) = 'ADJPLANLT'
        AND UPPER(TRIM(key2)) = 'OVERRIDE'
        AND TRIM(key3) IS NULL
        );

2)
instead of:
      IF inner_loop.subord IN ( SELECT item FROM stsc.item
                                 WHERE scen = 0
                                   AND item.product_type IN
                              ( SELECT param2 FROM
springs.si_jde_user_proc_params
                                 WHERE UPPER(TRIM(key1)) = 'ADJPLANLT'
                                   AND UPPER(TRIM(key2)) = 'OVERRIDE'
                                   AND TRIM(key3) IS NULL)
                              ) THEN
       n_count_subords := n_count_subords + 1;
      END IF;        
     
try:      

      FOR item_rt IN item_c (inner_loop.subord)
      LOOP
          n_count_subords := n_count_subords + 1;
      END LOOP;
0
 
LVL 4

Author Comment

by:ramumorla
ID: 18895636
Subqueries arenot allowed? Can u please elaborate>?
0
 
LVL 1

Accepted Solution

by:
rkrtera earned 400 total points
ID: 18895684
You got some kind of compilation error in the script, thats the reason you are facing this problem.

You have two problems in the script.


The first problem (see listing below) is that "Start With" is missing a comparison. For instance: start with manager = 'Greg.'
FOR inner_loop IN ( SELECT DISTINCT subord
                        FROM stsc.bom
                       START WITH skudc_planorder_cursor.item
                     CONNECT BY PRIOR subord =  skudc_planorder_cursor.item

The second problem (see listing below) is that you are using the variable "inner_loop.subord" as a loop index variable. This is not allowed for an IF statement:
IF inner_loop.subord IN ( SELECT item FROM stsc.item
                                 WHERE scen = 0
                                   AND item.product_type IN
                              ( SELECT param2
                                 FROM springs.si_jde_user_proc_params
                                 WHERE UPPER(TRIM(key1)) = 'ADJPLANLT'
                                   AND UPPER(TRIM(key2)) = 'OVERRIDE'
                                   AND TRIM(key3) IS NULL)
                              ) THEN
       n_count_subords := n_count_subords + 1;
      END IF;

0
 
LVL 4

Author Comment

by:ramumorla
ID: 18895727
rkrtera,

Yeah you are right...
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
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.

734 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