x

How to restrict the stored procedure calling twice on submit ?

Hi,

Is there any approach in stored procedure code level to restrict the procedure to call twice on SUBMIT button.

waiting for your valuable inputs.
more ▼

asked Aug 07 '12 at 06:21 PM in Default

satya gravatar image

satya
361 18 18 21

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first
Prevention of user submitting twice should be handled at application level. This is the best way of doing it. I do not think handling it at database level would help your cause. You may end up with something undesired.
more ▼

answered Aug 08 '12 at 05:18 AM

Usman Butt gravatar image

Usman Butt
13.9k 6 8 14

@Usman I've seen this during my years as a web developer. It isn't always the user clicking twice, some other weirdness happens that calls the stored proc twice. It is usually less than 10ms apart--too quick for consecutive clicks. This was especially concerning for us during credit card processing apps.
Aug 08 '12 at 11:10 PM Scot Hauder
agree, the UI needs to handle this. the first step in the code needs to disable the button, then go on to make the request to the database. Logic in the database to recognise duplicate requests within NN (milli)seconds could also help but the UI needs to prevent the user causing the problem.
Aug 09 '12 at 09:18 AM Fatherjack ♦♦

@Scot In that case It still smells like the web application OR application server being the culprit. Some serious Stress/Regression Testing with different option like very low network latency etc on application side needs to be done.

Since I am sure there would be an/multiple application server/s being working as the middle-were, a check with NN milliseconds may still not be the best choice as it may cause some unwanted rollbacks.
Aug 09 '12 at 10:08 AM Usman Butt
(comments are locked)
10|1200 characters needed characters left
You're saying that you want to execute the procedure two times? Then I would either execute it twice or just run the command within it two times.
more ▼

answered Aug 07 '12 at 07:20 PM

Grant Fritchey gravatar image

Grant Fritchey ♦♦
91k 19 21 74

Thank you Grant, I don`t want to call it twice. If the user accidentally clicks twice on SUBMIT button, Stored Procedure calls twice.

In this situation how to restrict the second call from db side.
Aug 08 '12 at 03:15 AM satya
That's different than what you asked. In this case, any data submitted should have a unique constraint on the table to prevent duplicate data from being entered. That's all you have to do. Clicking submit any number of times will cause the insert to fail.
Aug 08 '12 at 09:53 AM Grant Fritchey ♦♦
Hey @satya, I just looked, after 18 questions you've never accepted an answer on any of them. If someone has helped you out, please mark the question answered by clicking on the check box under the appropriate answer. It's just below the little thumbs down symbol.
Aug 08 '12 at 09:58 AM Grant Fritchey ♦♦
Sorry @grant, till now i didn`t notice that one. I got answers for all my questions.
Aug 18 '12 at 04:31 AM satya
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x977
x402

asked: Aug 07 '12 at 06:21 PM

Seen: 1341 times

Last Updated: Aug 18 '12 at 04:31 AM