I'm calling a function from pl/sql, but I do not require the result in this case. Is there a cleaner way to call this function without using a dummy variable?


junk := performWork();

Does not work:

performWork();         --PLS-00221: performWork is not a procedure or is undefined
EXEC performWork();    --this might work from SQL*Plus, but not from pl/sql
SELECT pkg.performWork() FROM DUAL;  --PLS-00428: INTO clause is expected in this SELECT statement
  • I suspect this sort of questions is more on-topic at SO. – Yasir Arsanukaev Jun 10 '13 at 14:13
  • 2
    If you don't want the output from a function, why do you need to call it? Normally if something is going to 'perform work', then that something is a procedure, not a function. – Jack Douglas Jun 10 '13 at 14:20

Your options are:

  1. Assign the result to a dummy variable:

    junk := perform_work;
  2. Select the result into a dummy variable:

    select perform_work into junk from dual;
  3. Create an implicit cursor in a loop:

    for i in ( select perform_work from dual ) loop
    end loop;
  4. If the function does not need to be called from SQL you could change it into a procedure with an OUT parameter, though this still requires a "junk" variable it might look very slightly cleaner?


If you don't want to use this function though, why not just remove it from your code?

The only time I can think of there being a valid use-case for this sort of structure is when you're running identical code in two different schemas/on two different databases but this function is useless in one of them. If that's the case the function is still useful in the other and so you will want to do something with the result anyway.

  • In one case, I need the ID returned by the function for further processing. In the other case I don't. Thought perhaps I was missing some obvious syntax that would allow me to do this. – Matter Jul 19 '13 at 17:32

Test it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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