Solved

ORA-6502 ERROR

Posted on 2004-09-13
3
1,481 Views
Last Modified: 2012-06-27
Hello!  
I have the following code in a trigger called Post-Query.

-- Populate display_bslip_changed
if :view_discrepancies.bslip_changed is null then
   :view_discrepancies.display_bslip_changed := 'NA';
--   :view_discrepancies.bslip_changed := '0';
elsif :view_discrepancies.bslip_changed = '0' then
   :view_discrepancies.display_bslip_changed := 'No';
elsif :view_discrepancies.bslip_changed = '1' then
   :view_discrepancies.display_bslip_changed := 'Yes';
elsif :view_discrepancies.bslip_changed = '2' then
   :view_discrepancies.display_bslip_changed := 'NA';
end if;


-- Display the current Sort Order
:display.sort_order := 'Ordered By '||Get_Block_Property( 'VIEW_DISCREPANCIES', order_by);
-- Parse :display.sort_order looking for 'Ordered By GET_'.  If found
-- remove the 'GET_'.
if substr(:display.sort_order,1,15) = 'Ordered By GET_' then
   :display.sort_order := 'Ordered By '||substr(substr(:display.sort_order,16),1,(instr(substr(:display.sort_order,16),'(') -1))||
                           ','||substr(:display.sort_order,instr(:display.sort_order,')') +2);
end if ;

-- Reset Default-Where to null after each query
set_block_property('view_discrepancies',default_where,' ');


-- Populate PC Code
:view_discrepancies.pc_code := get_pccode(:view_discrepancies.project,:view_discrepancies.bundle);

-- Populate ONC initails
:view_discrepancies.onc := get_onc(:view_discrepancies.project,:view_discrepancies.bundle);

-- Depending on which view selected, update the ONC initials
onc_mteam_pairs;

declare
   x number(2):=0;
Begin

-- Populate display_discr_type
for i in 1..7 loop
   if substr(:view_discrepancies.discr_type,i,1) = 'A' then
           x:=x+1;
      :view_discrepancies.display_discr_type := :view_discrepancies.display_discr_type||' Bad Address;';
   elsif substr(:view_discrepancies.discr_type,i,1) = 'B' then
           x:=x+1;
      :view_discrepancies.display_discr_type := :view_discrepancies.display_discr_type||' Invalid Box;';
-- highlighting the row in red when bad box
      DISPLAY_ITEM('view_discrepancies.display_discr_type','highlight');
      DISPLAY_ITEM('view_discrepancies.onc','highlight');
      DISPLAY_ITEM('view_discrepancies.project','highlight');
      DISPLAY_ITEM('view_discrepancies.week','highlight');
      DISPLAY_ITEM('view_discrepancies.pc_code','highlight');
      DISPLAY_ITEM('view_discrepancies.bundle','highlight');
      DISPLAY_ITEM('view_discrepancies.dropper','highlight');
      DISPLAY_ITEM('view_discrepancies.binvest_flag','highlight');
      DISPLAY_ITEM('view_discrepancies.display_bslip_changed','highlight');
      DISPLAY_ITEM('view_discrepancies.box_id','highlight');
      DISPLAY_ITEM('view_discrepancies.box_time_ind','highlight');
      DISPLAY_ITEM('view_discrepancies.display_status','highlight');
      DISPLAY_ITEM('view_discrepancies.display_result','highlight');
   elsif substr(:view_discrepancies.discr_type,i,1) = 'L' then
         x:=x+1;
      :view_discrepancies.display_discr_type := :view_discrepancies.display_discr_type||' Bad LPU;';
       
   elsif substr(:view_discrepancies.discr_type,i,1) = 'C' then
         x:=x+1;
      :view_discrepancies.display_discr_type := :view_discrepancies.display_discr_type||' Critical LPU;';
-- highlighting the row in red when critical lpu
      DISPLAY_ITEM('view_discrepancies.display_discr_type','highlight');
      DISPLAY_ITEM('view_discrepancies.onc','highlight');
      DISPLAY_ITEM('view_discrepancies.project','highlight');
      DISPLAY_ITEM('view_discrepancies.week','highlight');
      DISPLAY_ITEM('view_discrepancies.pc_code','highlight');
      DISPLAY_ITEM('view_discrepancies.bundle','highlight');
      DISPLAY_ITEM('view_discrepancies.dropper','highlight');
      DISPLAY_ITEM('view_discrepancies.binvest_flag','highlight');
      DISPLAY_ITEM('view_discrepancies.display_bslip_changed','highlight');
      DISPLAY_ITEM('view_discrepancies.box_id','highlight');
      DISPLAY_ITEM('view_discrepancies.box_time_ind','highlight');
      DISPLAY_ITEM('view_discrepancies.display_status','highlight');
      DISPLAY_ITEM('view_discrepancies.display_result','highlight');
   elsif substr(:view_discrepancies.discr_type,i,1) = 'M' then
         x:=x+1;
      :view_discrepancies.display_discr_type := :view_discrepancies.display_discr_type||' Bad Box ID;';
   elsif substr(:view_discrepancies.discr_type,i,1) = '#' then
         x:=x+1;
      :view_discrepancies.display_discr_type := :view_discrepancies.display_discr_type||' No BOX ID;';
   elsif substr(:view_discrepancies.discr_type,i,1) = 'O' then
         x:=x+1;
      :view_discrepancies.display_discr_type := :view_discrepancies.display_discr_type||' Bad Closing Time;';
   elsif substr(:view_discrepancies.discr_type,i,1) = 'F' then
          x:=x+1;
      :view_discrepancies.display_discr_type := :view_discrepancies.display_discr_type||' Fcast Box Missing;';
   end if;
   if i = 6 then
      :view_discrepancies.display_discr_type := substr(:view_discrepancies.display_discr_type,2);
   end if;
   if x>1 then
         DISPLAY_ITEM('view_discrepancies.display_discr_type','highlight');
      DISPLAY_ITEM('view_discrepancies.onc','highlight');
      DISPLAY_ITEM('view_discrepancies.project','highlight');
      DISPLAY_ITEM('view_discrepancies.week','highlight');
      DISPLAY_ITEM('view_discrepancies.pc_code','highlight');
      DISPLAY_ITEM('view_discrepancies.bundle','highlight');
      DISPLAY_ITEM('view_discrepancies.dropper','highlight');
      DISPLAY_ITEM('view_discrepancies.binvest_flag','highlight');
      DISPLAY_ITEM('view_discrepancies.display_bslip_changed','highlight');
      DISPLAY_ITEM('view_discrepancies.box_id','highlight');
      DISPLAY_ITEM('view_discrepancies.box_time_ind','highlight');
      DISPLAY_ITEM('view_discrepancies.display_status','highlight');
      DISPLAY_ITEM('view_discrepancies.display_result','highlight');
         end if;
end loop;

-- Populate display_status
if :view_discrepancies.bundle is not null then
if :view_discrepancies.status is null then
   if substr(:view_discrepancies.discr_type,1,1) = 'B' then
      :view_discrepancies.display_status := 'M-Team Ready';
--      :view_discrepancies.status := '2';
   else
      :view_discrepancies.display_status := 'A-Team Ready';
--      :view_discrepancies.status := '1';
   end if;
elsif :view_discrepancies.status = '1' then
   :view_discrepancies.display_status := 'A-Team Ready';
elsif :view_discrepancies.status = '2' then
   :view_discrepancies.display_status := 'M-Team Ready';
elsif :view_discrepancies.status = '3' then
   :view_discrepancies.display_status := 'Workroom Ready';
elsif :view_discrepancies.status = '4' then
   :view_discrepancies.display_status := 'Complete';
elsif :view_discrepancies.status = '5' then
   :view_discrepancies.display_status := 'M-Team In Progress';
end if;
end if;

--Populate display_result
if :view_discrepancies.result is not null then
   select substr(description,1,30)
   into :view_discrepancies.display_result
   from ttms_codes
   where type = 'CBMS DISCREPANCY RESULT' and
         code = :view_discrepancies.result;
end if;


-- Populate dropper_id
begin
   select a.dropper
   into :view_discrepancies.drop_id
   from induction_info a
   where a.bundle = to_number(:view_discrepancies.bundle);
exception
 when no_data_found then
  null;
end;

END;

The thing works fine except for when there are more than 3 discrepancy types.  When this happens, I get a POST-QUERY raised unhandled exception ORA-06502.  Is there something in the trigger that needs to be changed, or is there someother place in the form I should be looking to update.
Thanks
I would like to have this completed by COB today.
0
Comment
Question by:christie_holtz
[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
3 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 500 total points
ID: 12047384
0
 
LVL 22

Expert Comment

by:Helena Marková
ID: 12051519
Maybe the problem is caused by an item :view_discrepancies.bundle. Is it always a number in a string ?

-- Populate dropper_id
begin
   select a.dropper
   into :view_discrepancies.drop_id
   from induction_info a
   where a.bundle = to_number(:view_discrepancies.bundle);
exception
 when no_data_found then
  null;
end;
0
 
LVL 9

Expert Comment

by:konektor
ID: 12063717
what type is ":view_discrepancies.bundle". the error occurs when u r converting strings variable to number in cases, when variable does'n hold number.

ORA-06502 PL/SQL: numeric or value errorstring
Cause: An arithmetic, numeric, string, conversion, or constraint error occurred. For example, this error occurs if an attempt is made to assign the value NULL to a variable declared NOT NULL, or if an attempt is made to assign an integer larger than 99 to a variable declared NUMBER(2).
Action: Change the data, how it is manipulated, or how it is declared so that values do not violate constraints.

0

Featured Post

Webinar: Security & Encryption in the MySQL world

Join Percona’s Solutions Engineer, Dimitri Vanoverbeke as he presents “Security and Encryption in the MySQL world” on Thursday, July 6, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

Question has a verified solution.

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

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 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