How to restrict the stored procedure calling twice on submit ?


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, 2012 at 06:21 PM in Default

avatar image

361 18 20 26

(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, 2012 at 05:18 AM

avatar image

Usman Butt
14.9k 6 13 21

@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, 2012 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, 2012 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, 2012 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, 2012 at 07:20 PM

avatar image

Grant Fritchey ♦♦
137k 20 47 81

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, 2012 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, 2012 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, 2012 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, 2012 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.

Follow this question

By Email:

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



Answers and Comments

SQL Server Central

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



asked: Aug 07, 2012 at 06:21 PM

Seen: 3631 times

Last Updated: Aug 18, 2012 at 04:31 AM

Copyright 2018 Redgate Software. Privacy Policy