When querying the Oracle number type, you may encounter errors in precision. The following describes a solution to the loss of the Oracle number type query accuracy for your reference.
I. The Oracle number type query requirement requires that the value of a field be found and then the second digit after the decimal point is kept
// If you use the following method to obtain a number from ResultSet, and the number is greater than 40000, the obtained data will be inaccurate
- floatzcxxhj+=rss.getFloat(3);
// If double is used, no problem occurs.
- double zcxxhj+=rss.getDouble(3);
// Rounded to the second digit after the decimal point
- list.add(new BigDecimal(zcxxhj).setScale(2, BigDecimal.ROUND_HALF_UP));
2. If the Oracle number type query requires that the number retrieved from the database be retained to the second digit after the decimal point, it is then directly displayed on the front-end.
We can use the following query method:
Example:
- Select fpdm,
- Fphm,
- Fkdw,
- To_char (kprq, 'yyyy-mm-dd '),
- To_char (xxhj, 'fm9999999999990. 00 '),
- Decode (fpzt, '1', 'positive pass', '2', 'Red pass', '3', 'invalid pass ')
- From wskp_fpkj_zbxx_111000861071
- Where 11 = 1
- And nssbh = '000000'
The xxhj is of the number type. We can use to_char (xxhj, 'fm990. 00 '), keep at least two digits after the tree points, three digits before the decimal point, at least one;
Another example is to_char (xxhj, 'fm9990. 123456'), which means to keep at least two digits after the decimal point, at most four digits, four digits before the decimal point, and at least one digit.
3. If you want to add the numbers to be found, keep the last two digits of the small tree.
- double d=rss.getDouble(3)+ rss.getDouble(4);
- BigDecimal bigDecimal= new BigDecimal(d).setScale(2, BigDecimal.ROUND_HALF_UP);
- beanData.setXxhj(bigDecimal.toString());
Oracle multi-Table query instance
ORACLE Database Encoding
Use the Oracle to_date () function
Oracle date formatting implementation
Oracle memory structure-SGA