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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:35:45+00:00 2026-05-27T21:35:45+00:00

Query DECLARE v_vendor_id NUMBER; BEGIN FOR vp_rec IN ( SELECT * FROM vpprocess )

  • 0

Query

DECLARE
  v_vendor_id NUMBER;
BEGIN
  FOR vp_rec IN ( SELECT * FROM vpprocess )
    LOOP
      SELECT i.vendor_id INTO v_vendor_id FROM item i, lineitems l WHERE l.itemid = i.itemid AND l.id = vp_rec.lineitemid;
        EXCEPTION
            WHEN no_data_found THEN SELECT 0 INTO v_vendor_id FROM dual;
      UPDATE vpprocess SET vendorid = v_vendor_id WHERE vpprocessid = vp_rec.vpprocessid;
    END;
  END LOOP;
END;

Error Message

 Error starting at line 1 in command:
DECLARE
  v_vendor_id NUMBER;
BEGIN
  FOR vp_rec IN ( SELECT * FROM vpprocess )
    LOOP
      SELECT i.vendor_id INTO v_vendor_id FROM item i, lineitems l WHERE l.itemid = i.itemid AND l.id = vp_rec.lineitemid;
        EXCEPTION
            WHEN no_data_found THEN SELECT 0 INTO v_vendor_id FROM dual;
      UPDATE vpprocess SET vendorid = v_vendor_id WHERE vpprocessid = vp_rec.vpprocessid;
    END;
  END LOOP;
END;
Error report:
ORA-06550: line 7, column 9:
PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:

   begin case declare 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> <<
   close current delete fetch lock insert open rollback
   savepoint set sql execute commit forall merge pipe
ORA-06550: line 11, column 7:
PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:

   ;
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:
  • 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-27T21:35:45+00:00Added an answer on May 27, 2026 at 9:35 pm

    You’re using the wrong syntax for your FOR loop. The error message tells you exactly what’s wrong. Instead of the word BEGIN PUT LOOP.

    As a personal rule, I never use BEGIN IN PL/SQL with very few exceptions, such as if I need to trap exceptions only on a certain block of code, and that code isn’t already a loop or function body or whatever.

    Edit based on OP’s edit: this appears to be one of those cases. Try the following:

    DECLARE
      v_vendor_id NUMBER;
    BEGIN
      FOR vp_rec IN ( SELECT * FROM vpprocess )
        LOOP
         BEGIN
           SELECT i.vendor_id INTO v_vendor_id FROM item i, lineitems l WHERE l.itemid = i.itemid AND l.id = vp_rec.lineitemid;
            EXCEPTION
                WHEN no_data_found THEN v_vendor_id := 0;
          END;  
          UPDATE vpprocess SET vendorid = v_vendor_id WHERE vpprocessid = vp_rec.vpprocessid;
        /* END; has been removed */
        END LOOP;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A query runs fast: DECLARE @SessionGUID uniqueidentifier SET @SessionGUID = 'BCBA333C-B6A1-4155-9833-C495F22EA908' SELECT * FROM
I have a query: declare @Code nvarchar(100) select @Code=BMW select name from NewCars where
Take a standard broad search query...: DECLARE @sq Varchar(50) = 'Desperate' SELECT * FROM
I have the following query: DECLARE @IsStocked bit SELECT * FROM Products p WHERE
Let's say I have this SQL query: declare @input varchar(20) select * from myTable
I have a query like below declare @str_CustomerID int Insert into IMDECONP38.[Customer].dbo.CustomerMaster ( CustomerName
Query: SELECT DISTINCT ([Equipment List].ID) AS Expr1, [Job Assignments].Job FROM [Equipment List] LEFT JOIN
Given this EXACT ad-hoc query: DECLARE @list AS TABLE (Name VARCHAR(20)) INSERT INTO @list(Name)
I have the the following SQL query Declare @tempcalctbl Table ( ItemId varchar(50), ItemLocation
Here is my query Declare @StartDateTime datetime, @EndDateTime datetime Select @StartDateTime = '2010-11-15', @EndDateTime

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.