-----------------------------------------------------------------------------------------------------------------

    eb_rp_pertrancereportday(个人网银业务状况明细日报表).sql

 from sysobjects where name = 'eb_rp_pertrancereportday' and type = 'P')
    drop procedure eb_rp_pertrancereportday
go

))     --个人网银业务状况明细日报表
as
begin
    )
    )

    declare @iitrnm int                            --期初行内转账笔数
    ,)                --期初行内转账金额
    declare @intrnm int                            --新增行内转账笔数
    ,)                --新增行内转账金额
    declare @ietrnm int                            --期末行内转账笔数
    ,)                --期末行内转账金额

    declare @oitrnm int                            --期初跨行转账笔数
    ,)                --期初跨行转账金额
    declare @ontrnm int                            --新增跨行转账笔数
    ,)                --新增跨行转账金额
    declare @oetrnm int                            --期末跨行转账笔数
    ,)                --期末跨行转账金额

    declare @aitrnm int                            --期初总计转账笔数
    ,)                --期初总计转账金额
    declare @antrnm int                            --新增总计转账笔数
    ,)                --新增总计转账金额
    declare @aetrnm int                            --期末总计转账笔数
    ,)                --期末总计转账金额

    )                --今天first 格式yyyy-mm-dd
    )                --明天end 格式yyyy-mm-dd
    )             --昨天last 格式yyyymmdd
    )                --明天  格式yyyymmdd
    select @f_rprtdt = convert(varchar,datepart(yy,@rprtdt))+"-"+convert(varchar,datepart(mm,@rprtdt))+"-"+convert(varchar,datepart(dd,@rprtdt))
    ,)
    select @e_rprtdt = convert(varchar,datepart(yy,@n_rprtdt))+"-"+convert(varchar,datepart(mm,@n_rprtdt))+"-"+convert(varchar,datepart(dd,@n_rprtdt))
    ,)

    --取网点号
    ' order by brchno for read only
    open cur_rprt
    fetch cur_rprt into @brchno,@brchna

    begin    

         ')
        begin

            select @iitram = 0.00

            select @intram = 0.00

            select @ietram = 0.00

            select @oitram = 0.00

            select @ontram = 0.00

            select @oetram = 0.00

            select @aitram = 0.00

            select @antram = 0.00

            select @aetram = 0.00
        end
        else begin
            '
            '
            '
        end

        --新增(当天)行内转账笔数和金额
        ), @intram = sum(tranam) from epc_flog a, epc_cifx b where a.mastid = b.mastid and senddt >= @f_rprtdt and senddt < @e_rprtdt and b.brchid = @brchno and a.status = 'success' and tranna = '/transfer/transferInBank'
        --新增(当天)跨行转账笔数和金额
        ), @ontram = sum(tranam) from epc_flog a, epc_cifx b where a.mastid = b.mastid and senddt >= @f_rprtdt and senddt < @e_rprtdt and b.brchid = @brchno and a.status = 'success' and tranna = '/transfer/transferOutBank'

        if @iitram is null
        begin
            select @iitram = 0.00
        end

        if @intram is null
        begin
            select @intram = 0.00
        end

        if @ietram is null
        begin
            select @ietram = 0.00
        end            

        if @oitram is null
        begin
            select @oitram = 0.00
        end

        if @ontram is null
        begin
            select @ontram = 0.00
        end

        if @oetram is null
        begin
            select @oetram = 0.00
        end

        if @aitram is null
        begin
            select @aitram = 0.00
        end

        if @antram is null
        begin
            select @antram = 0.00
        end

        if @aetram is null
        begin
            select @aetram = 0.00
        end

        select @antrnm = @intrnm + @ontrnm  --当天新增转账笔数合计
        select @antram = @intram + @ontram  --当天新增转账金额合计

        select @ietrnm = @iitrnm + @intrnm  --本期行内转账笔数
        select @oetrnm = @oitrnm + @ontrnm    --本期跨行转账笔数
        select @aetrnm = @aitrnm + @antrnm    --本期合计转账笔数    

        select @ietram = @iitram + @intram   --本期行内转账金额
        select @oetram = @oitram + @ontram     --本期跨行转账金额
        select @aetram = @aitram + @antram     --本期行内转账金额

        ')
        fetch cur_rprt into @brchno,@brchna
    end
    close cur_rprt
    deallocate cursor cur_rprt

end
go

-----------------------------------------------------------------------------------------------------------------

    eb_rp_pertrancereportmonth(个人网银业务状况明细月报表).sql

 from sysobjects where name = 'eb_rp_pertrancereportmonth' and type = 'P')
    drop procedure eb_rp_pertrancereportmonth
go

))     --个人网银业务状况明细月报表
as
begin
    )
    )

    declare @iitrnm int                            --期初行内转账笔数
    ,)                --期初行内转账金额
    declare @intrnm int                            --新增行内转账笔数
    ,)                --新增行内转账金额
    declare @ietrnm int                            --期末行内转账笔数
    ,)                --期末行内转账金额

    declare @oitrnm int                            --期初跨行转账笔数
    ,)                --期初跨行转账金额
    declare @ontrnm int                            --新增跨行转账笔数
    ,)                --新增跨行转账金额
    declare @oetrnm int                            --期末跨行转账笔数
    ,)                --期末跨行转账金额

    declare @aitrnm int                            --期初总计转账笔数
    ,)                --期初总计转账金额
    declare @antrnm int                            --新增总计转账笔数
    ,)                --新增总计转账金额
    declare @aetrnm int                            --期末总计转账笔数
    ,)                --期末总计转账金额

    )                --当月第一天
    )                --当月最后一天
    )                --上月最后一天    

    ),()),)
    ,,),()))),)
    --上月最后一天
    ,),())),)

    --取网点号
    ' order by brchno for read only
    open cur_rprt
    fetch cur_rprt into @brchno,@brchna

    begin    

         ')
        begin

            select @iitram = 0.00

            select @intram = 0.00

            select @ietram = 0.00

            select @oitram = 0.00

            select @ontram = 0.00

            select @oetram = 0.00

            select @aitram = 0.00

            select @antram = 0.00

            select @aetram = 0.00
        end
        else begin
            --
            '
            '
            '
        end
            '
            '
            '
            '
        if @iitram is null
        begin
            select @iitram = 0.00
        end

        if @intram is null
        begin
            select @intram = 0.00
        end

        if @ietram is null
        begin
            select @ietram = 0.00
        end            

        if @oitram is null
        begin
            select @oitram = 0.00
        end

        if @ontram is null
        begin
            select @ontram = 0.00
        end

        if @oetram is null
        begin
            select @oetram = 0.00
        end

        if @aitram is null
        begin
            select @aitram = 0.00
        end

        if @antram is null
        begin
            select @antram = 0.00
        end

        if @aetram is null
        begin
            select @aetram = 0.00
        end

        select @antrnm = @intrnm + @ontrnm  --当月新增转账笔数合计
        select @antram = @intram + @ontram  --当月新增转账金额合计 

        select @ietrnm = @iitrnm + @intrnm  --本期行内转账笔数
        select @oetrnm = @oitrnm + @ontrnm    --本期跨行转账笔数
        select @aetrnm = @aitrnm + @antrnm    --本期合计转账笔数    

        select @ietram = @iitram + @intram   --本期行内转账金额
        select @oetram = @oitram + @ontram     --本期行内转账金额
        select @aetram = @aitram + @antram     --本期行内转账金额

        ')
        fetch cur_rprt into @brchno,@brchna
    end
    close cur_rprt
    deallocate cursor cur_rprt

end
go

-----------------------------------------------------------------------------------------------------------------

    报表.sql---我写的

---------------网银新统计报表总表
create table dbo.emc_cprt (
mainid     int              identity not null ,
rprtdt     smalldatetime         null ,
status     )               null ,
rptype     )               null ,
rprtcs     )               null ,--2:个人网银交易统计
constraint pk_emc_cprt primary key nonclustered (mainid)
)

-----------------个人网银交易统计
create table dbo.emp_trpt (
mainid     int              identity not null ,
rprtdt     smalldatetime         null ,
iitrnm int NULL ,                            --期初行内转账笔数
iitram ,) null,        --期初行内转账金额
intrnm int NULL ,                            --新增行内转账笔数
intram ,) null,        --新增行内转账金额
ietrnm int NULL ,                            --期末行内转账笔数
ietram ,) null,        --期末行内转账金额
oitrnm int NULL ,                            --期初跨行转账笔数
oitram ,) null,        --期初跨行转账金额
ontrnm int NULL ,                            --新增跨行转账笔数
ontram ,) null,        --新增跨行转账金额
oetrnm int NULL ,                            --期末跨行转账笔数
oetram ,) null,        --期末跨行转账金额
aitrnm int NULL ,                            --期初总计转账笔数
aitram ,) null,        --期初总计转账金额
antrnm int NULL ,                            --新增总计转账笔数
antram ,) null,        --新增总计转账金额
aetrnm int NULL ,                            --期末总计转账笔数
aetram ,) null,        --期末总计转账金额
rptpfg     )               null ,    -- 0:日报表 1:月报表 2:季报表 3:年报表
constraint pk_emp_trpt primary key nonclustered (mainid)
)

-----------------个人交易流水表
create table dbo.epc_flog (
mainid     int              identity not null ,
senddt     smalldatetime         null ,        --交易时间
brchno     )           null ,        --机构号
custid     )           null ,        --客户号
trancd     )           null ,        --交易码   (其实是一种类型,,暂时用1表示行内,2表示跨行)
tranam     ,)          null ,    --交易金额
tranfe         ,)          null,        --交易手续费
constraint pk_epc_flog primary key nonclustered (mainid)
)

--功能:
--1、可按日、月维度统计转账交易的统计
--2、eb_rp_pertrancereportday查询epc_flog表,统计出当天的交易量,并写入到emp_trpt表
--3、eb_rp_pertrancereportmonth从emp_trpt表查询该月每天的交易量并进行统计,统计结果也写入到emp_trpt表
--4、统计的图表可使用饼状图、柱状图或曲线图
--5、批处理类报表:
----a.用曲线图展示每天交易量(金额)同时显示其交易笔数,查询条件:日期范围、指定转账类型
----b.用饼状图展示指定月行内转账和跨行转账的笔数和金额,查询条件:指定月份
----c.用柱状图展示最近6个月中每月的交易笔数和交易金额
--6、实时类报表:
----用柱状图展示当天的交易量(笔数和交易金额)

------------------------------------------------------------------------------------------------------------------
-----------------个人交易流水表
create table epc_flog (
mainid     int              identity not null ,
senddt     smalldatetime         null ,        --交易时间
brchno     )           null ,        --机构号
custid     )           null ,        --客户号
trancd     )           null ,        --交易码   (其实是一种类型,,暂时用1表示行内,2表示跨行)
tranam     ,)          null ,    --交易金额
tranfe         ,)          null,        --交易手续费
constraint pk_epc_flog primary key nonclustered (mainid)
)

-----------------个人网银交易统计
create table dbo.emp_trpt (
mainid     int              identity not null ,

rprtdt     smalldatetime         null ,

intrnm int NULL ,            --新增行内转账笔数
intram ,) null,        --新增行内转账金额

ontrnm int NULL ,            --新增跨行转账笔数
ontram ,) null,        --新增跨行转账金额

rptpfg     )               null ,    -- 0:日报表 1:月报表 2:季报表 3:年报表
constraint pk_emp_trpt primary key nonclustered (mainid)
)

---创建存储过程.
create or replace procedure  p_pertrancereportday(pdate in date)
    as

        Cursor my_cursor
        is
        ) pcount,sum(TRANAM) pamount
        from EPC_FLOG
            ' hour) and pdate
            group by TRANCD ;

        c_row my_cursor%rowtype ;

    begin

        for c_row in my_cursor loop

            ' then

           insert into EMP_TRPT(RPRTDT,INTRNM,INTRAM,ONTRNM,ONTRAM,RPTPFG)
           ,');
        else
           insert into  EMP_TRPT(RPRTDT,INTRNM,INTRAM,ONTRNM,ONTRAM,RPTPFG)
           ,');
        end if;

        end loop;
    end;

----存储过程的调用
declare
pdate date:= to_date('2013-07-08 17:00:00','yyyy-MM-dd hh24:mi:ss') ;
begin

p_pertrancereportday(pdate);
end;
/

----创建存储过程 (月统计,不可用)

create or replace procedure p_pertrancereportmonth(pdate in date)
    as
        --定义变量
        pintrnm EMP_TRPT.INTRNM%TYPE;
        pintram EMP_TRPT.INTRAM%TYPE;
        pontrnm EMP_TRPT.ONTRNM%TYPE;
        pontram EMP_TRPT.ONTRAM%TYPE;
    begin

        select  sum(INTRNM) into pintrnm, sum(INTRAM) into pintram, sum(ONTRNM) into pontrnm, sum(ONTRAM) into pontram ,--这里的聚合函数只能有一个
        from EMP_TRPT
            ' and  RPRTDT between trunc(pdate,'MON') and pdate ; --用到了oracle的时间函数

        if SQL%FOUND then
             insert into EMP_TRPT(RPRTDT,INTRNM,INTRAM,ONTRNM,ONTRAM,RPTPFG)
             ');
        end if;
        commit;
    end;

-----调用与前一个一样

--创建序列
      drop sequence emp_trpt_tb_seq;
      create sequence emp_trpt_tb_seq
               increment
               start ;
--创建序列
 create or replace trigger emp_trpt_tb_tri
          before insert on emp_trpt
          for each row
          begin
                 select emp_trpt_tb_seq.nextval into :new.MAINID from dual;
          end;

----创建存储过程(月统计,可用)

create or replace procedure p_pertrancereportmonth(pdate in date)
    as
        Cursor my_cursor
        is
        select  sum(INTRNM) pintrnm, sum(INTRAM) pintram, sum(ONTRNM) pontrnm, sum(ONTRAM) pontram
        from EMP_TRPT
            ' and  RPRTDT between trunc(pdate,'MON') and pdate ; --用到了oracle的时间函数

        c_row my_cursor%rowtype ;
    begin

        for c_row in my_cursor loop

          insert into EMP_TRPT(RPRTDT,INTRNM,INTRAM,ONTRNM,ONTRAM,RPTPFG)
             ');

        end loop;

    end;

temp-存储过程 以前的的更多相关文章

  1. mysql存储过程--学习

    -- 存储过程示例一   inDROP DATABASE IF EXISTS tdemo;CREATE DATABASE tdemo CHARACTER SET=utf8; USE tdemo;CRE ...

  2. SQL 存储过程(转帖摘录)

    篇一: 创建存储过程     Create Proc dbo.存储过程名 存储过程参数     AS     执行语句     RETURN     执行存储过程     GO *********** ...

  3. sql server存儲過程語法

    -- 变量的声明,sql里面声明变量时必须在变量前加@符号    DECLARE @I INT -- 变量的赋值,变量赋值时变量前必须加set    SET @I = 30 -- 声明多个变量    ...

  4. 【SQL】SQL存储过程相关当前理解。(@temp=……)

    1.下图左侧红框中的是SQL的存储过程,是程序同SQL之间互相调用的函数.——这里先作为了解不做深入研究. 比如客户通过ATM提款机取200元钱,程序中提交取200元钱操作,后续可能会进入SQL进行一 ...

  5. Dapper逆天入门~强类型,动态类型,多映射,多返回值,增删改查+存储过程+事物案例演示

    Dapper的牛逼就不扯蛋了,答应群友做个入门Demo的,现有园友需要,那么公开分享一下: 完整Demo:http://pan.baidu.com/s/1i3TcEzj 注 意 事 项:http:// ...

  6. Mysql - 存储过程/自定义函数

    在数据库操作中, 尤其是碰到一些复杂一些的系统, 不可避免的, 会用到函数/自定义函数, 或者存储过程. 实际项目中, 自定义函数和存储过程是越少越好, 因为这个东西多了, 也是一个非常难以维护的地方 ...

  7. SQL Server 在多个数据库中创建同一个存储过程(Create Same Stored Procedure in All Databases)

    一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 遇到的问题(Problems) 实现代码(SQL Codes) 方法一:拼接SQL: 方法二: ...

  8. 存储过程 Row_number() 分页

    ---恢复内容开始--- 自己之前一直是使用的通用的存储过程 ,也是封装好的只要传表名 + 条件 等等 来到新环境 让自己写一个存储过程, 没办法 自己就需要写一个咯 之前写的比较多的是 按 top ...

  9. SQL存储过程基础(从基础开始学,加油!)

    Transact-SQL中的存储过程,非常类似于Java语言中的方法,它可以重复调用.当存储过程执行一次后,可以将语句缓存中,这样下次执行的时候直接使用缓存中的语句.这样就可以提高存储过程的性能. Ø ...

  10. sqL编程篇(三) 游标与存储过程

    sql编程2 游标与存储过程 sql编程中的游标的使用:提供的一种对查询的结果集进行逐行处理的一种方式不用游标的处理解决方式:逐行修改工资update salar set 工资=‘新工资’ where ...

随机推荐

  1. Swift语言中与C/C++和Java不同的语法(二)

    这一部分,主要讲Swift中创新的可选型(optionals) 一.概要 可选型是Swift创新的一种新的类型,首先看一下可选型的应用场景: var errorCode : Int = 404 这时候 ...

  2. github+hexo搭建自己的博客网站(一)基础入门

    github提供的page,hexo提供的静态博客文档,这样可以搭建一个自己的一个博客网站. 使用github pages服务搭建博客的好处有: 全是静态文件,访问速度快: 免费方便,不用花一分钱就可 ...

  3. node里面的c/c++模块

    准备工作 node使用c++插件时需要使用node-gyp包,node-gyp把c++源码编译为二进制文件,js在调用二进制文件,编译后的二进制文件模块调用就和js的模块调用一样. npm insta ...

  4. 【Ubuntu 16】 SSH免密码登录

    免密码登录时两个机器的普通用户名都要相同,这里都是dream361 ,主机名可以不同,这里的主机名都是ubuntu 1.目前有两台机器master 和 slave 在这两台机器上都安装并启动ssh服务 ...

  5. jQuery DOM对象区别与联系

    对两种对象类型的定义,只要能理解并转换成自己的说法就可以,不用死板按照资料所写 jQuery对象(jq对象)其实就是通过jquery类库选择器获得的对象(或者说是通过$获取的对象或者说是通过jquer ...

  6. QQ无法通过ISA2006&TMG2010代理收发图片问题解决

    近期公司有业务需求通过TMG访问QQ,但配置多次均无法通过QQ收发图片,文字输入正常. 目前已解决,供参考: 这个问题是SSL端口默认使用了443,但QQ的离线文件不使用这个端口.所以ISA会把QQ的 ...

  7. java面向对象(三)之抽象类,接口,向上转型

    java类 java类分为普通类和抽象类,接口,上一节我大概讲了java类的一般格式,今天将抽象类和接口.同时讲一下它们是怎样存储的. 最重要的是理解为什么要有抽象和接口,这样学下来你猜不会迷茫,才能 ...

  8. .Netcore之日志组件Log4net、Nlog性能比较

    转载请注明出处http://www.cnblogs.com/supernebula/p/7506993.html .Netcore之Log4net.Nlog性能比较 最近在写一个开源.netcore ...

  9. Maven setting.xml 文件剖析

    全局配置: ${M2_HOME}/conf/settings.xml (配置环境变量  新建 M2_HOME    安装目录到版本名那里(D:\apache-maven-3.0.2) 编辑path 环 ...

  10. 向eclipse的JavaWeb项目中导入jar包--备忘录

    一:      在你所需的jar包网站下载对应的jar包.如org.apache.commons.lang.jar. 二:复制粘贴到该JavaWeb的WEB-INF目录下的lib目录下,如: 三:右键 ...