Tag Info

New answers tagged

1

How about using a column in the table account called max_customer_id and updating that every time there's a new customer? That should be the simplest solution available that I can think of. With this solution you have to take care of the concurrency. Take a look at the document PostgreSQL Concurrency issues: If two concurrent transactions try to ...


1

I wanted to release at least the direct PHP function (I'll eventually release the tools I'm building to something like Github) though I don't yet have the time to do much else other than post it here at least. Hopefully this will save others time and please feel free to suggest improvements. I'm not sure how secure the code is (it's merely a tool I'm only ...


1

To create a copy as close as possible you must use INCLUDING ALL with CREATE TABLE .. (LIKE ..) since there can be any number of columns with defaults that you obviously want to copy. You just want serial columns to get their own, independent sequence, which makes a lot of sense and probably should be the default behavior. For now, this should do the job: ...


1

The problem is that your parts1 table uses the sequence from the parts table (instead of its own sequence) ... thus it complains that you can't drop the parts table because the parts1 table depends on it (via default value for one of the columns)... You are getting this behavior in how you are creating the parts1 table... CREATE TABLE - see the LIKE ...


0

since the Procedure structure in MSSQL is: EXEC sys.sp_sequence_get_range @sequence_name = ‘CyclingSequence’, @range_size = 3, @range_first_value = @firstValue OUTPUT, @range_last_value = @lastValue OUTPUT; SELECT FirstValue = CONVERT(INT, @firstValue), LastVlaue = CONVERT(INT, @lastValue), NextValue = NEXT VALUE FOR ...


0

Just alter then increment the sequence. For example, to increment by 1000: ALTER SEQUENCE yoursequence INCREMENT BY 1000; You then have to SELECT the NEXTVAL from the sequence and re-alter it to increment by the usual value to restore "normal" operation. To check the current value without incrementing: SELECT yoursequence.CURRVAL FROM DUAL; If you ...



Top 50 recent answers are included