-3

I'm getting an error PLS-00103 on the second IF statement in the LOOP.

[Error] PLS-00103 (17: 13): PLS-00103: Encountered the symbol "IF" when expecting one of > the following:

. ( * @ % & - + / at mod remainder rem then and or || multiset The symbol "then" was substituted f....

Here's the procedure and the columns in the update both contain primary keys so there is no possibility of a null. The role-id column has a NO NULL constraint.

create procedure sp_fix_property_role as
-- make sure the role_id contains an offense_party_id 
 cursor curs_property is select p.* 
    from  t_offense o inner join t_property p on p.offense_id = o.offense_id
    where receive_date > to_date('12/01/2013','mm/dd/yyyy');

cursor curs_offense_party is select op.* 
    from t_offense_party op inner join t_offense o on o.offense_id = op.offense_id
    where receive_date > to_date('12/01/2013','mm/dd/yyyy'); 

begin for cp1 in curs_property loop
    for co1 in curs_offense_party loop
--when property offense = offense party offense
    --and property role <> offense party id    
        if cp1.offense_id = co1.offense_id
            if cp1.role_id <> co1.offense_party_id then
    --then find property role = offense party person
                if cp1.role_id = co1.person_id then
     --replace property role with offense party id
                    update t_property set t_property.role_id = co1.offense_party_id
                        where t_property.property_id = cp1.property_id;
                 end if;
            end if;
         end if;
    end loop; end loop; end sp_fix_property_role;

This is being compiled in TOAD with 11g client

oaksong

1
  • 3
    Please edit your question and include the exact text of the error messages you're receiving. And you might want to fix up the declaration of the curs_property cursor. Thanks. Jul 25, 2014 at 21:26

1 Answer 1

0
  1. Added "or replace" after CREATE
  2. Added a line feed before the two instances of LOOP so it looks like this:

    for cp1 in curs_property 
    loop
       for co1 in curs_offense_party 
       loop
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.