For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
In general the sort of things that a int id in a SQL database which might be solved are not the same as for NoSQL (mongodb). For example the overhead for storing each document (instance) is already so high that and saving with an int is almost insignificant. And if it is a matter of retrieval speed then look to some other solution that would provide real performance rather than the small (if any) gain that this might produce.
Because the key is generated on the client not the server.
So what if I created a PK table on the sever:
public int GetNextPrimaryKey(string collectionName)
// Get the PrimaryKeys collection from the DB
IMongoCollection<PrimaryKeyEntity> pkCol = GetCollection<PrimaryKeyEntity>("PrimaryKeys");
// Attempt to find the row for the collection
PrimaryKeyEntity entity = pkCol.Find(x => x.CollectionName == collectionName).FirstOrDefault();
// If it doesn't exist...
if (entity == null)
// Create and insert the row for the desired collection
entity = new PrimaryKeyEntity
PrimaryKey = 1,
CollectionName = collectionName
// Increment the PK
entity.PrimaryKey = entity.PrimaryKey + 1;
var filter = Builders<PrimaryKeyEntity>.Filter.Eq(x => x.CollectionName, collectionName);
var update = Builders<PrimaryKeyEntity>.Update.Set(x => x.PrimaryKey, entity.PrimaryKey);
var result = pkCol.UpdateOneAsync(filter, update).Result;
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
Actually, the concept is..."if i select january 2018 and enter some data that data should enter repeatedly from january to december 2018....if i select november 2018 and enter some data that data should enter repeatedly from november to december 2018..." Based on Month we selecting it should enter into database....Here i got the answer but i want query to insert....[Can't able to insert multiple data].
Can I just run this past you guys, to check I'm not losing my mind...
I use a hosted webserver for a number of my sites, that each use a MySql database. Most use StoredProcs to access data. Yesterday, all the SP-based ones stopped working, with a variety of error messages. No code had changed. Trying to connect to the databases using HeidiSQL or MySql Workbench threw up warnings that the tools didn't support v10.2.24... now I thought I was on MySql 5.7 or something...?
Digging deeper reveals that v10.2.24 is the current MariaDB version. Checking with my hosting provider, and asking why they'd not only upgraded version but changed from MySql to MariaDB without telling anyone, I got this reply:
MySQL 5.7 is the last version of MySQL to be called MySQL
MariaDB is the new name for what was MySQL, so thare is noting to move back to. [sic]
This is news to me!!!
I found the following (really useful) article from less than two weeks ago: MariaDB vs MySQL in 2019: Compatibility, Performance, and Syntax[^]
Please, tell me my hosting provider is talking rubbish!!
Oddly enough, after giving more detail on the issue, everything started working normally again (but still reporting potential compatibility issues with 10.2.24 when using Workbench or Heidi). I'm guessing they'd not configured MariaDB to support StoredProcs (is that even an option?) but whatever they've done seems to have done the trick. But my confidence in them is very severely shaken, when they change d/bs without informing customers, and seem to think MariaDB 10.2.24 is just the new name for MySql 5.7 (and they don't even seem to know about MySql 8.0!) ....
Please, tell me my hosting provider is talking rubbish!
Yes they are.
MariaDB is a clone taken from the MySQL code base when Oracle acquired it. So now there are two products. And more specifically two different development branches which are different. The branch wasn't a recent one either.
So upgrading from MySQL to MariaDB is a product change. And likely a disruptive one as well.
Compare this to AWS Aurora which is also a different product but one that promises binary equality.
Might also note, my impression (without any research) is that stored procedures might be impacted the most.
That said if you are not tied to MySQL for marketing reasons then my gut would say that MariaDB might, in general, be a better product. If for no other reason then Oracle absolutely will pour more money into their commercial MySQL offering than they will into the open source version.
Thanks, JSchell. I later found that although my apps were generally working OK, a couple of functions were failing. Digging deeper I found the issue was that on one StoredProc there was a "missing" parameter, and another was just missing altogether. Everything else was fine. I deduce from this that once alerted to the issue, they probably realised they'd forgotten to migrate the SPs and did a quick manual copy/paste. It's not a huge hosting company and although they have a few hundred databases, I suspect only a handful - or fewer - are using SPs so they may not even have been aware until I pointed out the issue.
They previously (last October) migrated to a new server op.system plus MySql upgrade. That also broke most of my sites since many call webservices on other domains, and the new server didn't support some of the older security protocols the sites were using. It was a one-line fix for each but took quite a while to identify. Also I couldn't send any emails via the SMTP server; I reported it and they claimed nothing had changed, but magically it started working about 10 minutes after I raised the ticket. Seriously p***ed off with them. They've given me a year's free hosting as compensation but when they continually break sites by screwing up upgrades (with no advance warning) I'd rather pay someone to do a proper job....
Just randomises the output and has nothing to do with selecting alternate records. Incidentally, you should avoid using reserved words (e.g. TABLE) as tablenames, but if you insist, then get into the habit of surrounding the reserved word with square brackets (i.e. [TABLE])
In your section 2 you have put Identity column in bold suggesting that it is someway relevant to identifying alternate records - it is not, as I stated earlier.
You then go on to mention "ROW_NUMBER() Rank function" - which one do you mean?
Your final comment I think, is saying that the Rank function has an option to order columns - all Window functions have the potential for ORDER BY and/or PARTITION BY, that's why they are sometimes referred to as OVER functions. You can use Window functions on any table, not just derived tables or CTEs.
Here is an example of why Identity Column is not appropriate: Consider this sample data
createtable test (d varchar(10))
insertinto test (d) values
('Test 1'), ('Test 2'), ('Test 3'), ('Test 4'),
('Test 5'), ('Test 6'), ('Test 7'), ('Test 8')
DELETEfrom test WHERE Id = 3
The contents of the table are
1 Test 1
2 Test 2
4 Test 4
5 Test 5
6 Test 6
7 Test 7
8 Test 8
Note the missing Id 3.
So I would expect to return rows where Id = 1, 4, 6 and 8. But if I just use the Identity Column
SELECT * FROM test where id % 2 = 1
I only get rows where id = 1, 5 and 7. Incorrect.
An example where RANK is inappropriate. Consider the following test data
1 Test 1
1 Test 2
1 Test 3
2 Test 4
2 Test 5
2 Test 6
3 Test 7
3 Test 8
So I would expect to return the rows where d is Test... 1, 3, 5, 7.
If I try to use Rank like this
;with CTE AS
select *, ROW_NUMBER() OVER (ORDERBY d) as rn, RANK() OVER (ORDERBY d) as r
SELECT * FROM CTE WHERE r % 2 = 1
I get the correct answer. But I could just have easily used
SELECT * FROM CTE WHERErn % 2 = 1
as both RANK and ROW_NUMBER return the same value in this instance. I contend that using ROW_NUMBER is clearer and less prone to risk - what if someone changes it to use a PARTITION … RANK() OVER (PARTITION BY id ORDER BY d) as r … you're going to get the rows where Test is … 1, 3, 4, 6, 7. Incorrect again.
Even if partition is not used, RANK can fail depending on the data being returned. Try adding some more data to test2 e.g.
I was trying to make him aware that his post was as clear as mud.
I'd just had a session with a user group from whom I'm trying to get some requirements. They (the group and the requirements!) are woollier than a woolly mammoth.
I wasn't in the best of moods.