我有一个程序,我将值设置为
DECLARE V_FACTOR DECIMAL(14,9);
SET V_FACTOR = ROUND((73108997572.52/69453547621393.89),9);
应该给我一个像0.001052632这样的值,但它的给出为0.00105
答案 0 :(得分:2)
我进行了以下测试。
创建源文件round.sql。
--#SET TERMINATOR @
connect to pocdb@
values (ROUND((73108997572.52/69453547621393.89),9))@
create or replace procedure stack.round_proc(out r decimal(14,9))
language sql
begin
declare r1 decimal(14,9);
set r = ROUND((73108997572.52/69453547621393.89),9);
end
@
create or replace function stack.round_func()
returns decimal(14,9)
language sql
begin atomic
declare r1 decimal(14,9);
set r1 = ROUND((73108997572.52/69453547621393.89),9);
return r1;
end
@
call stack.round_proc(?)@
values (stack.round_func())@
connect reset@
terminate@
执行源文件,使用:
db2 -tvf round.sql > round.out 2>&1
在round.out中捕获的结果:
connect to pocdb
Database Connection Information
Database server = DB2/LINUXX8664 10.5.3
SQL authorization ID = DB2INST1
Local database alias = POCDB
values (ROUND((73108997572.52/69453547621393.89),9))
1
---------------------------------
0.001052632000000000
1 record(s) selected.
create or replace procedure stack.round_proc(out r decimal(14,9))
language sql
begin
declare r1 decimal(14,9);
set r = ROUND((73108997572.52/69453547621393.89),9);
end
DB20000I The SQL command completed successfully.
create or replace function stack.round_func()
returns decimal(14,9)
language sql
begin atomic
declare r1 decimal(14,9);
set r1 = ROUND((73108997572.52/69453547621393.89),9);
return r1;
end
DB20000I The SQL command completed successfully.
call stack.round_proc(?)
Value of output parameters
--------------------------
Parameter Name : R
Parameter Value : 0.001052632
Return Status = 0
values (stack.round_func())
1
----------------
0.001052632
1 record(s) selected.
connect reset
DB20000I The SQL command completed successfully.
terminate
DB20000I The TERMINATE command completed successfully.
如果您收到的结果不同,则应打开PMR。