Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

restrict multiple executions of a procedure

user634631Jul 24 2015 — edited Jul 28 2015

Hi All,

I would like to restrict concurrent executions of a procedure. In other words, would like to serialize it. Simple enough, I can use locking mechanism for this but this procedure has an out parameter which is a ref cursor and the lock will eventually be released as soon as the ref cursor is opened and the control reaches the end of the procedure but I would like is to restrict the users from not being able to execute this procedure again until that ref cursor is closed. Is there a way that this can be achieved from with in Oracle DB?

Sample Code:

CREATE OR REPLACE PROCEDURE SH.SALES_BY_PRODUCT(P OUT SYS_REFCURSOR) IS

BEGIN

..... --Lock here

  OPEN P FOR

    SELECT PROD_ID, SUM(AMOUNT_SOLD) AS AMOUNT FROM SH.SALES GROUP BY PROD_ID;

..... --Release the lock here --This approach of locking is not helping as the lock is released even before the cursor P is closed by the calling application.

END;

Thanks!

This post has been answered by RogerT on Jul 24 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 25 2015
Added on Jul 24 2015
21 comments
4,982 views