create table miParam(
yKey varchar(20) not null,
yValue varchar(255) not null,
yMemo varchar(255) not null default '',
primary key(yKey))
insert into miParam values('FCompCode', '贵阳市第一公墓','')
insert into miParam values('FMaxLogCountCode','10000','');
create table miLog(
yCode int not null,
yDate varchar(10) not null default '',
yTime varchar(8) not null default '',
yType int not null default 0,
yModuleDesc varchar(20) not null default '',
yOperation varchar(255) not null default '',
yOperMan varchar(20) not null default '',
primary key(yCode))
create table miDegree(
yCurrentNo int not null,
yParentNo int not null,
yDesc varchar(20) not null,
yMemo varchar(255) not null default '',
primary key(yCurrentNo))
create unique index IX_miDegree_yDesc on miDegree(yDesc)
create table miLevel(
yCode int not null,
yDesc varchar(20) not null,
yMemo varchar(255) not null default '',
primary key(yCode))
create unique index IX_miLevel_yDesc on miLevel(yDesc)
create table miDepart(
yCode int not null,
yDesc varchar(20) not null,
yMemo varchar(255) not null default '',
primary key(yCode))
create unique index IX_miDepart_yDesc on miDepart(yDesc)
create table miPsn(
yCode varchar(20) not null,
yDesc varchar(20) not null,
yDepartCode int not null default '',
yDegreeCode int not null default '',
yLevelCode int not null default '',
ySex varchar(2) not null default '',
yAge int not null default 0,
yPolitics varchar(4) not null default '',
yKnowledge varchar(20) not null default '',
yTelephone varchar(20) not null default '',
yMail varchar(20) not null default '',
yPicAddr varchar(255) not null default'',
yMemo varchar(255) not null default '',
primary key(yCode),
Constraint FK_miPsn_miDepart foreign key(yDepartCode) references miDepart(yCode),
Constraint FK_miPsn_miDegree foreign key(yDegreeCode) references miDegree(yCurrentNo),
Constraint FK_miPsn_miLevel foreign key(yLevelCode) references miLevel(yCode))
create unique index IX_miPsn_yDesc on miPsn(yDesc)
create table miTombPos(
yCode int not null,
yDesc varchar(20) not null,
yMemo varchar(255) not null default '',
primary key(yCode))
create unique index IX_miTombPos_yDesc on miTombPos(yDesc)
create table miTombType(
yCode int not null,
yDesc varchar(20) not null,
yBaseFee numeric(15,2) not null default 0,
yManageFee numeric(15,2) not null default 0,
yOtherFee numeric(15,2) not null default 0,
yCheapFee numeric(15,2) not null default 0,
yMemo varchar(255) not null default '',
primary key(yCode))
create unique index IX_miTombType_yDesc on miTombType(yDesc)
create table miTombReg(
ySn int not null,
yBuyTime varchar(19) not null default '',
yBuyMan varchar(20) not null default '',
yPsnCode varchar(20) not null default -1,
yDepartCode int not null default -1,
yTypeCode int not null default -1,
yPosCode int not null default -1,
yBaseFee numeric(15,2) not null default 0,
yManageFee numeric(15,2) not null default 0,
yOtherFee numeric(15,2) not null default 0,
yCheapFee numeric(15,2) not null default 0,
yBondNumber varchar(20) not null default '',
yTombNumber varchar(20) not null default '',
yInvoiceNumber varchar(20) not null default '',
yManageFeeNumber varchar(20) not null default '',
yReceivePicTime varchar(19) not null default '',
yAttachPicTime varchar(19) not null default '',
yTabletTime varchar(19) not null default '',
yInBoxTime varchar(19) not null default '',
yFee1 numeric(15,2) not null default 0,
yFee1Time varchar(19) not null default '',
yFee1Man varchar(20) not null default '',
yFee2 numeric(15,2) not null default 0,
yFee2Time varchar(19) not null default '',
yFee2Man varchar(20) not null default '',
yFee3 numeric(15,2) not null default 0,
yFee3Time varchar(19) not null default '',
yFee3Man varchar(20) not null default '',
yFee4 numeric(15,2) not null default 0,
yFee4Time varchar(19) not null default '',
yFee4Man varchar(20) not null default '',
yFee5 numeric(15,2) not null default 0,
yFee5Time varchar(19) not null default '',
yFee5Man varchar(20) not null default '',
yDeathName1 varchar(20) not null default '',
yDeathName2 varchar(20) not null default '',
yDeathSex1 varchar(2) not null default '',
yDeathSex2 varchar(2) not null default '',
yDeathAge1 int not null default 0,
yDeathAge2 int not null default 0,
yDeathPicAddr1 varchar(255) not null default '',
yDeathPicAddr2 varchar(255) not null default '',
yTelephone varchar(20) not null default '',
yAddress varchar(50) not null default '',
yOperMan varchar(20) not null default '',
yMemo varchar(255) not null default '',
primary key(ySn),
Constraint FK_miTombReg_miPsn foreign key(yPsnCode) references miPsn(yCode),
Constraint FK_miTombReg_miDepart foreign key(yDepartCode) references miDepart(yCode),
Constraint FK_miTombReg_miTombType foreign key(yTypeCode) references miTombType(yCode),
Constraint FK_miTombReg_miTombPos foreign key(yPosCode) references miTombPos(yCode)
)
create unique index IX_miTombReg_yBondNumber on miTombReg(yBondNumber)
create unique index IX_miTombReg_yPosCode on miTombReg(yPosCode)
create table miTombChg(
yChgSn int not null,
yChgOldPosCode int not null,
yChgNewPosCode int not null,
yChgOldTypeCode int not null,
yChgNewTypeCode int not null,
yChgDatetime varchar(19) not null default '',
yChgMemo varchar(255) not null default '',
primary key(yChgSn),
Constraint FK_miTombChg_miTombReg foreign key(yChgSn) references miTombReg(ySn),
Constraint FK_miTombChg_miTombPos1 foreign key(yChgOldPosCode) references miTombPos(yCode),
Constraint FK_miTombChg_miTombPos2 foreign key(yChgNewPosCode) references miTombPos(yCode),
Constraint FK_miTombChg_miTombType1 foreign key(yChgOldTypeCode) references miTombType(yCode),
Constraint FK_miTombChg_miTombType2 foreign key(yChgNewTypeCode) references miTombType(yCode)
)
create view vTombRegQry as
select tr.ySn, tr.yBuyTime, tr.yBuyMan, tr.yPsnCode, p.yDesc yPsnDesc,
tr.yDepartCode, d.yDesc yDepartDesc, tr.yTypeCode, tt.yDesc yTypeDesc,
tr.yPosCode, tp.yDesc yPosDesc, tr.yBaseFee, tr.yManageFee, tr.yOtherFee, tr.yCheapFee,
tr.yBondNumber, tr.yTombNumber, tr.yInvoiceNumber, tr.yManageFeeNumber,
tr.yReceivePicTime, tr.yAttachPicTime, tr.yTabletTime, tr.yInBoxTime,
tr.yFee1, tr.yFee1Time, tr.yFee1Man, tr.yFee2, tr.yFee2Time, tr.yFee2Man,
tr.yFee3, tr.yFee3Time, tr.yFee3Man, tr.yFee4, tr.yFee4Time, tr.yFee4Man,
tr.yFee5, tr.yFee5Time, tr.yFee5Man, tr.yDeathName1, tr.yDeathName2,
tr.yDeathSex1, tr.yDeathSex2, tr.yDeathAge1, tr.yDeathAge2, tr.yDeathPicAddr1,
tr.yDeathPicAddr2, tr.yTelephone, tr.yAddress, tr.yOperMan, tr.yMemo,
tr.yCheapFee yTotalShouldPay,
tr.yFee1+tr.yFee2+tr.yFee3+tr.yFee4+tr.yFee5 yTotalHavedPay,
tr.yCheapFee-(tr.yFee1+tr.yFee2+tr.yFee3+tr.yFee4+tr.yFee5) yRemainPay
from miTombReg tr, miPsn p, miDepart d, miTombType tt, miTombPos tp
where tr.yPsnCode=p.yCode and tr.yDepartCode=d.yCode
and tr.yTypeCode=tt.yCode and tr.yPosCode=tp.yCode