2

I have the following SELECT statement:

SELECT AUDITORID 
        FROM SOL.GROUPS WHERE STATUS = 1;

I need for each AUDITORID that returns the statemnet to call the procedure INSERT_LD_PER_AUDITOR (VAUDITORID)

how to do that?

3
  • @Pirate nothing make some inserts Commented Oct 7, 2016 at 11:57
  • 1
    docs.oracle.com/database/121/LNPLS/… Commented Oct 7, 2016 at 11:58
  • Do you mind sharing what insert_ld_per_auditor does? I suspect you would be much better off changing the procedure to execute on a whole data set at once instead of individual "auditors". That way, you can avoid cursors all together, which would be much better. Commented Oct 7, 2016 at 12:18

2 Answers 2

4

If you're sure you want loop you can use:

begin
  for x in (SELECT AUDITORID FROM SOL.GROUPS WHERE STATUS = 1) loop
      INSERT_LD_PER_AUDITOR(x.AUDITORID);
  end loop;
end;

but as sstan wrote it is probably better to refactor procedure to process all data.

Sign up to request clarification or add additional context in comments.

Comments

0

You cant call procedure via SQL statement And you have at least 2 ways how to resolve it. 1) Create pl_sql function and set call procedure into function

create or replace function F_INSERT_LD_PER_AUDITOR (VAUDITORID NUMBER) 
   return NUMBER
is 
begin 
  NSERT_LD_PER_AUDITOR (VAUDITORID);
  return 0;
end;
/

and call it function

SELECT F_INSERT_LD_PER_AUDITOR(AUDITORID)
    FROM SOL.GROUPS WHERE STATUS = 1;

2) wirte pl/sql and use LOOP as in previous comment

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.