oracle reports实现报表定长与定宽输出
oracle reports是oracle的数据统计及图形化报表工具,它提供了六种风格的报表格式,而我们通常使用的只有其中的两种,即tabular和matrix,无论用哪种风格生成的报表,打印出的表格数都是动态变化的。其中tabular风格的报表,列数固定,而行数不定;matrix风格的报表,行数和列数均不定。那么在oracle reports中如何实现报表的'定长与定宽输出呢?
一、对于tabular风格的报表,可用报表触发子after parameter form和after report实现定长输出。其方法是:根据实际情况确定每页打印的行数,当最后一页的记录数少于每页打印的行数时,则用空记录补齐。在触发子after parameter form插入空记录,在触发子after report中再将空记录删除,下面举例说明。
假设有一数据基表wzdm:存放物资代码信息,其数据结构为:
字段名 | 含义 | 长度 | 类型 |
wzdm | 物资代码 | 9 | c |
wzmc | 物资名称 | 20 | c |
xhgg | 型号规格 | 20 | c |
jldw | 计量单位 | 6 | c |
要求:按定长输出物资代码表,并且每页均输出x行(x可根据实际情况而定)。
1.启动oracle*reports,建立物资代码打印报表(略),然后在报表触发子after parameter form中加入以下代码:
declare
v—jls number(2);
i number(2):=1;
begin
select count(*) into v—jls from wzdm;
if mod(v—jls,x)〈〉0 then
loop
exit when i〉=(x-mod(v—jls,x))+1;
insert into wzdm(wzdm,wzmc,xhgg,jldw)
values(′′,′′,′′,′′);
i:=i+1;
end loop;
commit;
end if;
end;
在报表触发子after report中分别加入以下代码:
begin
delete from wzdm where wzdm is null;
commit;
end;
2.运行报表后即可输出定长的物资代码表。
说明:对于其它tabular风格的报表,在编写上述两个触发子时只需将基表名与列名根据实际情况修改一下,并确定x的值即可。
二、对于matrix风格的报表,可利用视图实现定长与定宽输出,其思路是:当行记录数和列记录少于实际报表的行数和列数时,均以空记录补齐。下面举例说明。
假设有一物资资金消耗去向统计月报,该表横向显示本期消耗去向,纵向显示物资类别,由于每月物资消耗去向和消耗物资均不定,所以此类报表即为一矩阵报表。该报表的数据存放在基表t—zjxhqx中,其数据结构如下:
字段名 | 含义 | 长度 | 类型 |
lbmc | 类别名称 | 20 | c |
dwmc | 单位名称 | 20 | c |
je | 金额 | 14,2 | n |
要求:按定长定宽输出物资资金消耗去向统计月报,并且每页均输出x行y列(行数和列数可根据实际情况而定)。
1.首先建一基表t—kjl,用来存放空记录,其数据结构为:
字段名 | 含义 | 长度 | 类型 |
no | 序号 | 2 | n |
建完该数据表后,再往其中插入记录,记录数可根据实际情况而定,一般为一页所能打印的最大行数,这里假设为z条,即no的值为1,2,3…z。
2.建视图,其过程如下:
create view v—tjbb as
select dwmc,lbmc,je from t—zjxhqx
union
select dwmc,null,to—number(null) from t—zjxhqx,t—kjl
where no-(z-x)〉(select mod(count(distinct lbmc)-1,x)+1 from t—zjxhqx)
union
select null,lbmc,to—number(null) from t—zjxhqx,t—kjl
where no-(z-y)〉(select mod(count(distinct dwmc)-1,y)+1 from t—zjxhqx);
3. 启动oracle*reports,建立矩阵报表查询时直接引用视图v—tjbb即可。这样运行时输出的报表每页都是x行y列,即实现了定长和定宽输出。
相關文章
-
MySQL安装时出现current root password的解决方法
总结出以下解决方法:1.清除MYSQL的`安装目录,默认是C:Program Files2.清除MYSQL数据存放目录,一般在C:Documents and SettingsAll owsApplication Data目录下(需要注意的时Application Data这个文件夹默认是隐藏的,要通过 -
Choice of large enterprises or small英语四级作文
本文目录建筑学实习报告范文建筑学测量实习报告建筑学施工实习报告建筑学专业大学生实习报告范文一、实习目的通过接触和参加实际工作,充实和扩大自己的知识面,培养综合应用的能力,为以后走上工作岗位打下基础,更好的走向 -
A Letter to the Editor of a Newspaper英语四级作文
June 20th, 2004Dear Mr. / Miss Editor,I am a student from Tsinghua University and I am writing to you about my experience of buying a dictionary and my complaint about the service of a bookstore.It wa -
英语阅读:VIT declines to acquire Ang Mo Kio property
像在北方地区大棚内的黑坑较为多见,自然不会受到多少自然因素的影响,可遮风挡雨,现在的垂钓环境也是越来越好内部还设有地暖、大灯,大大提高了钓鱼的舒适度。冬季来临,气温突降,越来越多的北方钓友开始转战大棚,高手在线嘉宾 -
Efforts Urged to Improve Womens Reproductive Health英语阅读
Efforts Urged to Improve Women's Reproductive HealthParliamentarians from over 100 countries are being urged to take action in improving women's reproductive health ahead of the 2015 deadline -
人物性格分析 The Analysis of Personal Character英语作文
在学习、工作或生活中,大家对作文都再熟悉不过了吧,借助作文人们可以实现文化交流的目的。相信许多人会觉得作文很难写吧,下面是小编精心整理的.人物性格分析 The Analysis of Personal Character英语作文,欢迎大家分享。 -
Protecting water resources英语作文
Water is to us what air is to birds. As our daily necessity, we can't live without water. Nevertheless, there do exist many severe water pollutions all over the world. As a result, it's no dou -
英语作文Let the Surprise Speak of Your Love
In China, people are not used to saying out the word “love”, they don’t express their emotion strongly, it is Chinese tradition, people believe that deep love should be proved in action instead of -
Illustrator与CorelDRAW操作的对比
注:文章用AI来表示Illustrator,CD表示CorelDRAW。一、文件互换打开本机格式:AI打开CD,限制在CD10以前,以后的版本不能打开。CD打开AI,CDX4打开AICS3以下(非压缩,可在AI保存文件时取消压缩),CDX3打开AICS2以下,以此类推。另存格 -
公共英语二级写作Preserving Natural Resources
Through the changes in the ways of making a living in a family over several generations, the cartoon aims at sounding a waing against mans wasteful use of natural resources and emphasizing the urgent