Is it possible to take a user input during the time when the stored procedure runs? Like pause for a moment and ask for a user input and then continue?
There is a parameter #query inside my stored procedure and I want the option in which the user can modify the value of this parameter at a certain point of the procedure.
Possible?
No, I don't think this is possible.
You might want to look at CLR Stored Procedures:
http://technet.microsoft.com/en-us/library/ms131094.aspx
They allow the full .NET framework inside sprocs. But even then, I don't see how you could stop for user input.
You basically should not expect SP to do this. The correct way of making use of SP is actually separate what you wanna do into multiple smaller SP and use your UI to control it.
You may wanna refer to this
Related
http://www.aspsnippets.com/Articles/Load-data-while-Scrolling-Page-down-with-jQuery-AJAX-and-ASPNet.aspx
Above link is having code example to load data on demand(Infinite scroll) is it possible to use join query.
I don't want to create this SQL PROCEDURE is it possible with query. because this procedure has DECLARE the. it's quite difficult to change the SQL PROCEDURE each time.
it will be easy to manage store procedure in place of hard coding
because if anything will require to modify then you can change Store
procedure from server, Otherwise if you have done hard code in
application then you have to publish complete application to change
anything.
We have a SQL server that we are using for our data warehouse.
We want to give a department the ability to update the data when they want (and not just on schedule).
Was is the best way to do this? We have a SP that we are thinking of calling from a batch script, but is there a more elegant way?
The data will eventually go into Palo Jedox for BI.
I do this sort of thing by writing a ColdFusion web page that the user can run. It could also be done with .net, php, java, etc.
Do not give users the ability to change the tables directly.
Instead, create one or more stored procedures to do the updates/inserts/deletes that you want to do. If it is one record, you can just pass in the values as arguments. If it is a bunch of records, you need a mechanism to transfer larger data into the database -- either reading from a text file or putting it into a table in the database some way.
Be sure the stored procedure has the same owner as the underlying tables. Using owner chaining, the stored procedure will be able to make changes to the tables. At no time can a user make a change to the data directly, only through the stored procedure.
Then, log, log, log everything that gets done. You want to know every time this stored procedure is called to change the data.
My Asp.Net MVC web-site uses stored procedures based data access to the SQL Server database. Almost every procedure should check permissions, if current user can perform this operation. I've solve it by passing additional parameter UserId to every procedure and checking if user has special permission code in special table.
It causes many copy-pasted script. I wonder, is there any another way? Or may be you have an advices to improve my solution...
Just a thought, but what if you encapsulate the logic to lookup the permission for the given user and item in a user defined function. Then, invoke the function from the necessary stored procedures and check the return value. You still will wind up with some copying and pasting but in theory it should result in a cleaner approach.
Is a stored procedure in a database system is a call back mechanism ?
Not sure I really get the question. Do you mean:
Is a stored procedure in a database
system in itself a call back mechanism?
Or
Do stored procedures have a call back mechanism?
In the first instance, the answer is no, but for me, that question doesn't make much sense.
In the second instance, again the answer is no, if you are wanting a formal dedicated callback machanism. However, a form of callback can be achieved using dynamic SQL and stored procedure parameters.
Consider the following
CREATE Procedure usp_test (#callback varchar(100))
AS
EXEC (#callback)
Here, we are passing the name of the procedure in a string and executing as dynamic SQL. We can, of course append parameters to it if we want. It isn't a tryue callback as we are not passing a reference.
In all honesty, however, it sounds like you don't understand the question. Maybe a better question would have been to enquire as to the meaning of the question?
Databases are basically passive. No calls = no action.
When a database emails you, it is in fact some scheduled client code that calls the database and sends the email.
"A happy database has no users" of course
I am creating an application in which i am using stored procedure where i m implementing my logic.
Now what i need to know is that- i want my database not to contain any invalid entry, for this purpose should i create triggers, for implementing my data validation logic such that when FailPasswordAttemptCount is changed to some value then should i make changes in corresponding column IsLocked accordingly thru triggers or leave it on dba to manage.
eg
if FailPassowrdAttemptCount > 3
IsCaptchaActivated=True
if FailPasswordAttemptCount>6
IsLocked=true
now if a dba changes the value of FailPasswordAttemptCount to 4 without changing IsCaptchaActivated to true then this will make an invalid entry for my frontend.
SO should i manage it thru triggers or should i left it over dba to make correct entry.
Although this type of entry is not possible thru frontend but in case any1 having privilages to access database, changes directly thru database.
For this should i leave it on user or should i manage thru triggers.
I want to make my database to remain consistent in all circumstances.
I'd make the following:
Put the data validation logic into a stored procedure
Made the stored procedure the only way the application interacts with the table
Put the code you want into the stored procedure.
Trigger-based programming paradigma grows too hard to code and maintain as the business logic complexity of your application increases.
However, if you are absolutely sure you will only have the simple logic like this, it is OK to put it into a trigger since this will require minimal changes in the ways the application interacts with the database.
I wouldn't use a trigger for something like this. Triggers are obscure and can be hard to debug for the developer. Use your tables and stored procedures to deal with the issue. Use triggers for when you don't have an alternative.
I would use a combination of both. I will try to restrict data as far as possible. And will fire trigger, so that no one can insert any invalid entry.
For this type of situation, I would probably not use a trigger, just for the situation you describe. Though I would wonder why you have dba's manually altering data in a field that closely tied to the security of your app.
I would implement this in the application logic. When calling the login sproc you can return both whether it succeeded as well as the number of failed password attempts and if captcha is needed. Regardless of if the DBA changes the 3 to a 4, your code will see the 4, ignore the result of the validation and present the user with a captcha. If you're worried about DBA's modifying the code directly you can also check the APP_NAME() function/variable to see what program is trying to modify the data. Its something to be very careful with but so is DBAs modifying fields directly.