Oracle Stored Procedure Question

When trying to compile this oracle stored procedure I keep getting an error stating "Error(69,1): PLS-00103: Encountered the symbol "END" "  Can someone help me out as to why?  I thought I was supposed to put an end there because I had a corresponding BEGIN at the top.
create or replace
PROCEDURE GET_CONFLICT_VOLUME(pJunction       IN VARCHAR2,
                              pPipeline       IN VARCHAR2,
                              pBatchCode      IN VARCHAR2,
                              pStartDateTime  IN VARCHAR2,
                              pFinishDateTime IN VARCHAR2,
                              pConflictVolume OUT VARCHAR2) IS
                                
                              pStartToCheck DATE;
                              pEndToCheck DATE;
                              pVolume NUMBER;
                              
  CURSOR C1 IS
  SELECT START_DATE_TIME, FINISH_DATE_TIME
    FROM sch_fie_events
   WHERE rate > 0
     AND shipper || '-' || product || '-' || cycle || phase = pBatchCode
     AND junction = pJunction
     AND pipeline = pPipeline
     AND STATION = 'S00'
     AND (to_date(pStartDateTime, 'mm/dd/yyyy hh:mi:ss am') between START_DATE_TIME and FINISH_DATE_TIME
     OR to_date(pFinishDateTime, 'mm/dd/yyyy hh:mi:ss am') between START_DATE_TIME and FINISH_DATE_TIME);

  BEGIN     

     pVolume := 0;

     FOR rec IN C1.count
     
       LOOP
        
        IF START_DATE_TIME < to_date(pStartDateTime, 'mm/dd/yyyy hh:mi:ss am') THEN
          pStartToCheck := to_date(pStartDateTime, 'mm/dd/yyyy hh:mi:ss am');
        ELSE
          pStartToCheck := START_DATE_TIME;
        END IF;
        
        IF END_DATE_TIME > to_date(pEndDateTime, 'mm/dd/yyyy hh:mi:ss am') THEN
          pEndToCheck := to_date(pEndDateTime, 'mm/dd/yyyy hh:mi:ss am');
        ELSE
          pEndToCheck := END_DATE_TIME;
        END IF;
        
        BEGIN
        
         SELECT rate * ((to_date(pEndToCheck, 'mm/dd/yyyy hh:mi:ss am') - to_date(pStartToCheck, 'mm/dd/yyyy hh:mi:ss am')) * 24)
          INTO pVolume
          FROM sch_fie_events
          WHERE rate > 0
           AND shipper || '-' || product || '-' || cycle || phase = pBatchCode
           AND junction = pJunction
           AND pipeline = pPipeline
           AND STATION = 'S00'
           AND (to_date(pStartDateTime, 'mm/dd/yyyy hh:mi:ss am') between START_DATE_TIME and FINISH_DATE_TIME
           OR to_date(pFinishDateTime, 'mm/dd/yyyy hh:mi:ss am') between START_DATE_TIME and FINISH_DATE_TIME);
        
        END; 
        
        pVolume := pVolume + pVolume;       
       
      END LOOP;
      
      pConflictVolume := to_char(pVolume);
       
END; <----- Error Here

  

END GET_CONFLICT_VOLUME;

Open in new window

jmpattonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

anumosesCommented:
create or replace
PROCEDURE GET_CONFLICT_VOLUME(pJunction       IN VARCHAR2,
                              pPipeline       IN VARCHAR2,
                              pBatchCode      IN VARCHAR2,
                              pStartDateTime  IN VARCHAR2,
                              pFinishDateTime IN VARCHAR2,
                              pConflictVolume OUT VARCHAR2) IS
                               
                              pStartToCheck DATE;
                              pEndToCheck DATE;
                              pVolume NUMBER;
                             
  CURSOR C1 IS
  SELECT START_DATE_TIME, FINISH_DATE_TIME
    FROM sch_fie_events
   WHERE rate > 0
     AND shipper || '-' || product || '-' || cycle || phase = pBatchCode
     AND junction = pJunction
     AND pipeline = pPipeline
     AND STATION = 'S00'
     AND (to_date(pStartDateTime, 'mm/dd/yyyy hh:mi:ss am') between START_DATE_TIME and FINISH_DATE_TIME
     OR to_date(pFinishDateTime, 'mm/dd/yyyy hh:mi:ss am') between START_DATE_TIME and FINISH_DATE_TIME);

  BEGIN    

     pVolume := 0;

     FOR rec IN C1.count
     
       LOOP
       
        IF START_DATE_TIME < to_date(pStartDateTime, 'mm/dd/yyyy hh:mi:ss am') THEN
          pStartToCheck := to_date(pStartDateTime, 'mm/dd/yyyy hh:mi:ss am');
        ELSE
          pStartToCheck := START_DATE_TIME;
        END IF;
       
        IF END_DATE_TIME > to_date(pEndDateTime, 'mm/dd/yyyy hh:mi:ss am') THEN
          pEndToCheck := to_date(pEndDateTime, 'mm/dd/yyyy hh:mi:ss am');
        ELSE
          pEndToCheck := END_DATE_TIME;
        END IF;
       
        BEGIN
       
         SELECT rate * ((to_date(pEndToCheck, 'mm/dd/yyyy hh:mi:ss am') - to_date(pStartToCheck, 'mm/dd/yyyy hh:mi:ss am')) * 24)
          INTO pVolume
          FROM sch_fie_events
          WHERE rate > 0
           AND shipper || '-' || product || '-' || cycle || phase = pBatchCode
           AND junction = pJunction
           AND pipeline = pPipeline
           AND STATION = 'S00'
           AND (to_date(pStartDateTime, 'mm/dd/yyyy hh:mi:ss am') between START_DATE_TIME and FINISH_DATE_TIME
           OR to_date(pFinishDateTime, 'mm/dd/yyyy hh:mi:ss am') between START_DATE_TIME and FINISH_DATE_TIME);
       
        END;
       
        pVolume := pVolume + pVolume;      
       
      END LOOP;
     
      pConflictVolume := to_char(pVolume);
       
 

END GET_CONFLICT_VOLUME;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MilleniumaireCommented:
You have two BEGIN's, but three END's, so the identified END is not required.
anumosesCommented:
Either have End;
or
END GET_CONFLICT_VOLUME;

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.