Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6956975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:56:21+00:00 2026-05-27T14:56:21+00:00

I am trying to execute a cursor and want it to complete the loop

  • 0

I am trying to execute a cursor and want it to complete the loop even if there is some exception.

What I trying to do is "catch" all the exception and probably log something or do nothing and then return back to the flow . Here is how the code looks like:

 FOR line IN my_cursor
 LOOP
 begin
        
    if<condition> then
      GOTO pass; 
    else     
     <<do_something>>
     exception
       when others then
        sys.dbms_output.put_line('say something');       
    end if;  

    <<pass>> null;
 end
 END LOOP;

The script doesn’t compile.

There is probably some syntax error with the exception, but I am also not aware of semantics very well. Like I am not sure if you can return back to execution flow after handling an exception.

p.s: The DB is 10g and there is not CONTINUE in it. Hence using GOTO.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:56:22+00:00Added an answer on May 27, 2026 at 2:56 pm

    Put the code that you want to execute within the loop in it’s own block and then you can use that blocks exception section to handle any problems during the loop iteration.

    Once the exception for that iteration is handled, the next loop iteration will start

    e.g.:

    for line in my_cursor
    loop
       begin    
          <<do_something>>
       exception
          <<do_exception_processing>>        
       end;
    end loop;
    

    To illustrate this further, in the example below, I have declared a local variable of type exception. I am looping through numbers 1 to 10, during the second loop iteration, the if statement is true and processing passes to the exception handler. Once the exception is handled, the next iteration of the loop begins.

    begin
    
       for i in 1 .. 10 
       loop
    
          declare
    
             my_exception exception;
    
          begin
    
             if i = 2
             then
    
                -- if you need to do some processing then you would enter it
                -- here and then when you want to enter the exception section 
                -- you would add the line below 
    
                raise my_exception;
    
             end if;
    
          exception
             when my_exception then
                dbms_output.put_line('in exception section');
    
          end;
    
       end loop;
    
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do the following query: cursor.execute(SELECT DISTINCT(provider) FROM raw_financials WHERE vendor_id=%s
I'm trying to get this Python MYSQL update statement correct(With Variables): cursor.execute (UPDATE tblTableName
I am trying to do an INSERT into MySQL using the cursor.execute(sql, args) syntax.
While trying to execute the following lines only the last two statements are displayed(Here
I am trying to execute this SQL query prior to restoring a .BAK file
I am trying to execute a stored procedured from a linked database in MS
I am trying to execute this SQL command: SELECT page.page_namespace, pagelinks.pl_namespace, COUNT(*) FROM page,
I'm trying to execute a asp.net webservice using jquery. When I pass only one
I am trying to execute this but cant see any result: <script> function init()
I'm trying to execute the following line: exit | sqlplus username/password@sid @test.sql Works great

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.