才开始学习存储过程。如下sql如何改成存储过程并返回最后的结果集

hb79924 2012-10-11 03:20:38
{set isolation to dirty read;
select b.claimno,caseno,notifydate,deptgroup,insurantname,telephone,mobile,manageunit,
(case when b.lawstatus <> '0' then '诉讼案件' when b.replevystatus <> '0' then '追偿案件' when b.repaystatus <> '0' then '补赔案件' else
(case when b.endno is not null and b.endno <> '' then '已归档' else
(case when b.endstatus = '2' then '注销完成' when b.endstatus = '3' then '拒赔完成' when b.endstatus = '5' then '作废案件' when b.endstatus = '4' then '已结案' else
(case when b.ifrefuse = '1' then '拒赔处理中' when b.ifrefuse = '2' then '注销处理中' else
(case when c.notify <> '2' then '报案抄单中' else
(case when c.dispatchSurvey in ('0','1','3') then '查勘调度中' else
(case when c.estimate in ('0','1','3') then '查勘估损中' else
(case when c.surveyreport in ('0','1','3') then '查勘估损中' else
(case when c.auditPrice in ('0','1','3') then '本地核价中' else
(case when c.lhauditprice in ('0','1') then '总公司核价中' else
(case when c.voucher = '1' then '单证收集中' else
(case when c.pay in ('0','1','3') then '理算缮制中' else
(case when c.checkPay in ('0','1','3') then '理算复核中' else
(case when c.auditing in ('0','1','3') then '本地核赔中' else
(case when c.lhauditing in ('0','1') then '总公司核赔中' else '未知状态'
end) end) end) end) end) end) end) end) end) end) end) end) end) end) end) as claim_status
from c_claim b,c_processstatus c
where b.claimno=c.claimno
and endstatus='0'
into temp a with no log;
select unique a.*,losstype
from a a,outer c_lossitem b
where a.caseno=b.caseno
and losstype='2'
into temp b with no log;
select a.*,max(dispatchtime) dispatchtime
from b a,outer c_surveytask b
where a.caseno=b.caseno
and tasktype='2'
group by 1,2,3,4,5,6,7,8,9,10
into temp c with no log;
select a.*,surveydeptgroup,surveydept,surveyor1code
from c a,outer c_surveytask b
where a.caseno=b.caseno
and taskserialno='1'
into temp d with no log;
select a.*,max(endtime) endtime
from d a,outer c_surveytask b
where a.caseno=b.caseno
and a.dispatchtime=b.dispatchtime
and tasktype='2'
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14
into temp e with no log;
select a.*,sum(gsje) gsje
from e a,outer datacenter@onlinegztb1:estiloss b
where claimno=b.caseno
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
into temp f with no log;}
select claimno,caseno,notifydate,deptgroup,insurantname,telephone,mobile,manageunit,claim_status,losstype,dispatchtime,surveydeptgroup,surveydept,staff_name,endtime,sum(gsje) gsje
from f a,outer ids6@pguz:rydm_t b
where surveyor1code=staff_code
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
into temp g with no log;
select a.*,jbr
from g a,outer datacenter@onlinegztb1:regcase b
where claimno=b.caseno
into temp h with no log;
select a.*,b.staff_name staff_name1
from h a,outer ids6@pguz:rydm_t b
where jbr=staff_code
into temp i with no log;
select a.*,allbilltime
from i a,outer c_property b
where a.claimno=b.claimno
and ifallbill='1'
into temp j with no log;
select a.*,max(finishtime) finishtime
from j a,outer c_taskaudit b
where a.claimno=b.claimno
and status='4'
and resultcode='1'
and audittype='7'
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
into temp k with no log;
select a.*,max(b.finishtime) finishtime1
from k a,outer c_taskaudit b
where a.claimno=b.claimno
and status='4'
and resultcode='1'
and audittype='3'
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
into temp l with no log;
select a.*,max(b.finishtime) finishtime2
from l a,outer c_taskaudit b
where a.caseno=b.claimno
and status='4'
and resultcode in ('1','B')
and audittype='1'
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21
into temp m with no log;
unload to wjmx.txt
select * from m
...全文
8645 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
阿呆哥 2012-10-22
  • 打赏
  • 举报
回复
写个shell script,在此过程中调用。
hb79924 2012-10-11
  • 打赏
  • 举报
回复
补充:就是最后的unload .....中的select是返回结果集。
一、 数据概览 塔里木内流区流经空间范围SHP矢量数据是一套以矢量格式精确描绘塔里木内流区(又称塔里木盆地内流区)地理边界的地理信息系统(GIS)基础数据。该数据以业界通用的Shapefile(.shp)格式存储,定义了塔里木内流区这一完整、封闭的自然地理单元的空间范围。它本质上是一个多边形矢量图层,其边界线勾勒出了所有最终流入塔里木盆地内部而不汇入海洋的水系的水区域。 该数据是研究中国西北干旱区水文、生态、气候及资源环境的核心基础数据之一,为相关领域的科学分析、规划决策提供了精确的空间框架。 二、 地理范围与重要性 塔里木内流区是中国最大的内流区,也是世界著名的干旱中心。其空间范围大致涵盖新疆维吾尔自治区南部的塔里木盆地及其周边山脉(天山、昆仑山、阿尔金山、帕米尔高原)的水区域。 核心区域:数据范围主要包括塔里木河干流及其源流——阿克苏河、叶尔羌河、和田河、开都-孔雀河等流域的水区。 地理特征:该区域地形封闭,四周高山环绕,降水主要来自山区,冰川融水是河流的重要补给来源。所有河流均向盆地中心汇,最终消失于沙漠或汇入尾闾湖(如历史上的罗布泊)。 生态与经济重要性:塔里木内流区是南疆地区的生命线。著名的塔里木河是中国最长的内流河,其沿岸形成的天然植被带(“绿色走廊”)是阻挡塔克拉玛干沙漠和库鲁克沙漠合拢的关键生态屏障。同时,该区域也是重要的棉花、林果业和能源基地。 三、 数据内容与属性 SHP格式数据通常由多个文件组成(如 .shp, .shx, .dbf等),其中包含空间几何信息和属性信息。 空间几何:数据以一个或多个多边形(Polygon)要素构成,每个多边形代表塔里木内流区边界内的一块连续区域。其坐标系统通常采用地理坐标系(如WGS84)或投影坐标系(如Albers等积投影),以确保空间量算的准确性。 属性表:属性表(.dbf文件)记录了该
内容概要:本文深入探讨了Redis高级数据结构在分布式系统与实时应用中的核心作用,重点围绕String、Hash、ZSet和HyperLogLog四种数据结构,结合分布式锁与实时排行榜两大典型场景进行实战解析。通过Python + FastAPI + Redis的代码实现,详细展示了如何利用ZSet的原子性操作(如ZINCRBY、ZREVRANK、ZREVRANGE)构建高性能的实时积分排行榜,并分析其时间复杂度、内存占用及扩展功能。同时,文章还介绍了分布式锁的实现原理及其在秒杀场景中防止超卖的应用。; 适合人群:具备一定Redis基础,熟悉基本数据结构,从事后端开发或系统架构工作1-3年的研发人员;正在参与高并发、实时性要求较高的项目开发者;希望深入理解Redis在实际业务中高级应用的技术人员。; 使用场景及目标:①掌握如何使用ZSet实现高效的实时排行榜,支持动态更新与TOP N查询;②理解分布式锁的实现机制及其在库存扣减、防并发冲突中的应用;③学习Redis在去重统计(UV)、对象存储(Hash)等场景的最佳实践;④提升对Redis原子操作、性能优化和生产环境部署的认知。; 阅读建议:建议结合代码动手实践,重点关注ZSet的核心命令与原子性保障机制,在本地搭建Redis环境运行示例程序并模拟高并发测试,同时延伸学习Redis模块化生态(如RedisBloom、RedisTimeSeries)以拓展技术视野。

1,195

社区成员

发帖
与我相关
我的任务
社区描述
其他数据库开发 Informix
社区管理员
  • Informix社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧