Solved

ORA-06550 error

Posted on 2007-04-11
4
756 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

862 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now