使用 DCPROMO/FORCEREMOVAL 命令强制将 Active Directory 域控制器降级
查看全文tmp_str varchar2(20);
money_str varchar2(20);
val_j varchar2(20);
len_j number;
k number;
i number;
j number;
m number;
result varchar2(40);
type my_type is varray(20) of varchar2(4);
num constant my_type := my_type('1','2','3','4','5','6','7','8','9','0');
num_str constant my_type := my_type('壹','贰','叁','肆','伍','陆','柒','捌','玖','零');
begin
tmp_str := to_char(money * 100);
len_j := length(tmp_str);
k := 11 - len_j;
result := substr(tmp_str,1,1);
m := 2;
for i in 1..len_j loop
begin
if k = 1 then money_str := '仟';
elsif k = 2 then money_str :='佰';
elsif k = 3 then money_str :='拾';
elsif k = 4 then money_str :='万';
elsif k = 5 then money_str :='仟';
elsif k = 6 then money_str :='佰';
elsif k = 7 then money_str :='拾';
elsif k = 8 then money_str :='元';
elsif k = 9 then money_str :='角';
elsif k = 10 then money_str :='分';
end if;
k := k + 1;
m := i + 1;
val_j := nvl(substr(tmp_str,m,1),'');
if len_j = m + 5 and substr(result,length(result),1) = '0' then
result := substr(result,0,length(result)-1) ||'万0';
end if;
if len_j = m + 1 and substr(result,length(result) ,1) = '0' then
result := substr(result,0,length(result)-1) ||'元0';
end if;
if val_j = '0' and substr(result,length(result),1) = '0' then
goto TheEnd;
end if;
if substr(result,length(result) ,1) != '0' then
result := result || money_str;
end if;
result := result || val_j ;
<<TheEnd>>
null;
end;
end loop;
--除去最后的0
for j in 1..3 loop
begin
if substr(result,length(result),1) = '0' then
result := substr(result,0,length(result) -1);
end if;
end;
end loop;
for i in 1..10 loop
result := replace(result,num(i),num_str(i));
end loop;
return result||'整';
end;
/
例子
SQL> select getBigMoneyStr(2124324.34) from dual;
GETBIGMONEYSTR(2124324.34)
--------------------------------------------------------------------
贰佰壹拾贰万肆仟叁佰贰拾肆元叁角肆分整
SQL> select getBigMoneyStr(2129874.34) from dual;
GETBIGMONEYSTR(2129874.34)
--------------------------------------------------------------------
贰佰壹拾贰万玖仟捌佰柒拾肆元叁角肆分整
现有状况
根据数据库日志文件db2diag.log,我们发现以下问题:
1. Memory Heap Error;
2. cdbold有锁升级现象;
观察当前环境后,我们发现系统内存平均使用率很高,2G内存平时使用量达到1.96G,可再分配的内存不到40M,非常有限。
参数调节
因此,我们采用加速脏业回写的方式来尝试改变性能,语法为:
db2 connnect to stmaold;
db2 update db cfg for stmaold using CHNGPGS_THRESH 30;
用同样的方式,我们也改变了其他三个数据库的参数。参数改变后,必须进行数据库重激活或者数据库实例重起。例如:
db2stop
db2start
然后该参数能够开始起作用。
此外,我还将cdbold的锁列表改大:
db2 connect to cdbold;
db2 update db cfg for cdbold using locklist 200;
该参数直接生效。并多占用了0.4M内存。
其他环节
如果要将参数修改回原样,可采用以下设置:
db2 connnect to <数据库名>;
db2 update db cfg for <数据库名> using CHNGPGS_THRESH 60;
db2 connect to cdbold;
db2 update db cfg for cdbold using locklist 200;
此外,建议定期检测db2diag.log文件,如果出现Memory Heap Error,建议选择适当的时间对数据库进行重起。而且,观察出现该错误的时间应用的什么功能在运行,收集errpt信息和DB2support信息,以供进一步分析处理。











