Write Conflict between two transactions [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am a noob in DBMS. I am developing a project which has multiple readers and writers.
Here are the steps of the project.
User Logins
Makes changes
Then clicks submit
Admins review the changes and merges with the main DB.
So, I thought let's use a transaction for each user when they login to my project. Because the transaction takes a snapshot and commits data if all the queries are executed without any error.
If two users want to write in the same row then the transaction throws an error that is required for the project.
Now my question is if such an error occurs then I want only that query to fail I still want the transaction to continue if it has no error.

You are trying to use the concept of a database transaction in a wrong way. Database transactions should be very short (sub-second) and never involve user interaction. The idea is to group statements that belong together so that either all of them succeed or all fail.
What you want to do is application logic and should be handled by the application. That doesn't mean that you cannot use the database. For example, your table could have a column that persists the status (entered by client, approved, ...).

Related

Create SQL Server "creator" account which cannot view or delete data [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Good afternoon, I am looking to see if anyone knows if there is a way to create a "creator" user in SQL. Yes this is Microsoft SQL Server.
I would like this user to be able to:
Create objects (functions, stored procedures, tables, views)
Insert data as needed
I would like this user to NOT be able to:
View or delete any data.
Any input would be appreciated, doing testing now.
I will try the db_denydatareader - and this account will be used by an automated process only, we simply want to deny reader as it's not needed and in-case the user was compromised.
Thanks!
Tough one...
First of all, I am assuming Microsoft SQL server.
Read this:
Permissions (Database Engine)
You can try db_owner and and db_denydatareader on the user, since you are testing now. It is a long shot. But even if it works, the user might then change data and it looses its integrety.

In concurrent thread,how can we avoid duplicate uri in cts:uris()? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
In a schedular ,which is running on all host at a time, right now I am using xdmp:lock-acquire to lock the collection, so that ,cts:uris will not pick the duplicate uris, but due to this scheduler is running in sequence .Is there any other alternative ,so that I avoid this lock, so that all run in parallel.
It's a bit unclear what you are trying to do, but it sounds like you have documents in the database that you are processing using a scheduled task, that runs on all hosts. Your existing query makes it possible for two tasks to attempt to process the same document.
The easiest would be to generate a list of forests on the host that the task is running on using xdmp:host-forests, and passing that list into cts:uris as $forest-ids
$forest-ids A sequence of IDs of forests to which the search will be
constrained. An empty sequence means to search all forests in the
database. The default is ().

How to delay all queries for a specified timespan? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I'd like to delay all the queries I receive in my test database for a specified amount of time. My intent in doing this is to test the "loading" feature in my program. I do not want to alter my queries though! WAITFOR doesn't work for me. If possible, the ideal would be to delay all the queries of a specific connection.
Summarizing: I'd like to delay all the queries of my database via some kind of configuration.
How to do that in SQL Server?
To the best of my knowledge, this is not an out-of-the-box feature.
Most people who want to test their data access code write specific test cases to do that. Again, there are lots of different scenarios; the closest to what you describe would be to capture all the requests going to your server, and then write a harness to replay those queries under test conditions.
Is it really needed? And is there a way to put a delay on the code level? I mean do something like this before the database request.
Thread.Sleep(milliseconds);

How to protect a stored procedure file from reading - SQL Server [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to generate a file that contains a stored procedure query and I want to share it, but I need to protect it from reading. This query will be used by another person in his own database and server.
I want to give a SP to another person to use in a different environment but doesn't want them to be able to read the TSQL in the SP.
How can I do that?
You can use the WITH ENCRYPTION clause. However, it is known to be ineffective and easily broken, and there are third party tools available that will let your client break it.
If you want to do it anyway, a tutorial can be found here.
If you use WITH ENCRYPTION along with a thoughtfully constructed EULA, your client should not accidentally see the code, and if he purposefully goes to the trouble to crack your code encryption, you will have civil recourse (i.e. you can sue them).

sql database convention [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Apologies in advance if this is a stupid question. I've more or less just started learning how to use SQL.
I'm making a website, the website stores main accounts, each having many sub-accounts associated with them. Each sub-account has a few thousand records in various tables associated with it.
My question is to do with the conventional usage of databases. Is it better to use a database per main account with everything associated with it stored in the same place, store everything in one database, or an amalgamation of both?
Some insight would be much appreciated.
Will you need to access more than one of these databases at the same time? If so put them all in one. You will not like the amount of effort and cost 'joining' them back together to do a query. On top of that, every database you have needs to be managed, and should you need to transfer data between them that can get painful as well.
Segregating data by database is a last resort.