Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Space Whale
Nov 6, 2014
How do I ensure ACID transactions in TSQL?

I'm having the database generate IDs through incrementation and store the most recent one in a field in a junction table. Basically, if you end up selecting one of the codes from said junction table, and the code is one where the DB Generates the ID instead of it being user supplied, it increments one to the existing, stored, most recent ID and passes that new one up to the server - my PM wants me to make very sure that we don't have two users trying to do this at the same time and something screwing it up.

I've never actually had to worry about this before now, so I'd like to know what there is to make sure of this. I know SQL is in general good at this kind of thing but I've never needed to worry about the particularities before now.

Adbot
ADBOT LOVES YOU

Space Whale
Nov 6, 2014

Citizen Tayne posted:

I believe the answer to this question is "you use Oracle."

gently caress.

That's a non-option right now.

Space Whale
Nov 6, 2014

Citizen Tayne posted:

Aren't you letting the DBMS handle the sequence generation for you? What you're asking here is pretty much a non-issue with any DBMS I've ever used.

Being a dev and not a DBA I'm only well versed in making pretty simple queries and scripting out some basic stuff. I don't know if there are keywords to use in a stored procedure to do it atomically like I want, or not.

We don't have a DBA and the only knowledge anyone has about ensuring this is a keyword to use in Oracle, which we're not using.

For all I know MSSQL just does this by default but I don't know :(

Space Whale
Nov 6, 2014

Citizen Tayne posted:

I'm an Oracle dev so I'm not 100% sure about how SQL Server does it and it's been a long time since I touched it, but assuming that the DBAs did their job and made a sane database you don't need to worry about this in any modern DBMS I've ever used. You're trying to do things the hard way. Let the DB generate sequences and handle all of that for you.

There are no DBAs, only zool. The database is not sane and poo poo like "we hit a linked oracle (lol) server for each and every row from this subquery in this big rear end report and it takes forever oh we're hitting it 140,000 times oh my god" or "we ran out of space and everything died and we're hemorrhaging money right now to the tune of millions a day" is a current recurring problem.

OTOH I'll be 1000 miles away by the 6th of July :yotj:

Space Whale
Nov 6, 2014

Citizen Tayne posted:

Sounds like you need to quit.

I give the twoweeks tomorrow :q:

Space Whale
Nov 6, 2014
EDIT: CLEARLY SA COULD STAND TO HAVE TRANSACTIONS TOO :haw:

Space Whale fucked around with this message at 18:16 on Jun 18, 2015

Space Whale
Nov 6, 2014

PleasingFungus posted:

Also, I'd suggest googling AUTO_INCREMENT.

Getting the feeling I need to go hang out with some DBA type people sometime since I basically just know how to grab and bundle poo poo and spit it out with a sproc, or just have EF do it for me.

Adbot
ADBOT LOVES YOU

Space Whale
Nov 6, 2014

Nth Doctor posted:

If you're doing T-SQL (Microsoft SQL Server?) then you'll want to see if your using IDENTITY. But yeah: play minesweeper instead bro.

pffffffft DCSS is way better

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply