declare
existFlag int;
existColFlag int;
begin
select count(1) into existFlag from user_tables where table_name = upper('Print_Bill');
select count(1) into existColFlag from user_tab_columns where table_name=upper('Print_Bill') and column_name=upper('BillMKID');
IF existFlag>0 THEN
IF existColFlag=0 THEN
execute immediate 'alter table PRINT_BILL add BillMKID varchar(4) default '' '' not null';
END IF;
execute immediate 'alter table PRINT_BILL rename to PRINT_BILLTEMP';
execute immediate '
CREATE table PRINT_BILL
(BillMKID varchar(4) not null, /*单据所属模块ID*/
BillID varchar(50) primary key not null, /*单据逻辑名称*/
BillName varchar(50) not null, /*单据显示名称*/
RecordsPath varchar(200) null ,
ParamCount int default 0 /*生成的XML中的参数个数*/
)';
execute immediate 'insert into Print_Bill(BillMKID,BillID,BillName,RecordsPath,ParamCount) select BillMKID,BillID,BillName,RecordsPath,ParamCount from Print_Billtemp';
execute immediate 'drop table Print_Billtemp';
ELSE
execute immediate '
CREATE table PRINT_BILL
(
BillMKID varchar(4) not null, /*单据所属模块ID*/
BillID varchar(50) primary key not null, /*单据逻辑名称*/
BillName varchar(50) not null, /*单据显示名称*/
RecordsPath varchar(200) null ,
ParamCount int default 0 /*生成的XML中的参数个数*/
)';
END IF;
END;