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 3981046
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:21:47+00:00 2026-05-20T05:21:47+00:00

Here is the script that i wrote and it has weird syntax error at

  • 0

Here is the script that i wrote and it has weird syntax error at EXCEPTION block. If i remove exception block the script compiles properly. but no sooner i write it back it gives me error

Error(58,11): PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:     ( begin case declare else elsif end exit for goto if loop mod    null pragma raise return select update while with    <an identifier> <a double-quoted delimited-identifier>    <a bind variable> << continue close current delete fetch lock    insert open rollback savepoint set sql execute commit forall    merge pipe purge 

Here is the script

LOOP
  BEGIN
    SAVEPOINT check_point;

    EXIT WHEN DBMS_SQL.FETCH_ROWS (cursor_handle) = 0;
    DBMS_SQL.COLUMN_VALUE (cursor_handle, 1,  cc , col_err, actual_len);
    DBMS_SQL.COLUMN_VALUE (cursor_handle, 2,  di, col_err, actual_len);

    IF INSTR (cc, '_') <> 0 THEN
      cc := Trim (cc);
      cc := Upper(cc);
      cc := substr(cc,4,2);

      EXECUTE IMMEDIATE 'UPDATE  ' || dest || ' SET cc = :v1 WHERE di = :v2' 
        USING cc, di;

      if SQL%ROWCOUNT > 0 THEN
        inserts := inserts + 1;
        counter := counter + 1;
        IF counter > 500 THEN
          counter := 0;
          COMMIT;
        END IF;
      END IF;

      EXCEPTION
        WHEN DUP_VAL_ON_INDEX THEN
          dups := dups+1;
          ROLLBACK TO check_point;
        WHEN VALUE_ERROR THEN
          valerr := valerr +1;
          ROLLBACK TO check_point;
        WHEN OTHERS THEN
          DBMS_OUTPUT.PUT_LINE('errno: ' || TO_CHAR(SQLCODE) || ' Msg: ' || SQLERRM);
          otherexc := otherexc +1;
        IF otherexc > 50 THEN 
          EXIT;
        END IF;
        ROLLBACK TO check_point;              
    END IF;
  END;
END LOOP;

I know its very annoying to ask such kind a question but i am unable to figure out what error is that. I am lehman at Pl/SQL.

  • 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-20T05:21:48+00:00Added an answer on May 20, 2026 at 5:21 am

    The error appears to be that your EXCEPTION clause is inside the IF INSTR (cc, '_') <> 0 IF statements but you appear to want to match the EXCEPTION to the BEGIN statement at the top of your loop. I believe that you want to move the END IF; for the IF INSTR (cc, '_') <> 0 before the EXCEPTION as I do here

    LOOP
      BEGIN
        SAVEPOINT check_point;
    
        EXIT WHEN DBMS_SQL.FETCH_ROWS (cursor_handle) = 0;
        DBMS_SQL.COLUMN_VALUE (cursor_handle, 1,  cc , col_err, actual_len);
        DBMS_SQL.COLUMN_VALUE (cursor_handle, 2,  di, col_err, actual_len);
    
        IF INSTR (cc, '_') <> 0 THEN
          cc := Trim (cc);
          cc := Upper(cc);
          cc := substr(cc,4,2);
    
          EXECUTE IMMEDIATE 'UPDATE  ' || dest || ' SET cc = :v1 WHERE di = :v2' 
            USING cc, di;
    
          if SQL%ROWCOUNT > 0 THEN
            inserts := inserts + 1;
            counter := counter + 1;
            IF counter > 500 THEN
              counter := 0;
              COMMIT;
            END IF; -- IF counter > 500
          END IF; -- IF SQL%ROWCOUNT > 0
        END IF; -- INSTR (cc, '_') <> 0
    
    
      EXCEPTION
        WHEN DUP_VAL_ON_INDEX THEN
          dups := dups+1;
          ROLLBACK TO check_point;
        WHEN VALUE_ERROR THEN
          valerr := valerr +1;
          ROLLBACK TO check_point;
        WHEN OTHERS THEN
          DBMS_OUTPUT.PUT_LINE('errno: ' || TO_CHAR(SQLCODE) || ' Msg: ' || SQLERRM);
          otherexc := otherexc +1;
          IF otherexc > 50 THEN 
            EXIT;
          END IF;
          ROLLBACK TO check_point;              
      END;
    END LOOP;
    

    That being said, however, I would probably rewrite the code a bit. Committing every 500 rows is almost certainly an error. I’m very dubious of your WHEN OTHERS exception handler– I would really think that you’d want to at least write the error to a table or populate a collection of errors rather than writing to the DBMS_OUTPUT buffer that may or may not ever be displayed.

    LOOP
      SAVEPOINT check_point;
    
      EXIT WHEN DBMS_SQL.FETCH_ROWS (cursor_handle) = 0;
      DBMS_SQL.COLUMN_VALUE (cursor_handle, 1,  cc , col_err, actual_len);
      DBMS_SQL.COLUMN_VALUE (cursor_handle, 2,  di, col_err, actual_len);
    
      IF INSTR (cc, '_') <> 0 THEN
        cc := Trim (cc);
        cc := Upper(cc);
        cc := substr(cc,4,2);
    
        BEGIN
          EXECUTE IMMEDIATE 'UPDATE  ' || dest || ' SET cc = :v1 WHERE di = :v2' 
            USING cc, di;
    
          if SQL%ROWCOUNT > 0 THEN
            inserts := inserts + 1;
          END IF; 
        EXCEPTION
          WHEN DUP_VAL_ON_INDEX THEN
            dups := dups+1;
            ROLLBACK TO check_point;
          WHEN VALUE_ERROR THEN
            valerr := valerr +1;
            ROLLBACK TO check_point;
          WHEN OTHERS THEN
            DBMS_OUTPUT.PUT_LINE('errno: ' || TO_CHAR(SQLCODE) || ' Msg: ' || SQLERRM);
            otherexc := otherexc +1;
            IF otherexc > 50 THEN 
              EXIT;
            END IF;
            ROLLBACK TO check_point;              
        END;
    
      END IF; -- INSTR (cc, '_') <> 0
    END LOOP;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.