先提炼,然后再问!
来源:互联网 发布:阿里云服务器80端口 编辑:程序博客网 时间:2024/05/16 18:17
说实话我没弄明白楼主的意思,但后来再看这个问题时,有一个人做了解答,这个回答的人应该是弄懂了楼主的意思,我也不好说什么,就说给自己听听吧: 先提炼,然后再问!
楼主贴出来的是动态的sql,只有where 语句没有select语句不知道怎么 回事,楼主的问题如下:
以下存储过程返回查询结果集,统计结果. 现在的问题是:消费统计/调帐(借记)统计/调帐(贷记)统计/退货统计/充值统计,5项结果不正确,要求从"结果集"中进行统计,现在不是,我该如果做
create or replace package pak_trans as
type trans_cursor is ref cursor;
end pak_trans;
/
CREATE OR REPLACE PROCEDURE "CARD"."TRANS"
(
mcht in varchar, --商户号
sett in varchar, --清算号
startcardno in varchar, --起始卡号
endcardno in varchar, --结束卡号
tx_code in varchar, --交易代码
banlace in varchar, --交易金额
startdate in varchar, --开始日期
enddate in varchar, --结束日期
traceno in varchar, --流水号
batchno in varchar, --批次号
termid in varchar, --终端号
document in varchar, --证件类型
cardhold in varchar, --证件号码
lxname in varchar, --联系人
telphone in varchar, --电话
gkdate in varchar, --购卡时间
pagesize in number, --页尺寸
currpage in number, --当前页
recordcount out number, --记录数
sell out number, --消费笔数
rating_sum out number, --消费金额
rating out number, --充值笔数
init_sum out number, --充值金额
initsell out number, --退货笔数
RSA_sum out number, --退货金额
init out number, --调帐(借记)笔数
TSO_sum out number, --调帐(借记)金额
makeall out number, --调帐(贷记)笔数
TSI_sum out number, --调帐(贷记)金额
poundage out number, --卡激活总量
hstint out number, --卡冻结总量
intbal out number, --卡解冻总量
p_cursor out pak_trans.trans_cursor --返回结果集
)
as
v_startRowNum NUMBER; --分页起始记录编号
v_endRowNum NUMBER; --分页结束记录编号
strsql varchar2(4000); --查询语句
strsql1 varchar2(4000); --查询语句1
str varchar2(4000);
sqlwhere varchar2(4000); --where条件1
sqlwhere1 varchar2(4000); --where条件2
sqlwhere2 varchar2(4000); --where条件3
sqlwhere3 varchar2(4000); --where条件4
sqlwhere4 varchar2(4000); --where条件5
sqlwhere5 varchar2(4000); --where条件6
sqlwhere6 varchar2(100); --where条件7
perstr varchar2(4000); --充值SQL
rej_code varchar2(10); --卡状态变更
txcode varchar(5); --卡状态变更状态码
standby2 varchar2(40); --卡段
tmp_min varchar2(7); --卡段最小值
tmp_max varchar2(7); --卡段最大值
begin
--查询条件
sqlwhere:=' where merch_id='
||mcht
||' and sett_postdate>='''
||startdate
||''' and sett_postdate<='''
||enddate
||''' and exists(select * from merchant where merch_id='
||mcht
--||' and exists(select * from grppou where substr(MERGRP,1,8)='
--||substr(merchant.grp_name,1,8)
--||' and grp_leader='
--||mcht
||')';
if length(startcardno)>0 and length(endcardno)>0 then
sqlwhere:=sqlwhere
||' and cardno>='''
||startcardno
||''' and cardno<='''
||endcardno
||'''';
--||' or (substr(addidata1,1,18)<='
--||startcardno
--||' and substr(addidata1,20,18)>='
--||startcardno
--||' and substr(addidata1,1,18)<='
--||endcardno
--||' and substr(addidata1,20,18)>='
--||endcardno
--||')';
end if;
if to_number(banlace)!=0 then
sqlwhere:=sqlwhere
||' and req_txnamt='
||to_number(banlace)*0.01;
end if;
if length(traceno)>0 then
sqlwhere:=sqlwhere
||' and trace_no='
||traceno;
end if;
if length(batchno)>0 then
sqlwhere:=sqlwhere
||' and batchid='
||batchno;
end if;
if length(termid)>0 then
sqlwhere:=sqlwhere
||' and term_id='
||termid;
end if;
if length(cardhold)>0 then
sqlwhere:=sqlwhere
||' and addidata1 like '''
||'%'
||cardhold
||'%''';
end if;
if length(lxname)>0 then
sqlwhere:=sqlwhere
||' and addidata1 like '''
||'%'
||lxname
||'%''';
end if;
if length(telphone)>0 then
sqlwhere:=sqlwhere
||' and addidata1 like '''
||'%'
||telphone
||'%''';
end if;
if length(gkdate)>0 then
sqlwhere:=sqlwhere
||' and addidata1 like '''
||'%'
||gkdate
||'%''';
end if;
--where 条件2
sqlwhere1:=' and (compl_flag<>04 and compl_flag<>02 or compl_flag is null) and rsp_code=00 and tx_code=''PER''';
sqlwhere2:=' and (compl_flag<>04 and compl_flag<>02 or compl_flag is null) and rsp_code=00 and tx_code=''TSO''';
sqlwhere3:=' and (compl_flag<>04 and compl_flag<>02 or compl_flag is null) and rsp_code=00 and tx_code=''TSI''';
sqlwhere4:=' and (compl_flag<>04 and compl_flag<>02 or compl_flag is null) and rsp_code=00 and (tx_code=''RSA'' or tx_code=''REF'')';
sqlwhere5:=' and (compl_flag<>04 and compl_flag<>02 or compl_flag is null) and rsp_code=00 and (tx_code=''HNT'' or tx_code=''PNT'')';
--sqlwhere6:=' and (tx_code=''CST'' or tx_code=''HSN'' or tx_code=''PSN'')';
if length(tx_code)>0 then
sqlwhere6:=' and tx_code='''
||tx_code
||'''';
end if;
- 先提炼,然后再问!
- 先定义元素,然后再使用
- 先获取经纬度 然后再输出
- 先思考,再发问
- 编程语言与函数库都是先历史,后 数据类型,然后函数,再然后是复杂函数
- ERP项目实施讨论:先僵化,再优化,然后做固化
- 子曾经曰过,先把历史遗留问题解决,然后再展鸿鹄
- 问题的提出方式。(【先】说出最关键的【结果】,然后再描述细节)
- ASP.NET先显示‘提示信息’然后再跳转---Page.ClientScript.RegisterStartupScript()
- 按钮一次次点击然后线程都先停止再重新创建
- rebuild 工程 莫名其妙的问题 一定要先rebuild工程 然后再解决问题,
- 必须先将 ContentLength 字节写入请求流,然后再调用 [Begin]GetResponse。解决方法
- 【Visual Studio】解决方案未保存,请先保存你的解决方案,然后再管理Nuget包
- 先装.NET然后安装IIS
- 今天初步实现先Request然后Connect
- 先有校长,然后才有大学
- 先弹出对话框,然后跳转页面
- 先成为锦,然后才能添花
- 转载宏的使用技巧
- linux之sort用法(转载)
- 环形缓冲区的设计与实现
- eclipse进入很慢
- Web Services中RPC/Encoded 、RPC/Literal 等样式的区别
- 先提炼,然后再问!
- ArcGIS Diagrammer建模拓扑提示“The topology rule is invalid/malformed.”
- 转 Android开辟呈现 invalid command-line parameter: Files. 解决办法
- C++类对象创建过程(分配空间、赋值和初始化、对象初始化顺序、虚函数表指针)
- SVN代码回滚命令之---merge的使用
- WriteFile写中文字符串 TxT显示乱码
- Spring 的核心机制:依赖注入(控制反转)
- json-lib异常整理
- 2012年4月RHCE6.0考试心得