0

I have a sample pl/sql that does not compile. i have 4 errors and cannot figure out where it is. i have attempted process of isolation and yet i cannot find out the missing piece

CREATE OR REPLACE PACKAGE TestLocks AS


  PROCEDURE testBlocks(in_iteration IN number, in_loop_no IN number, z OUT number) ;
  END TestLocks;

/

CREATE OR REPLACE PACKAGE TestLocks IS
 PROCEDURE testBlocks(in_iteration IN NUMBER, in_loop_no IN NUMBER, z OUT NUMBER) IS
BEGIN
  startdate:=sysdate;
update test_locks
set last_datetime=startdate
 where loop_no =in_loop_no;
 -- do loop


 FOR i IN in_iteration  LOOP
 update test_locks
set last_datetime=startdate
 where loop_no =in_iteraction;

  END LOOP;
END;


END TestLocks;
/
junkone
  • 1,427
  • 1
  • 20
  • 45
  • Sow what does `show errors` give you? (**[edit]** your question. Do **not** post code or additional information in comments) –  May 08 '18 at 14:31
  • Is that just a typo, or did you really forget the word **body** in the second **CREATE OR REPLACE**? `CREATE OR REPLACE PACKAGE BODY TestLocks IS ...` –  May 08 '18 at 14:35
  • Can you explain what exactly are you trying to do in your `for loop` ? – Kaushik Nayak May 08 '18 at 14:49

1 Answers1

1
CREATE OR REPLACE PACKAGE TestLocks AS
  PROCEDURE testBlocks(in_iteration IN number, in_loop_no IN number, z OUT number) ;
END TestLocks;

CREATE OR REPLACE PACKAGE BODY TestLocks IS
 PROCEDURE testBlocks(in_iteration IN NUMBER, in_loop_no IN NUMBER, z OUT NUMBER) IS
startdate date;
BEGIN
  startdate:=sysdate;
update test_locks
set last_datetime=startdate
 where loop_no =in_loop_no;
 -- do loop

 FOR i IN 1..in_iteration  LOOP
     update test_locks
    set last_datetime=startdate
     where loop_no =in_iteraction;

  END LOOP;
END;
END TestLocks;
  • The `for loop` will run the update on same row multiple times. I don't see why one wants to do that. – Kaushik Nayak May 08 '18 at 14:52
  • The tables are prefixed with "test" word, so it might be not the exact use case but something like that where he/she will update the table and column name later? btw question is for why the package is not getting compiled. :P, –  May 08 '18 at 15:01