Home » SQL & PL/SQL » SQL & PL/SQL » Need help with an exception
Need help with an exception [message #9238] Tue, 28 October 2003 07:30 Go to next message
Tony Grace
Messages: 23
Registered: August 2003
Junior Member
What I am trying to do is a simple pass using pl/sql from one table to another to verify what item_type_code each product_id is identified with...here is my problem. some of the product_Id's are no longer available so when I do my exception for no data found it exits my loop so I thought I would do something like after my begin

Begin

G_counter :=0

open G_cursor
loop
fetch G_cursor into
G_product_id
exit when G_cursor%not found;

select item_type_code
into G_item_type_code
from product
where G_product = product.product_id

Exception When no data found then
v_item_type_code = 'obsolete';

update product_update
set product_type_code =v_item_type_code
where G_product = product.product_id;

It stops after one tho....any hints or help on how I can do this so it runs a complete pass on all rows...should I not be using an exception in this case?

Thanks for any help or ideas you can provide
Re: Need help with an exception [message #9242 is a reply to message #9238] Tue, 28 October 2003 11:46 Go to previous messageGo to next message
sverch
Messages: 582
Registered: December 2000
Senior Member
Where is your G_cursor cursor?
Re: Need help with an exception [message #9249 is a reply to message #9238] Wed, 29 October 2003 02:05 Go to previous message
sprs
Messages: 2
Registered: October 2003
Junior Member
If i'm not mistaken this should work. Try this
Begin

G_counter :=0;

begin
open G_cursor;
loop;
fetch G_cursor into G_product_id;
exit when G_cursor%not found;
BEGIN
select item_type_code into G_item_type_code
from product
where G_product = product.product_id;
Exception When no data found then
v_item_type_code = 'obsolete';
END;

update product_update
set product_type_code =v_item_type_code
where G_product = product.product_id;
end loop;
END;
END;
Previous Topic: Data migration
Next Topic: query
Goto Forum:
  


Current Time: Thu Apr 25 17:17:30 CDT 2024