Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Exception handling within a for loop.

604514Mar 26 2008 — edited Mar 27 2008
Hello, I have spent some time trying to fix the syntax so I can handle the exception when no data found is found when trying to allocate data to a variable. If this is the case I want the code to assign just string := ' ';

Below is my attempt to solve it (which does not work). All help greatly appreciated:

Here is the part of the code where the problem is:
select substr(REPLACE(BBC.business_class_level_2_name,   ',',   ''),1,50)
into substring1 from tmsdat.a_secs_business_class BBC
where tupel.sec_ref = BBC.sec_ref;

Exception 
  when no_data_found then 
    substring1 := '';
    COMMIT;
    ROLLBACK;
End;

select substr(REPLACE(BBC.business_class_level_3_name,   ',',   ''),1,50)
into substring2 from tmsdat.a_secs_business_class BBC
where tupel.sec_ref = BBC.sec_ref;

Exception 
  when no_data_found then 
    substring2 := '';
    COMMIT;
    ROLLBACK;
End;

etc
[\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2008
Added on Mar 26 2008
8 comments
558 views