“书籍过期不显示罚款”处理概要


     “书籍过期不显示罚款”处理概要


1.随机抽取数据,查看要处理数据的格式
select  z31_rec_key,z31_description,z31_sum from z31 where z31_credit_debit='D' and z31_rec_key like '1061400225%';
select  z31_description,z31_sum from z31 where z31_credit_debit='C' and z31_rec_key like '1061400225%';
select  z31_description from z31 where z31_rec_key like '1061400225%' and z31_status='C';
select  z31_description from z31 where z31_rec_key like '1061400225%' and z31_status='O' and z31_type=3;
select  z31_description from z31 where z31_rec_key like '1061400225%' and z31_status='W';
select z31_sum,z31_description from z31 where z31_rec_key='1061400225  200405221414401';

2.更新z31表的一条记录的z31_sum字段
update z31 set z31_sum='00000000000250' where z31_rec_key='1061400225  200405221414401';

3.确定Z31表的结构与数据存储方式

select  z31_sum from z31 where z31_credit_debit='D' and z31_rec_key like '4369%';
select  z31_rec_key,z31_status,z31_sum from z31 where  z31_rec_key like '4369%';

4.统计要处理的数据量
select count(*) from  z31 where z31_status='O' and z31_credit_debit='D' and z31_sum='00000000000000';

5.创建备份数据表结构
create table z31_bak
(
Z31_REC_KEY                                   CHAR(27),
Z31_DATE                                           NUMBER(8),
Z31_STATUS                                         CHAR(1),
Z31_SUB_LIBRARY                                    CHAR(5),
Z31_ALPHA                                          CHAR(1),
Z31_TYPE                                           NUMBER(4),
Z31_CREDIT_DEBIT                                   CHAR(1),
Z31_SUM                                            CHAR(14),
Z31_PAYMENT_DATE_KEY                               CHAR(12),
Z31_PAYMENT_CATALOGER                              CHAR(10),
Z31_PAYMENT_TARGET                                 VARCHAR2(20),
Z31_PAYMENT_IP                                     VARCHAR2(20),
Z31_PAYMENT_RECEIPT_NUMBER                         VARCHAR2(20),
Z31_DESCRIPTION                                    VARCHAR2(100),
Z31_KEY                                            VARCHAR2(100),
Z31_KEY_TYPE                                       CHAR(10)
)

6.备份Z31表的数据到备份表中
insert into z31_bak
(
 Z31_REC_KEY,
 Z31_DATE ,
 Z31_STATUS ,
 Z31_SUB_LIBRARY,
 Z31_ALPHA ,Z31_TYPE,
 Z31_CREDIT_DEBIT,
 Z31_SUM,
 Z31_PAYMENT_DATE_KEY,
 Z31_PAYMENT_CATALOGER,
 Z31_PAYMENT_TARGET,
 Z31_PAYMENT_IP,
 Z31_PAYMENT_RECEIPT_NUMBER,
 Z31_DESCRIPTION ,
 Z31_KEY,
 Z31_KEY_TYPE
)
select
 Z31_REC_KEY,
 Z31_DATE ,
 Z31_STATUS ,
 Z31_SUB_LIBRARY,
 Z31_ALPHA ,
 Z31_TYPE,
 Z31_CREDIT_DEBIT,
 Z31_SUM,
 Z31_PAYMENT_DATE_KEY,
 Z31_PAYMENT_CATALOGER,
 Z31_PAYMENT_TARGET,
 Z31_PAYMENT_IP,
 Z31_PAYMENT_RECEIPT_NUMBER,
 Z31_DESCRIPTION ,
 Z31_KEY,
 Z31_KEY_TYPE
from z31;

7.使用左填充函数,将char2字符补充到char1的左侧,使char1的长度为n
lpad(char1,n,char2)

8.创建关键字段数据表
create table z31_source
(
Z31_REC_KEY                           CHAR(27),
Z31_STATUS                            CHAR(1),
Z31_SUM                               CHAR(14),
Z31_DESCRIPTION                       VARCHAR2(100)
);

9.将要处理的数据字段复制到z31_source表中

insert into z31_source
(
 Z31_REC_KEY,Z31_STATUS ,Z31_SUM,Z31_DESCRIPTION
)
select
 Z31_REC_KEY,Z31_STATUS ,Z31_SUM,Z31_DESCRIPTION 
from
 z31
where
 z31_status='O' and z31_type=3 and z31_credit_debit='D';

10.再次统计要处理的数据条数
select count(*) from z31 where z31_status='O' and z31_type=3 and z31_credit_debit='D';

11.实验字符串截取函数substr找到相应的位置
select substr(z31_description,8,4) from z31_source where z31_rec_key='1011200007  200305060947702';

12.字符串转换成数字函数
select to_number(substr(z31_description,8,4))*50 from z31_source where z31_rec_key='1011200007  200305060947702';

13.为z31_source表增加字段money来存储罚款金额
ALTER TABLE z31_source ADD money char(10);

14.实验一条数据更新money字段
update z31_source set money=to_char(to_number(substr(z31_description,8,4))*50) where z31_rec_key='1011200007  200305060947702';

15.更新所有记录的money字段
update z31_source set money=to_char(to_number(substr(z31_description,8,4))*50);

16.更新一条记录的z31_sum字段
update z31_source set z31_sum=lpad(trim(money),14,'0') where z31_rec_key='1011200007  200305060947702';

17.更新所有记录的z31_sum字段
update z31_source set z31_sum=lpad(trim(money),14,'0');

18.同步一条记录
update z31 set z31_sum = (
select z31_sum from z31_source where z31_rec_key='1011200007  200305060947702')
where z31_rec_key='1011200007  200305060947702';

19.查看结果
select z31_sum from z31 where z31_rec_key='1011200007  200305060947702';

20.同步所有记录
update z31 set z31_sum= (select z31_sum from z31_source where z31_rec_key=z31.z31_rec_key) where z31_status='O';

21.同照备份数据库,查看更新结果
select z31_rec_key,z31_sum,money from z31_source where to_number(money)=0;
select z31_rec_key,z31_sum,money from z31_source where to_number(z31_sum)=0;

select count(*) from z31_bak where z31_status='O';
select count(*) from z31_bak where to_number(z31_sum)>0;
select count(*) from z31 where z31_status='O';
     11444
select count(*) from z31 where z31_status='C';
    7573
select count(*) from z31 where z31_status='W';
    31
select count(*) from z31;
   19051

22.发现有空记录
select count(*) from z31 where z31_sum is NULL;
   3086

23.从备份表中将空记录恢复
update z31 set z31_sum=(select z31_sum from z31_bak where z31_rec_key =z31.z31_rec_key) where z31_sum is NULL;

24.查看是否还有空记录
select z31_rec_key,z31_description from z31 where z31_sum is NULL;

25.单独处理空记录(空记录的出现是因为在处理数据过程中有读者还书,所以以后再次处理这些事情需要将数据库停止服务)

update z31 set z31_sum='00000000000100' where z31_rec_key='1231103004  200406201916473';
update z31 set z31_sum='00000000000200' where z31_rec_key='1291402050  200406201938783';
update z31 set z31_sum='00000000000100' where z31_rec_key='1252203031  200406201957736';
update z31 set z31_sum='00000000000100' where z31_rec_key='1252203031  200406201958477';

26.查看是否有不合理的数据,即单笔过期罚款金额大小50元
select z31_rec_key,z31_sum  from z31 where to_number(z31_sum)>5000 and z31_type=3 and z31_STATUS='O';

27.找出记录并处理掉
select count(*) from z31 where z31_type=3 and z31_status='O' and z31_key like '__________________________________________________________20030109%';
select z31_rec_key from z31 where z31_type=3 and z31_status='O' and z31_key like '__________________________________________________________20030109%';

delete from z31 where z31_rec_key='1272402065  200308040904954';
delete from z31 where z31_rec_key='1272402065  200308040904995';
delete from z31 where z31_rec_key='1272402065  200308040905024';
delete from z31 where z31_rec_key='1272402065  200308040905451';
delete from z31 where z31_rec_key='1044401008  200308041026870';
delete from z31 where z31_rec_key='1044401008  200308041026909';
delete from z31 where z31_rec_key='1044401008  200308041026951';

28.统计是否还有相似的记录
select count(*) from z31 where z31_type=3 and z31_key like '__________________________________________________________20030109%';

29.查找GUI未显示付款记录(过期2天)

select z31_rec_key,z31_sum from z31 where substr(z31_description,8,4) ='0002' and substr(z31_rec_key,13,8)='20040622' and z31_status='O';

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
图书资料管理信息系统,带源代码、数据库sql文件、课设报告,具备如下基本功能: 1、 系统管理功能有:角色管理、用户管理、修改密码。主要实现系统的安全管理,不同的操作者有不同的权限,可以执行不同的操作。普通读者的权限只能是查询图书及自己的借阅情况;而图书馆管理员可以对图书信息进行管理,如对新书入库,也可以管理用户,如添加新用户和删除不用的账号等。 2、 进书管理功能有:登记基本的图书信息。这部分的功能用于登记新书的书名、作者、出版社、价格、进书的册数、进书日期、ISBN等。 3、 图书入库管理功能有:对新书分类编目,及时更新图书库中的图书信息。这部分的功能用于对所购进的新书,按其种类学科进行编目,给与唯一的书号;及时更新书库中的图书信息,包括书名、书号、作者、出版社、价格、库存位置和库存册数这些信息,方便读者查询借阅。 4、 查询功能功能有:查询图书的信息,查询读者的借阅情况。这部分的功能主要提供多种方式的查询服务。读者可以根据书名、作者或关键字模糊查询图书信息;读者也可以根据自己的借书证号查询自己的借阅情况,如已借了几本书,借书日期,还书日期,有没有续借等。 5、 借书/还书管理功能有:借书管理、还书管理。这部分的功能是当读者借书时,系统根据借书证号识别读者身份,核对读者的借书信息,做出判断如可不可以借、还可借几本,成功借阅后记录在借书信息并修改书库图书信息。当读者还书时,系统根据借书证号识别读者身份,核对读者的借书信息,做出判断如有没有超期,要不要罚款,需要罚多少等,最后还书成功,修改书库图书信息。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值