5 Replies - 2679 Views - Last Post: 05 February 2013 - 09:52 AM Rate Topic: -----

#1 albert018  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 07-January 13

Calling the procedure at the same time

Posted 05 February 2013 - 04:35 AM

There is a button for calculating score in website.

Each time the user click this button, it will call the Oracle procedure to calculate score.

The process of calculating score spends almost 2 minutes.

The problem is that there are two users click this button in the meantime.

The second user will get a error message because the first one is still in process.

Is there any solution to limit the second user to click this button before the first one finished.

Is This A Good Question/Topic? 0
  • +

Replies To: Calling the procedure at the same time

#2 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1182
  • View blog
  • Posts: 1,677
  • Joined: 24-August 11

Re: Calling the procedure at the same time

Posted 05 February 2013 - 07:24 AM

Disable the button as soon as you fire the Oracle procedure, and once the procedure has finished running, enable the button.
Was This Post Helpful? 1
  • +
  • -

#3 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 284
  • View blog
  • Posts: 1,502
  • Joined: 07-April 08

Re: Calling the procedure at the same time

Posted 05 February 2013 - 07:50 AM

There is a lot of context missing to really form an accurate response.

1. Are the users using the same machine?
2. What is happening in the procedure that calculates the scores?
3. What is the error that the second user gets?

If the users are not using the same machine then a solution to stopping the 2nd user would be to set a flag in the database, and have the website check that every so often and disable the button if it is set to true.
Was This Post Helpful? 1
  • +
  • -

#4 albert018  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 07-January 13

Re: Calling the procedure at the same time

Posted 05 February 2013 - 08:37 AM

1.The users are not using the same machine.

2.The procedure is to delete existed data first, then insert into calculated data again.(which means that the table is being locked)

3.The error message is related to the locked table.(I guess that it is because of trying to manipulate the locked table)

Actually I have considered about the solution of database flag.But what I worry is some exceptions.

For example.The user might get shutdown during the process of calculating score.

Or the user might think that the process spends too much time, then just close the explorer.

When these situations happen, the database flag might be 「locked」 permanently.

So I am just curious about how to avoid these exceptions ?

By the way:「h4nnib4l」 and 「rgfirefly24」 , thanks for you two suggestions. That is really helpful. ^ ^
Was This Post Helpful? 0
  • +
  • -

#5 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1182
  • View blog
  • Posts: 1,677
  • Joined: 24-August 11

Re: Calling the procedure at the same time

Posted 05 February 2013 - 09:42 AM

Check out this question and reply about using the Server.EnumLocks method to check if the table is locked or not. Here's the MSDN page for the method: Server.EnumLocks. I've never used this, so I can't tell you how well it works (or if it will work for your purpose) but it's worth a shot.

EDIT: Good call rgfirefly24, please disregard this. I'll leave it in case anyone wanders in here with the same question about a SQL Server.

This post has been edited by h4nnib4l: 05 February 2013 - 04:07 PM

Was This Post Helpful? 0
  • +
  • -

#6 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 284
  • View blog
  • Posts: 1,502
  • Joined: 07-April 08

Re: Calling the procedure at the same time

Posted 05 February 2013 - 09:52 AM

@h4nnib4l Since he is working in Oracle he does not have the Server.EnumLocks available to him.

What I would suggest is that you have a Job that runs and checks the flag and if it has set locked for so long and the table is not locked flip it. That being said there are probably a lot of better options then using a flag.

another question

Is the data being deleted/updated the same between users or different "Sets" of data out of this table?

Here is something that might be a good read for you:
Oracle Locking and Concurrency

This post has been edited by rgfirefly24: 05 February 2013 - 09:57 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1