数据库升级脚本-最终版哦

spool D:\工作文档\总参\邵工\1222\spbm1222.log

--table 表1.商品编码表
create table DM_GY_SPBM
(
spbm VARCHAR2(19) not null,
spmc VARCHAR2(200),
sm VARCHAR2(4000),
zzssl VARCHAR2(200),
gjz VARCHAR2(4000),
hzx CHAR(1),
bbh VARCHAR2(20),
kyzt CHAR(1),
zzstsgl VARCHAR2(500),
zzszcyj VARCHAR2(1000),
zzstsnrdm VARCHAR2(100),
xfsgl VARCHAR2(500),
xfszcyj VARCHAR2(1000),
xfstsnrdm VARCHAR2(100),
tjjbm VARCHAR2(4000),
sppm clob,
fjbm VARCHAR2(19),
qysj DATE,
gdqjzsj DATE,
rksj DATE default sysdate
)
tablespace LVHYDK_I_DJ;

-- Create/Recreate primary, unique and foreign key constraints
alter table DM_GY_SPBM
add constraint DM_GY_SPBM_PK primary key (SPBM)
using index
tablespace LVHYDK_I_DJ;

--table 表2.商品编码版本表
create table DM_GY_SPBM_BB
(
bbh VARCHAR2(20),
bbsm NVARCHAR2(500),
fbsj DATE,
fbrdm VARCHAR2(20),
fbrxm VARCHAR2(50),
qysj DATE,
gdqjzsj DATE
)
tablespace LVHYDK_I_DJ;

alter table DM_GY_SPBM_BB
add constraint PK_BBH primary key (BBH)
using index
tablespace LVHYDK_I_DJ;

--table 表3.商品编码版本子表
create table DM_GY_SPBM_BB_ZB
(
jlxh VARCHAR2(20),
spbm VARCHAR2(19),
spmc VARCHAR2(200),
sm VARCHAR2(4000),
zzssl VARCHAR2(200),
gjz VARCHAR2(4000),
hzx CHAR(1),
bbh VARCHAR2(20),
kyzt CHAR(1),
zzstsgl VARCHAR2(500),
zzszcyj VARCHAR2(1000),
zzstsnrdm VARCHAR2(100),
xfsgl VARCHAR2(500),
xfszcyj VARCHAR2(1000),
xfstsnrdm VARCHAR2(100),
tjjbm VARCHAR2(4000),
sppm clob,
qysj DATE,
rksj DATE,
gdqjzsj DATE,
sftb CHAR(1),
zjzzstsgl VARCHAR2(500),
zjzzszcyj VARCHAR2(1000),
zjzzstsnrdm VARCHAR2(100),
zjxfsgl VARCHAR2(500),
zjxfszcyj VARCHAR2(1000),
zjxfstsnrdm VARCHAR2(100),
istj NUMBER(4)
)
tablespace LVHYDK_I_DJ;

alter table DM_GY_SPBM_BB_ZB
add constraint FK_ZB_BBH foreign key (BBH)
references DM_GY_SPBM_BB (BBH);

--table 表4.商品编码优惠政策表
create table DM_GY_SPBM_YHZC
(
jlxh VARCHAR2(20),
bbh VARCHAR2(20),
spbm VARCHAR2(19),
yhzcwhf VARCHAR2(10),
fbsj DATE,
fbrdm VARCHAR2(20),
fbrxm VARCHAR2(50),
zzszcyj VARCHAR2(1000),
xfsgl VARCHAR2(500),
xfszcyj VARCHAR2(1000),
xfstsnrdm VARCHAR2(100),
rksj DATE,
zzstsgl VARCHAR2(500),
zzstsnrdm VARCHAR2(100),
yhzcdm VARCHAR2(500),
yhzcnr VARCHAR2(500)
)
tablespace LVHYDK_I_DJ;

--table 表5.商品编码缓存表
create table DM_GY_SPBMHC
(
spbm VARCHAR2(19),
spmc VARCHAR2(200),
sm VARCHAR2(4000),
zzssl VARCHAR2(200),
gjz VARCHAR2(4000),
hzx CHAR(1),
zzstsgl VARCHAR2(500),
zzszcyj VARCHAR2(1000),
zzstsnrdm VARCHAR2(100),
xfsgl VARCHAR2(500),
xfszcyj VARCHAR2(1000),
xfstsnrdm VARCHAR2(100),
tjjbm VARCHAR2(4000),
sppm clob,
fjbm VARCHAR2(19),
rksj DATE,
fbrdm VARCHAR2(20),
fbrxm VARCHAR2(50)
)
tablespace LVHYDK_I_DJ;

--table表6.增值税特殊管理表
create table DM_GY_ZZSTSGL
(
zzstsglmc VARCHAR2(500) not null,
sm VARCHAR2(500),
sl VARCHAR2(200),
sybz CHAR(1)
)
tablespace LVHYDK_I_DJ;

-- Create/Recreate primary, unique and foreign key constraints
alter table DM_GY_ZZSTSGL
add constraint PK_ZZSMC primary key (ZZSTSGLMC)
using index
tablespace LVHYDK_I_DJ;

--初始化数据
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘不征税‘, ‘0%‘);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘免税‘, ‘0%‘);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘先征后退‘, null);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘100%先征后退‘, null);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘50%先征后退‘, null);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘简易征收‘, ‘5%、4%、3%‘);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘即征即退30%‘, null);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘即征即退50%‘, null);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘即征即退70%‘, null);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘即征即退100%‘, null);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘超税负3%即征即退‘, null);
insert into DM_GY_ZZSTSGL (zzstsglmc, SL) values (‘稀土产品‘, null);
commit;

-- 编码表 添加 外键约束(字段 bbh 指向 版本表 的bbh)
ALTER TABLE DM_GY_SPBM ADD CONSTRAINT FK_BBH FOREIGN KEY (BBH) REFERENCES DM_GY_SPBM_BB(BBH);

-- 7. 创建序列
create sequence SPBM_YHZC_SEQ01
minvalue 1
maxvalue 9999999999999999999999999999
start with 11
increment by 1
cache 10;

create sequence SPBM_SEQ01
minvalue 1
maxvalue 9999999999999999999999999999
start with 11381
increment by 1
cache 20;

create sequence SEQ_YHZC
minvalue 1
maxvalue 9999999999999999999999999999
start with 422
increment by 1
cache 20;

--8 以下为修改的表

--货物运输业增值税专用发票明细表

alter table JS_SKSKJDK_HYZZSFPMX add BMB_BBH varchar2(20);

--货物运输业增值税专用发票明细子表
alter table JS_SKSKJDK_HYZZSFPMX_FYXM add SPBM Varchar2(20);
alter table JS_SKSKJDK_HYZZSFPMX_FYXM add ZXBM varchar2(20);
alter table JS_SKSKJDK_HYZZSFPMX_FYXM add YHZCBS Char(1);
alter table JS_SKSKJDK_HYZZSFPMX_FYXM add ZZSTSGL varchar2(100);
alter table JS_SKSKJDK_HYZZSFPMX_FYXM add LSLBS Char(1);

--机动车销售统一发票明细表
alter table JS_SKSKJDK_JDCFPMX add BMB_BBH Varchar2(20);
alter table JS_SKSKJDK_JDCFPMX add SPBM Varchar2(20);
alter table JS_SKSKJDK_JDCFPMX add ZXBM varchar2(20);
alter table JS_SKSKJDK_JDCFPMX add YHZCBS Char(1);
alter table JS_SKSKJDK_JDCFPMX add ZZSTSGL varchar2(100);
alter table JS_SKSKJDK_JDCFPMX add LSLBS Char(1);

--红字信息表子表
alter table TZD_SKSKJDK_HZFP add BMB_BBH varchar2(20);

--红字信息表子表子表
alter table TZD_SKSKJDK_HZFP_ZB add SPBM Varchar2(20);
alter table TZD_SKSKJDK_HZFP_ZB add ZXBM varchar2(20);
alter table TZD_SKSKJDK_HZFP_ZB add YHZCBS Char(1);
alter table TZD_SKSKJDK_HZFP_ZB add ZZSTSGL varchar2(100);
alter table TZD_SKSKJDK_HZFP_ZB add LSLBS Char(1);

--9 创建类型

drop type tbspbmtable force;
drop type tbspbmobjec force;

create or replace type tbspbmobjec as object(hbbm nvarchar2(19),lwmc nvarchar2(200),sm nvarchar2(4000),zzssl nvarchar2(100),zzstsgl nvarchar2(500),zzszcyj nvarchar2(1000),zzstsnrdm nvarchar2(100),xfsgl nvarchar2(500),xfszcyj nvarchar2(1000),xfstsnrdm nvarchar2(100),gjz nvarchar2(4000),sfgb nvarchar2(1),hydm nvarchar2(4000),sppm clob,fjbm nvarchar2(19),bbh nvarchar2(19),sysj nvarchar2(19),qysj nvarchar2(19),kyzt nvarchar2(10));
/
create or replace type tbspbmtable as table of tbspbmobjec;
/

-- 10 创建类型
drop type spbmtable force;
drop type spbmobjec force;

create or replace type spbmobjec as object(hbbm nvarchar2(19),lwmc nvarchar2(200),sm nvarchar2(4000),zzssl nvarchar2(100),zzstsgl nvarchar2(500),zzszcyj nvarchar2(1000),zzstsnrdm nvarchar2(100),
xfsgl nvarchar2(500),xfszcyj nvarchar2(1000),xfstsnrdm nvarchar2(100),gjz nvarchar2(4000),sfgb nvarchar2(1),hydm nvarchar2(4000),sppm clob,fjbm nvarchar2(19),isyzfj nvarchar2(1));
/
create or replace type spbmtable as table of spbmobjec;
/

--11 创建存储过程 分页存储过程
CREATE OR REPLACE Procedure Soa_Getpager(p_Pagesize Int, --每页记录数
p_Pageno Int, --当前页码,从 1 开始
p_Sqlcols Varchar2, --选择列
p_Sqlfrom Varchar2, --表名OR连接查询
p_Sqlwhere nVarchar2, --查询子句
p_Sqlorderby Varchar2, --排序
p_Outrecordcount Out Int, --返回总记录数
p_Outpagecount Out Int, --返回总页数
p_counts Out Sys_Refcursor) As
v_Sql Varchar2(3000);
p_Sqlselect Varchar2(3000);
v_Count Int;
v_Heirownum Int;
v_Lowrownum Int;
Begin

----拼接SQL查询语句
p_Sqlselect := ‘select ‘ || p_Sqlcols || ‘ from ‘ || p_Sqlfrom || ‘ ‘ || p_Sqlwhere ;
----取记录总数
v_Sql := ‘select count(1) from ‘ || p_Sqlfrom || ‘ ‘ || p_Sqlwhere ;
Execute Immediate v_Sql Into v_Count;
p_Outrecordcount := v_Count;
----取总页数
p_Outpagecount := p_Outrecordcount / p_Pagesize;
If p_Outpagecount = 0 Then
p_Outpagecount := 1;
End If;

p_Sqlselect :=p_Sqlselect || ‘ order by ‘||p_Sqlorderby;
----执行分页查询
v_Heirownum := p_Pageno * p_Pagesize;
v_Lowrownum := v_Heirownum - p_Pagesize + 1;

v_Sql := ‘SELECT * FROM (
SELECT A.*,rownum rn
FROM ( ‘ || p_Sqlselect || ‘) A
WHERE rownum <= ‘ || To_Char(v_Heirownum) || ‘
) B
WHERE rn >= ‘ || To_Char(v_Lowrownum);
--注意对rownum别名的使用,第一次直接用rownum,第二次一定要用别名rn

Dbms_Output.Put_Line(v_Sql);

Open p_counts For v_Sql;

exception when others then p_Outpagecount:=-1;

End Soa_Getpager;
/

--12 创建存储过程 获取商品编码子集
create or replace procedure spbm_get_jb(spbm in varchar2,backdata out Sys_Refcursor) is
cxsql varchar2(4000);
begin

if spbm is null or spbm=‘‘ then

cxsql:=‘ select spbm,spmc,zzssl,(select max(spbm)||‘‘|‘‘||count(1) from DM_GY_SPBM z where z.fjbm=t.spbm) cc,kyzt,fjbm,zzstsgl from DM_GY_SPBM t
where fjbm is null and t.kyzt=‘‘Y‘‘ order by spbm asc‘;

else

cxsql:= ‘select spbm,spmc,zzssl,(select max(spbm)||‘‘|‘‘||count(1) from DM_GY_SPBM z where z.fjbm=t.spbm) cc,kyzt,fjbm,zzstsgl from DM_GY_SPBM t
where t.fjbm=‘‘‘||spbm||‘‘‘ and t.kyzt=‘‘Y‘‘ order by spbm asc ‘;
end if;

open backdata for cxsql;

end spbm_get_jb;

/

--13 创建存储过程 批量导入商品编码
create or replace procedure spbmproceobject(aym in spbmtable,proerr out clob,SYSJ in varchar2,v_QYSJ in varchar,
FBRDM in varchar,FBRXM in varchar,BBSM in varchar,cfbm out clob,spbbh out varchar2,isfb in number)
as
ain spbmobjec;
v_version varchar2(20);
v_spbm_counts number;
v_fjspbm_counts number;
v_lwmc number;

begin

savepoint pt;

--计算版本
select max(to_number(substr(bbh,1,instr(bbh,‘.‘)-1)))+1 into v_version from dm_gy_spbm_bb;
if(v_version is null or v_version =‘‘) then
v_version:=‘1.0‘;
end if;
if instr(v_version,‘.‘)=0 then
v_version:=v_version||‘.0‘;
end if;

insert into dm_gy_spbm_bb values(v_version,BBSM,sysdate,FBRDM,FBRXM,to_date(SYSJ,‘yyyy/mm/dd‘),to_date(v_QYSJ,‘yyyy/mm/dd‘));

for ay in aym.first()..aym.last()
loop
ain:=aym(ay);
v_fjspbm_counts:=1;
if ain.isyzfj=‘1‘ then
select count(1) into v_fjspbm_counts from dm_gy_spbm where spbm=ain.fjbm ;
end if;

v_spbm_counts:=0;
if v_fjspbm_counts>0 then
select count(1) into v_spbm_counts from dm_gy_spbm where spbm=ain.hbbm ;
end if;

v_lwmc:=0;
if v_spbm_counts=0 and v_fjspbm_counts=1 then
select count(1) into v_lwmc from dm_gy_spbm where spmc=ain.lwmc ;
end if;

if ((v_spbm_counts=0 and isfb=0) or (isfb=1)) and v_fjspbm_counts=1 and v_lwmc=0 then

--新增
if v_spbm_counts=0 then
insert into dm_gy_spbm(spbm,spmc,SM,zzssl,hzx,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,QYSJ,GDQJZSJ,FJBM,BBH,RKSJ)
values(ain.hbbm,ain.lwmc,ain.sm,ain.zzssl,ain.sfgb,‘Y‘,ain.gjz,ain.zzstsgl,ain.zzszcyj,ain.zzstsnrdm,
ain.xfsgl,ain.xfszcyj,ain.xfstsnrdm,ain.hydm,ain.sppm,to_date(SYSJ,‘yyyy/mm/dd‘),to_date(v_QYSJ,‘yyyy/mm/dd‘),ain.fjbm,v_version,sysdate) ;
end if;
if v_spbm_counts>0 then
update dm_gy_spbm set spmc=ain.lwmc,SM=ain.sm,zzssl=ain.zzssl,hzx=ain.sfgb,gjz=ain.gjz,zzstsgl=ain.zzstsgl,
ZZSZCYJ=ain.zzszcyj,ZZSTSNRDM=ain.zzstsnrdm,XFSGL=ain.xfsgl,XFSZCYJ=ain.xfszcyj,XFSTSNRDM=ain.xfstsnrdm,
TJJBM=ain.hydm,SPPM=ain.sppm,QYSJ=to_date(SYSJ,‘yyyy/mm/dd‘),GDQJZSJ=to_date(v_QYSJ,‘yyyy/mm/dd‘),BBH=v_version
where spbm=ain.hbbm ;
end if;

insert into dm_gy_spbm_bb_zb(JLXH,spbm,spmc,SM,zzssl,hzx,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,QYSJ,GDQJZSJ,BBH,rksj)
values(spbm_seq01.nextval,ain.hbbm,ain.lwmc,ain.sm,ain.zzssl,ain.sfgb,‘Y‘,ain.gjz,ain.zzstsgl,ain.zzszcyj,ain.zzstsnrdm,
ain.xfsgl,ain.xfszcyj,ain.xfstsnrdm,ain.hydm,ain.sppm,to_date(SYSJ,‘yyyy/mm/dd‘),to_date(v_QYSJ,‘yyyy/mm/dd‘),v_version,sysdate) ;
else

if v_spbm_counts>0 then
cfbm:=cfbm||to_char(ain.hbbm)||‘,‘;--编码重复
end if;

if v_fjspbm_counts=0 then
proerr:=proerr||to_char(ain.hbbm)||‘bb‘;--没有夫级
end if;

if v_lwmc>0 then
proerr:=proerr||to_char(ain.hbbm)||‘cc‘;--劳务名称
end if;
end if;

end loop;
if (proerr is null or proerr=‘‘) and (cfbm is null or cfbm=‘‘) then
spbbh:=v_version;
commit;
else
rollback to savepoint pt;
end if;

exception
when others then
proerr:=sqlerrm;
rollback to savepoint pt;
end spbmproceobject;

/

---14 创建存储过程 批量同步商品编码
create or replace procedure tbspbmproceobject(aym in tbspbmtable,tbresult out varchar2)
as
ain tbspbmobjec;
v_version varchar2(20);
v_version1 number(8);

b_zzstsgl varchar2(4000);
b_zzszcyj varchar2(4000);
b_zzstsnrdm varchar2(4000);
b_xfsgl varchar2(4000);
b_xfszcyj varchar2(4000);
b_xfstsnrdm varchar2(4000);
bbzj number(8);
indexsy number(12);
JLXHcount number(12);
begin

savepoint pt;

indexsy:=0;

for ay in aym.first()..aym.last()
loop
tbresult :=1;
indexsy:=indexsy+1;
ain:=aym(ay);

select count(spbm) into v_version1 from dm_gy_spbm where spbm=ain.hbbm ;

if v_version1 =0 then
--先往版本表里面插入值
select count(bbh) into bbzj from dm_gy_spbm_bb where bbh=ain.bbh;
if bbzj=0 then
insert into dm_gy_spbm_bb values(ain.bbh,‘‘,sysdate,‘‘,‘‘,to_date(ain.sysj,‘yyyy/mm/dd‘),to_date(ain.qysj,‘yyyy/mm/dd‘));
end if;
insert into dm_gy_spbm(spbm,spmc,SM,zzssl,gjz,HZX,BBH,kyzt,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,FJBM,QYSJ,GDQJZSJ,RKSJ)
values(ain.hbbm,ain.lwmc,ain.sm,ain.zzssl,ain.gjz,ain.sfgb,ain.bbh,ain.kyzt,ain.zzstsgl,ain.zzszcyj,ain.zzstsnrdm,
ain.xfsgl,ain.xfszcyj,ain.xfstsnrdm,ain.hydm,ain.sppm,ain.fjbm,to_date(ain.sysj,‘yyyy/mm/dd‘),to_date(ain.qysj,‘yyyy/mm/dd‘),sysdate) ;

--王版本字表中插入数据
insert into dm_gy_spbm_bb_zb(JLXH,spbm,spmc,SM,zzssl,HZX,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,QYSJ,GDQJZSJ,BBH,RKSJ,SFTB,
zjzzstsgl,zjzzszcyj,zjzzstsnrdm,zjxfsgl,zjxfszcyj,zjxfstsnrdm)
values(spbm_seq01.nextval,ain.hbbm,ain.lwmc,ain.sm,ain.zzssl,ain.sfgb,ain.kyzt,ain.gjz,ain.zzstsgl,ain.zzszcyj,ain.zzstsnrdm,
ain.xfsgl,ain.xfszcyj,ain.xfstsnrdm,ain.hydm,ain.sppm,to_date(ain.sysj,‘yyyy/mm/dd‘),to_date(ain.qysj,‘yyyy/mm/dd‘),ain.bbh,sysdate,1,
ain.zzstsgl,ain.zzszcyj,ain.zzstsnrdm,ain.xfsgl,ain.xfszcyj,ain.xfstsnrdm) ;

else
select bbh into v_version from dm_gy_spbm where spbm=ain.hbbm ;

if trunc(v_version)<>trunc(ain.bbh) then

v_version := substr(ain.bbh,1,instr(ain.bbh,‘.‘)-1)||‘.‘||substr(v_version,instr(v_version,‘.‘)+1,length(v_version)- instr(v_version,‘.‘));

select count(bbh) into bbzj from dm_gy_spbm_bb where bbh=v_version;
if bbzj=0 then
insert into dm_gy_spbm_bb values(v_version,‘‘,sysdate,‘‘,‘‘,to_date(ain.sysj,‘yyyy/mm/dd‘),to_date(ain.qysj,‘yyyy/mm/dd‘));
end if;

select count(JLXH) into JLXHcount from dm_gy_spbm_bb_zb where spbm=ain.hbbm and sftb=1;
if JLXHcount>0 then
--获取总局的优惠政策数据
select zjzzstsgl,zjzzszcyj,zjzzstsnrdm,zjxfsgl,zjxfszcyj,zjxfstsnrdm into b_zzstsgl,b_zzszcyj,b_zzstsnrdm,b_xfsgl,b_xfszcyj,b_xfstsnrdm from (select zjzzstsgl,zjzzszcyj,zjzzstsnrdm,zjxfsgl,zjxfszcyj,zjxfstsnrdm from dm_gy_spbm_bb_zb where spbm=ain.hbbm and sftb=1 order by JLXH desc) where rownum=1 ;
else
b_zzstsgl:=null;
b_zzszcyj:=null;
b_zzstsnrdm:=null;
b_xfsgl:=null;
b_xfszcyj:=null;
b_xfstsnrdm:=null;
end if;
if ain.zzstsgl<>b_zzstsgl or (b_zzstsgl is null and ain.zzstsgl is not null) then
b_zzstsgl:=ain.zzstsgl;
else
b_zzstsgl:=null;
end if;
if ain.zzszcyj<>b_zzszcyj or (b_zzszcyj is null and ain.zzszcyj is not null) then
b_zzszcyj:=ain.zzszcyj;
else
b_zzszcyj:=null;
end if;
if ain.zzstsnrdm<>b_zzstsnrdm or (b_zzstsnrdm is null and ain.zzstsnrdm is not null) then
b_zzstsnrdm:=ain.zzstsnrdm;
else
b_zzstsnrdm:=null;
end if;
if ain.xfsgl<>b_xfsgl or (b_xfsgl is null and ain.xfsgl is not null) then
b_xfsgl:=ain.xfsgl;
else
b_xfsgl:=null;
end if;
if ain.xfszcyj<>b_xfszcyj or (b_xfszcyj is null and ain.xfszcyj is not null) then
b_xfszcyj:=ain.xfszcyj;
else
b_xfszcyj:=null;
end if;
if ain.xfstsnrdm<>b_xfstsnrdm or (b_xfstsnrdm is null and ain.xfstsnrdm is not null) then
b_xfstsnrdm:=ain.xfstsnrdm;
else
b_xfstsnrdm:=null;
end if;

--更新商品编码表
update dm_gy_spbm set spbm=ain.hbbm,spmc=ain.lwmc,SM=ain.sm,zzssl=ain.zzssl,HZX=ain.sfgb,kyzt=ain.kyzt,gjz=ain.gjz,
zzstsgl=(case when b_zzstsgl is null then zzstsgl else b_zzstsgl end),
ZZSZCYJ=(case when b_zzszcyj is null then ZZSZCYJ else b_zzszcyj end),
ZZSTSNRDM=(case when b_zzstsnrdm is null then ZZSTSNRDM else b_zzstsnrdm end),
XFSGL=(case when b_xfsgl is null then XFSGL else b_xfsgl end),
XFSZCYJ=(case when b_xfszcyj is null then XFSZCYJ else b_xfszcyj end),
XFSTSNRDM=(case when b_xfstsnrdm is null then XFSTSNRDM else b_xfstsnrdm end),
TJJBM=ain.hydm,SPPM=ain.sppm,GDQJZSJ=to_date(ain.qysj,‘yyyy/mm/dd‘),QYSJ=to_date(ain.sysj,‘yyyy/mm/dd‘),FJBM=ain.fjbm,BBH=v_version,RKSJ=sysdate
where spbm=ain.hbbm;

insert into dm_gy_spbm_bb_zb(JLXH,spbm,spmc,SM,zzssl,HZX,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,GDQJZSJ,QYSJ,BBH,RKSJ,SFTB,
zjzzstsgl,zjzzszcyj,zjzzstsnrdm,zjxfsgl,zjxfszcyj,zjxfstsnrdm)
select spbm_seq01.nextval,spbm,spmc,SM,zzssl,HZX,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,GDQJZSJ,QYSJ,BBH,sysdate,1,
ain.zzstsgl,ain.zzszcyj,ain.zzstsnrdm,ain.xfsgl,ain.xfszcyj,ain.xfstsnrdm from (
select spbm,spmc,SM,zzssl,HZX,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,GDQJZSJ,QYSJ,BBH from dm_gy_spbm where spbm=ain.hbbm
);

end if;
end if;
if mod(indexsy,200)=0 then
commit;
end if;
end loop;

exception
when others then
tbresult :=sqlerrm;--失败了
dbms_output.put_line(sqlcode||sqlerrm);
rollback to savepoint pt;
commit;
end tbspbmproceobject;
/

--15 缓存商品编码
create or replace procedure hcspbm (
v_spbm in VARCHAR2,
v_spmc in varchar2,
v_zzssl in varchar2,
v_KGB in varchar2,
v_KYZT in varchar2,
v_GJZ in varchar2,
v_ZZSTSGL in varchar2,
v_ZZSZCYJ in varchar2,
v_ZZSTSNRDM in varchar2,
v_XFSGL in varchar2,
v_XFSZCYJ in varchar2,
v_XFSTSNRDM in varchar2,
v_TJJBM in varchar2,
v_SPPM in clob,
v_SM in varchar2,
v_SYSJ in date,
v_QYSJ in date,
v_FJBM in varchar2,
v_FBRDM in varchar2,
v_FBRXM in varchar2,
v_oper in varchar2,
czzt out number --该变量记录本次操作的状态。 0 成功 -1 失败
)

as
v_spbm_counts number;
v_version varchar2(20);
v_sytime date;
v_qytime date;
v_lwmc number;
begin
--首先检查商品编码是否重复。如果 重复不做修改;不重复 插入编码表
select count(spbm) into v_spbm_counts from dm_gy_spbmhc where spbm=v_spbm ;

if v_oper=‘2‘ then
if v_spbm_counts=0 then
select count(spbm) into v_spbm_counts from dm_gy_spbm where spbm=v_spbm ;
end if;

select count(spbm) into v_lwmc from dm_gy_spbmhc where spbm<>v_spbm and spmc=v_spmc ;

if v_lwmc >0 then
czzt:= -2 ;
return;
end if;
end if;
--新增商品编码验证是否重复,修改商品编码必须存在编码
if (v_spbm_counts>0 and v_oper=‘2‘) or (v_spbm_counts=0 and v_oper=‘3‘) then
czzt:= -1 ;
return;

else

-- 取出当前最大版本号,往上递加1(注意区分 总局 省局。如果总局操作那么小数点左边递增1.如果省局操作 那么小数点右边递增1 )

czzt:=0;
v_sytime:=v_SYSJ;
v_qytime:=v_QYSJ;
if v_sytime is null or v_sytime=‘‘ then
v_sytime:=sysdate;
end if;

if v_qytime is null or v_qytime=‘‘ then
v_qytime:=sysdate;
end if;

--新增商品商品编码
if v_oper=‘2‘ then
insert into dm_gy_spbmhc(spbm,spmc,SM,zzssl,hzx,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,FJBM,RKSJ,FBRDM,FBRXM)
values(v_spbm,v_spmc,v_SM,v_zzssl,v_kgb,v_gjz,v_zzstsgl,v_ZZSZCYJ,v_ZZSTSNRDM,v_XFSGL,v_XFSZCYJ,v_XFSTSNRDM,v_TJJBM,v_SPPM,v_fjbm,sysdate,v_FBRDM,v_FBRXM) ;
end if;

if v_oper=‘3‘ then
update dm_gy_spbmhc set spmc=v_spmc,SM=v_SM,zzssl=v_zzssl,hzx=v_kgb,gjz=v_gjz,zzstsgl=v_zzstsgl,ZZSZCYJ=v_ZZSZCYJ,ZZSTSNRDM=v_ZZSTSNRDM,
XFSGL=v_XFSGL,XFSZCYJ=v_XFSZCYJ,XFSTSNRDM=v_XFSTSNRDM,TJJBM=v_TJJBM,SPPM=v_SPPM
where spbm=v_spbm;
end if;

czzt:=1;
commit;

end if;

exception when others then
rollback;
dbms_output.put_line(sqlcode||‘ ‘||sqlerrm);
end hcspbm;

/

--16 创建存储过程 优惠政策维护
create or replace procedure whspbm(spbmxml in clob,v_ZZSTSGL in varchar2,v_ZZSZCYJ in varchar2,v_ZZSTSNRDM in varchar2
,v_XFSGL in varchar2,v_XFSZCYJ in varchar2,v_XFSTSNRDM in varchar2,FBRDM in varchar2,FBRXM in varchar2,BBSM in varchar2,vtype in varchar2,bbh out varchar2,czzt out number) is
v_version varchar2(200);
v_xtdate date;
gddate date;
qydate date;
begin

savepoint pt;
--计算版本
if(vtype=‘0‘) then --总局
select max(to_number(substr(bbh,1,instr(bbh,‘.‘)-1)))+1 into v_version from dm_gy_spbm_bb;

if(v_version is null or v_version =‘‘) then
v_version:=‘1.0‘;
end if;
if instr(v_version,‘.‘)=0 then
v_version:=v_version||‘.0‘;
end if;

else--省局
select max(to_number(bbh)) into v_version from dm_gy_spbm_bb;

if(v_version is null or v_version =‘‘) then
v_version:=‘0.0‘;
end if;
if instr(v_version,‘.‘)=0 then
v_version:=v_version||‘.0‘;
end if;
v_version:= substr(v_version,1,instr(v_version,‘.‘)-1)||‘.‘;

select (v_version||(max(to_number(substr(bbh,instr(bbh,‘.‘)+1)))+1)) into v_version from dm_gy_spbm_bb;

end if;

select GDQJZSJ,QYSJ into gddate,qydate from DM_GY_SPBM_BB where bbh=(select (max(floor(bbh))||‘.‘||max(to_number(replace(to_char((to_number(bbh)-floor(bbh))),‘.‘,‘‘)))) maxbbh from dm_gy_spbm_bb where bbh>=((select floor(max(to_number(bbh))) from dm_gy_spbm_bb)));
if qydate<sysdate then
qydate:=to_date(to_char(sysdate,‘YYYY/MM/DD‘),‘YYYY/MM/DD‘);
gddate:=to_date(to_char(sysdate,‘YYYY/MM/DD‘),‘YYYY/MM/DD‘);
end if;

v_xtdate:=sysdate;
insert into dm_gy_spbm_bb values(v_version,BBSM,v_xtdate,FBRDM,FBRXM,qydate,gddate);

for xsk in ( SELECT
EXTRACTVALUE(VALUE(t),‘/u/i‘) i--编码
, EXTRACTVALUE(VALUE(t),‘/u/t‘) t-- 类型
FROM TABLE(XMLSEQUENCE(EXTRACT(
XMLTYPE(spbmxml), ‘/d/u‘)))
t )
loop

if(xsk.t=‘1‘) then
update dm_gy_spbm set ZZSTSGL=v_ZZSTSGL,ZZSZCYJ=v_ZZSZCYJ,ZZSTSNRDM=v_ZZSTSNRDM,XFSGL=v_XFSGL,XFSZCYJ=v_XFSZCYJ,XFSTSNRDM=v_XFSTSNRDM,BBH=v_version,GDQJZSJ=gddate,QYSJ=qydate where SPBM like ‘‘||xsk.i||‘%‘;
elsif (xsk.t=‘2‘) then
update dm_gy_spbm set ZZSTSGL=v_ZZSTSGL,ZZSZCYJ=v_ZZSZCYJ,ZZSTSNRDM=v_ZZSTSNRDM,XFSGL=v_XFSGL,XFSZCYJ=v_XFSZCYJ,XFSTSNRDM=v_XFSTSNRDM,BBH=v_version,GDQJZSJ=gddate,QYSJ=qydate where FJBM=xsk.i;
elsif (xsk.t=‘3‘) then
update dm_gy_spbm set ZZSTSGL=v_ZZSTSGL,ZZSZCYJ=v_ZZSZCYJ,ZZSTSNRDM=v_ZZSTSNRDM,XFSGL=v_XFSGL,XFSZCYJ=v_XFSZCYJ,XFSTSNRDM=v_XFSTSNRDM,BBH=v_version,GDQJZSJ=gddate,QYSJ=qydate where SPBM=xsk.i;
end if;

end loop;

insert into dm_gy_spbm_bb_zb(JLXH,spbm,spmc,SM,zzssl,hzx,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,QYSJ,GDQJZSJ,BBH,rksj,istj)
select spbm_seq01.nextval,spbm,spmc,SM,zzssl,hzx,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,QYSJ,GDQJZSJ,BBH,v_xtdate,1 from (
select spbm,spmc,SM,zzssl,hzx,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,QYSJ,GDQJZSJ,BBH from dm_gy_spbm where BBH=v_version);
bbh:=v_version||‘|‘||to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘);
czzt:=1;
commit;

exception
when others then
bbh:=v_version||‘|‘||to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘)||‘|‘||sqlerrm;
rollback to savepoint pt;

end whspbm;
/

--17 创建存储过程 更新商品编码
create or replace procedure update_spbm (
v_spbm in VARCHAR2,
v_spmc in varchar2,
v_zzssl in varchar2,
v_KGB in varchar2,
v_KYZT in varchar2,
v_GJZ in varchar2,
v_ZZSTSGL in varchar2,
v_ZZSZCYJ in varchar2,
v_ZZSTSNRDM in varchar2,
v_XFSGL in varchar2,
v_XFSZCYJ in varchar2,
v_XFSTSNRDM in varchar2,
v_TJJBM in varchar2,
v_SPPM in clob,
v_SM in varchar2,
v_SYSJ in date,
v_QYSJ in date,
v_FJBM in varchar2,
v_FBRDM in varchar2,
v_FBRXM in varchar2,
v_oper in varchar2,
czzt out number --该变量记录本次操作的状态。 0 成功 -1 失败
)

as
v_spbm_counts number;
v_version varchar2(20);
v_sytime date;
v_qytime date;
v_lwmc number;
begin
--首先检查商品编码是否重复。如果 重复不做修改;不重复 插入编码表

select count(1) into v_spbm_counts from dm_gy_spbm where spbm=v_spbm ;

select count(1) into v_lwmc from dm_gy_spbm where spbm<>v_spbm and spmc=v_spmc ;

if v_lwmc >0 then
czzt:= -2 ;
return;
end if;
--新增商品编码验证是否重复,修改商品编码必须存在编码
if (v_spbm_counts>0 and v_oper=‘0‘) or (v_spbm_counts=0 and v_oper=‘1‘) then
czzt:= -1 ;
return;

else
-- 取出当前最大版本号,往上递加1(注意区分 总局 省局。如果总局操作那么小数点左边递增1.如果省局操作 那么小数点右边递增1 )

czzt:=0;
v_sytime:=v_SYSJ;
v_qytime:=v_QYSJ;
if v_sytime is null or v_sytime=‘‘ then
v_sytime:=sysdate;
end if;

if v_qytime is null or v_qytime=‘‘ then
v_qytime:=sysdate;
end if;
--计算版本
select max(to_number(substr(bbh,1,instr(bbh,‘.‘)-1)))+1 into v_version from dm_gy_spbm_bb;
if(v_version is null or v_version =‘‘) then
v_version:=‘1.0‘;
end if;
if instr(v_version,‘.‘)=0 then
v_version:=v_version||‘.0‘;
end if;

insert into dm_gy_spbm_bb values(v_version,‘‘,sysdate,v_FBRDM,v_FBRXM,v_sytime,v_qytime);

--新增商品商品编码
if v_oper=‘0‘ then
insert into dm_gy_spbm(spbm,spmc,SM,zzssl,HZX,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,QYSJ,GDQJZSJ,FJBM,BBH,RKSJ)
values(v_spbm,v_spmc,v_SM,v_zzssl,v_kgb,v_kyzt,v_gjz,v_zzstsgl,v_ZZSZCYJ,v_ZZSTSNRDM,v_XFSGL,v_XFSZCYJ,v_XFSTSNRDM,v_TJJBM,v_SPPM,v_sytime,v_qytime,v_fjbm,v_version,sysdate) ;
end if;

if v_oper=‘1‘ then
update dm_gy_spbm set spmc=v_spmc,SM=v_SM,zzssl=v_zzssl,HZX=v_kgb,kyzt=v_kyzt,gjz=v_gjz,zzstsgl=v_zzstsgl,ZZSZCYJ=v_ZZSZCYJ,ZZSTSNRDM=v_ZZSTSNRDM,XFSGL=v_XFSGL,
XFSZCYJ=v_XFSZCYJ,XFSTSNRDM=v_XFSTSNRDM,TJJBM=v_TJJBM,SPPM=v_SPPM,QYSJ=v_sytime,GDQJZSJ=v_qytime,BBH=v_version
where spbm=v_spbm;
end if;

insert into dm_gy_spbm_bb_zb(JLXH,spbm,spmc,SM,zzssl,HZX,kyzt,gjz,zzstsgl,ZZSZCYJ,ZZSTSNRDM,XFSGL,XFSZCYJ,XFSTSNRDM,TJJBM,SPPM,QYSJ,GDQJZSJ,BBH,rksj)
values(spbm_seq01.nextval,v_spbm,v_spmc,v_SM,v_zzssl,v_kgb,v_kyzt,v_gjz,v_zzstsgl,v_ZZSZCYJ,v_ZZSTSNRDM,v_XFSGL,v_XFSZCYJ,v_XFSTSNRDM,v_TJJBM,v_SPPM,v_sytime,v_qytime,v_version,sysdate) ;

czzt:=1;
commit;

end if;

exception when others then
rollback;
dbms_output.put_line(sqlcode||‘ ‘||sqlerrm);
end update_spbm;
/

--18创建存储过程 监控优惠政策
create or replace procedure jkyhzc(spbmxml in clob,v_ZZSTSGL in varchar2,v_ZZSZCYJ in varchar2,v_ZZSTSNRDM in varchar2
,v_XFSGL in varchar2,v_XFSZCYJ in varchar2,v_XFSTSNRDM in varchar2,v_FBRDM in varchar2,v_FBRXM in varchar2,v_YHZCWHF in varchar2,v_FBSJ in varchar2,v_BBH in varchar2,czzt out number) is
begin

savepoint pt;

for xsk in ( SELECT
EXTRACTVALUE(VALUE(t),‘/u/i‘) i--编码
, EXTRACTVALUE(VALUE(t),‘/u/t‘) t-- 类型
FROM TABLE(XMLSEQUENCE(EXTRACT(
XMLTYPE(spbmxml), ‘/d/u‘)))
t)
loop

if(xsk.t=‘1‘) then
insert into dm_gy_spbm_yhzc (JLXH, BBH, SPBM,YHZCWHF,FBSJ,FBRDM,FBRXM,XFSGL,XFSZCYJ,XFSTSNRDM,ZZSTSGL,ZZSZCYJ,ZZSTSNRDM,RKSJ)
select SEQ_YHZC.NEXTVAL,v_BBH,spbm,v_YHZCWHF,to_date(v_FBSJ,‘yyyy/mm/dd hh24:mi:ss‘),v_FBRDM,v_FBRXM,v_XFSGL,v_XFSZCYJ,v_XFSTSNRDM,v_ZZSTSGL,v_ZZSZCYJ,v_ZZSTSNRDM,sysdate
from(select spbm from dm_gy_spbm where SPBM like ‘‘||xsk.i||‘%‘);
elsif (xsk.t=‘2‘) then
insert into dm_gy_spbm_yhzc (JLXH, BBH, SPBM,YHZCWHF,FBSJ,FBRDM,FBRXM,XFSGL,XFSZCYJ,XFSTSNRDM,ZZSTSGL,ZZSZCYJ,ZZSTSNRDM,RKSJ)
select SEQ_YHZC.NEXTVAL,v_BBH,spbm,v_YHZCWHF,to_date(v_FBSJ,‘yyyy/mm/dd hh24:mi:ss‘),v_FBRDM,v_FBRXM,v_XFSGL,v_XFSZCYJ,v_XFSTSNRDM,v_ZZSTSGL,v_ZZSZCYJ,v_ZZSTSNRDM,sysdate
from(select spbm from dm_gy_spbm where FJBM=xsk.i);
elsif (xsk.t=‘3‘) then
insert into dm_gy_spbm_yhzc (JLXH, BBH, SPBM,YHZCWHF,FBSJ,FBRDM,FBRXM,XFSGL,XFSZCYJ,XFSTSNRDM,ZZSTSGL,ZZSZCYJ,ZZSTSNRDM,RKSJ)
select SEQ_YHZC.NEXTVAL,v_BBH,spbm,v_YHZCWHF,to_date(v_FBSJ,‘yyyy/mm/dd hh24:mi:ss‘),v_FBRDM,v_FBRXM,v_XFSGL,v_XFSZCYJ,v_XFSTSNRDM,v_ZZSTSGL,v_ZZSZCYJ,v_ZZSTSNRDM,sysdate
from(select spbm from dm_gy_spbm where SPBM=xsk.i);
end if;

end loop;

czzt:=1;
commit;

exception
when others then
rollback to savepoint pt;

end jkyhzc;
/

--19创建存储过程 更新商品编码对照表
create or replace procedure spbm_zzstsgl(zzxml clob) is
begin
delete dm_gy_zzstsgl;

for xsk in (
SELECT
EXTRACTVALUE(VALUE(t),‘/u/i‘) i--编码
, EXTRACTVALUE(VALUE(t),‘/u/t‘) t-- 类型
, EXTRACTVALUE(VALUE(t),‘/u/y‘) y-- 类型
, EXTRACTVALUE(VALUE(t),‘/u/p‘) p-- 类型
FROM TABLE(XMLSEQUENCE(EXTRACT(
XMLTYPE(zzxml), ‘/d/u‘)))
t)
loop
insert into dm_gy_zzstsgl(zzstsglmc,sm,sl,sybz) values(xsk.i,xsk.t,xsk.y,xsk.p);
end loop;

commit;
end spbm_zzstsgl;

/

spool off

时间: 2024-10-06 21:04:10

数据库升级脚本-最终版哦的相关文章

MySQL/MariaDB/Percona数据库升级脚本

MySQL/MariaDB/Percona数据库升级脚本截取<OneinStack>中upgrade_db.sh, 一般情况下不建议升级数据库版本,该脚本专提供给各位版本控们.为防止大版本之间兼容问题,脚本默认仅支持同一大版本之间的升级,如:MySQL- 5.6.25升级到MySQL-5.6.26.MySQL-5.5.44升级到MySQL-5.5.45.MariaDB-10.0.20升级到 MariaDB-10.0.21:不能跨分支版本且不能跨大版本,如从MySQL-5.5.44升级到Perc

【转】用PowerDesigner制作数据库升级脚本

[原创]用PowerDesigner制作数据库升级脚本 很多人使用PD的时候就问有没有制作自动升级脚本的功能.其实是有的. 操作原理: 1.保存原来的版本,另存为apm的文件,生成一个Archive Model. 2.生成升级脚本,需要选择原来的版本 操作步骤: 1.打开PDM文件,选择Save as .... 另存为,在弹出的窗口中选择apm的文件类型,输入文件名保存即可. 2.修改相关的数据模型的内容,然后保存. 3.选择DataBase菜单中的modify database... 菜单 4

数据库升级代码学习

  业务场景及需求:全国每一个银行营业网点[指跟公司合作的]产品上线后.肯定须要升级业务以应对新的功能需求,那么数据库每次升级更新时都是在数据库管理工具中运行升级脚本.很不方便.此时需求:可以在业务系统代码中设置开关,须要升级的时候打开开关系统自己主动直接完毕升级. 思路:1)数据库里面有个对应的版本号号,服务里面有个版本号文件[以要升级到的版本号号命名]. 2)升级的时候查出服务里面的版本号和数据库里面的版本号,比对:假设版本号一样不升级.假设版本号不一样就运行服务里面的升级脚本. 以下看看基

针对数据库升级版本信息采集脚本编写

[环境介绍] 系统环境:Linux + 11G+ 集群/单机 [背景描述] 需求:每个季度都会有数据库漏洞扫描修复的事情,了解该扫描方式是根据数据库版本来进行判断是否当前数据库版本是否修复相应漏洞.而已一般漏洞信息分DBMS/OJVM/GRID类型漏洞.如果是当前维护的数据库,自己取数据库版本信息比较容易,但是大多时候接到协助升级的时候收集信息比较麻烦.需要较快的采取数据库版本信息和系统信息来进行写方案或者判断当前数据库是否需要升级及风险判断. [监控优化过程及思路] 对于上面描述的问题: 1,

数据库升级到mysql5.7出现的1067 - Invalid default value for &#39;字段名&#39; (docker版)

docker run -d --name xxx --network lnmp7 -p 3306:3306 -v /data/xxx/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=oneone mysql:5.7 docker container cp xxx:/etc/mysql/mysql.conf.d .   // 取出mysql中的配置文件 docker stop xxx docker rm -f xxx //删除实例 mv mysql.conf.

jQuery 3.0最终版发布,十大新特性眼前一亮

jQuery 3.0在日前发布了最终的全新版本.从2014年10月,jQuery团队对这个主要大版本进行维护开始,web开发者社区便一直在期待着这一刻的到来,终于在2016年6月他们迎来了这一个最终版www.lampbrother.net. 通过jQuery 3.0的版本更新说明,我们看到了一个保持着向后兼容的更轻便,更快速的jQuery.在本文中,我们将介绍一些令人眼前一亮的jQuery 3.0全新特性. 开始前的说明 如果你想要下载jQuery 3.0进行亲自实验,可以通过该页面进行下载.另

数据库升级ora-04063 DBMS_REGISTRY has error

在做Oracle数据库从11.2.0.1.0升级到11.2.0.2.8时,软件升级没有问题,实例升级没有问题,升级psu的时候. 运行@?/rdbms/admin/catbundle psu apply时,只显示一部分信息,即终止apply. 在dba_registry_history中未显示11.2.0.2.8的psu信息: select * from dba_registry_history; ACTION_TIME                    ACTION          NA

Android 数据库升级解决方案

转自:http://blog.csdn.net/leehong2005/article/details/9128501 请考虑如下情况: 在数据库升级时,不同版本的数据库,他们定义的表结构完全可能是不一样的,比如V1.0的表A有10个column,而在V1.1的表A有12个colum,在升级时,表A增加了两列,此时我们应该怎么做呢. 总体思路 1,将表A重命名,改了A_temp. 2,创建新表A. 3,将表A_temp的数据插入到表A. 下面代码列出了更新表的实现,upgradeTables,给

探索Oracle之数据库升级八 12c Downgrade 11gR2

探索Oracle之数据库升级八 12c Downgrade 11gR2 前言: 我们前面已经完成了11gR2 upgrade to 12c 的升级,整个过程还是比较顺利的,虽然和以前版本升级有些不太一样,但是整个难度不是太大,但是由于太多的特性不同,大大的加长了升级的时间. 但是对于Oracle 12c降回到之前版本,会有些限制,只能降级到升级前所用的版本和补丁级别. 如果我们是直接从10.2.0.5.11.1.0.7或版本11.2.0.2及更高版进行升级.那么将无法降级到10.2.0.5. 如