Oracle Database time type suspense case, oracle Database suspense

Source: Internet
Author: User

Oracle Database time type suspense case, oracle Database suspense

The problem Alan encountered was that he had already encountered a securities industry project a year and a half ago, but he had never thought about the cause of such a suspense case. What is the suspense case? In fact, it is very simple. I think many of my shoes are useful in Oracle databases. This is the case. This is a common order table for e-commerce platforms that contains two fields:

Take two examples at will. One is the time when the buyer submits the order, and the other is the time when the seller confirms the order. Let's look at a piece of data, which is like this:

We can see that there is no problem with the data. The two DATE formats are the same and all adopt the time format of the TIMESTAMP (6) type. DATE is also a commonly used type, if you need to be more precise, you can consider using the TIMESTAMP type. What is the problem? We use the test tool jmeter to send a request to the backend for the Order details interface:

The returned data is as follows:

Alan was desperate when he saw the Bug mentioned by mm in the Zen road test. what? Fuck? Shit? What is this? Sure enough, it wasn't long before the ios buddy came to the door? Why is the time you submit an order in milliseconds? I fuck your... however, little Alan's three-inch tongue will sound bad, and the ios guys are very helpful in formatting themselves. It's really not Alan's lazy, we have already formatted the H5 and Android buddies. We need to unify the development style ~

However, laziness cannot prevent Alan from seeking knowledge. So I carefully looked at the mysterious points in the Code and found the problem in seconds. The above also said that we should unify the development style, as a result, I did not have a uniform development style... cough... cough...

What is the problem? We will announce the following:

Let's take a look at the SQL statement used to submit the order (the SQL statement is too long to be simply truncated ):

Here we use the orm framework Mybatis. You can find that orderTime is passed through the object class. Let's take a look at the code for assigning values to it:

What does this mean? It indicates that the order submission time is the current system time obtained through the no-argument constructor of java. util. Date type. Is there any problem? Of course there is no problem! Let's take a look at how the order was confirmed? We came to the order confirmation interface:

Alan couldn't find the time to confirm the order for half a day. This is the problem. submitting an order is another interface developed by a Java buddy, what is the order confirmation interface I developed? Isn't there a uniform development style? cough... so embarrassing! Alan thought that there was no time for the database to confirm the order. How can this problem be solved? As a result, the following SQL statement is continued:

So the time for confirming the order came from? The current system time sysdate of the oracle database server is used directly. After such an output, the data is as follows:

Is there something wrong with Nima? No problem! However, the data returned by the API is faulty! Alan will reveal it to you here. Don't ask if Alan is caused by this. Alan is too lazy to verify it. If Alan is idle, you can verify it, if this is not the case, remember to comment below. Don't hit Alan. Alan took a bowl and went to the street to beg. No one sent the order, so don't hurt Alan's young mind.

 

Conclusion: There is no problem.

 

Alimail: AlanLee

Blog: http://www.cnblogs.com/AlanLee

This article is from the blog site. You are welcome to join the blog site.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.