sqlserver的存储过程转化成oracle的存储过程

dropprocup_tongji_generateElct_1gocreateprocup_tongji_generateElct_1@beginDatedatetim... drop proc up_tongji_generateElct_1
go
create proc up_tongji_generateElct_1
@beginDate datetime=null,
@endDate datetime=null
as
if @beginDate is null and @endDate is null
begin
--统计上月发电考核明细
set @endDate=CONVERT(varchar(8),getdate(),120)+'01'
set @beginDate=CONVERT(varchar(8),dateadd(month,-1,getdate()),120)+'01'
end
print @beginDate
print @endDate
select * into #tmp_发电汇总 from troubleGenElctRecord
where generateElctBegin between @beginDate and @endDate
alter table #tmp_发电汇总 add bsno900_1 varchar(20) null
alter table #tmp_发电汇总 add bsno900_2 varchar(20) null
alter table #tmp_发电汇总 add bsno1800_1 varchar(20) null
alter table #tmp_发电汇总 add bsno1800_2 varchar(20) null
alter table #tmp_发电汇总 add bsno3G varchar(20) null
alter table #tmp_发电汇总 add 是否超时 varchar(20) null
alter table #tmp_发电汇总 add roomId varchar(20) null
--select * from #tmp_发电汇总 where roomId is null
update #tmp_发电汇总 set bsno3G=(select top 1 bsNo from room_basestation where room_basestation.roomId=#tmp_发电汇总.roomId and bsNo like 'CDW%')
where roomId is not null and bsno3G is null
and exists(select 1 from room_basestation where room_basestation.roomId=#tmp_发电汇总.roomId and bsNo like 'CDW%')
on #tmp_发电汇总.BsRoomNo=room_basestation.bsNo
展开
 我来答
weiwancai
2014-02-27 · TA获得超过129个赞
知道答主
回答量:96
采纳率:0%
帮助的人:64.6万
展开全部
CREATE OR REPLACE PROCEDURE UP_TONGJI_GENERATEELCT_1(BEGINDATE IN VARCHAR,
ENDDATE IN VARCHAR) IS
BEGIN
IF BEGINDATE IS NULL AND ENDDATE IS NULL THEN
--开始日期2014-01-01
select to_char(add_months(trunc(sysdate),-1),'YYYY-MM')||'-01' INTO BEGINDATE from dual;
--结束日期2014-02-01
select to_char(add_months(trunc(sysdate),0),'YYYY-MM')||'-01' INTO ENDDATE from dual;
END IF;
INSERT INTO TMP_发电汇总 SELECT * FROM TROUBLEGENELCTRECORD WHERE GENERATEELCTBEGIN >=BEGINDATE AND GENERATEELCTBEGIN<= ENDDATE;
commit;
--select * from #tmp_发电汇总 where roomId is null
UPDATE TMP_发电汇总 A
SET BSNO3G =
(SELECT TOP 1 BSNO
FROM ROOM_BASESTATION
WHERE ROOM_BASESTATION.ROOMID = A.ROOMID
AND BSNO LIKE 'CDW%')
WHERE ROOMID IS NOT NULL
AND BSNO3G IS NULL
AND EXISTS (SELECT 1
FROM ROOM_BASESTATION
WHERE ROOM_BASESTATION.ROOMID = A.ROOMID
AND BSNO LIKE 'CDW%') ON
A.BSROOMNO = ROOM_BASESTATION.BSNO;
COMMIT;
END UP_TONGJI_GENERATEELCT_1;
有疑问再说说!~
追问
你这种方法的话,TMP_发电汇总这张表是一开始就建好的临时表还是正式表呢?
追答
不知道你原来的要求,可以直接更新正式表中去啊,不需要临时表。
micro0369
2014-02-26 · TA获得超过1.2万个赞
知道大有可为答主
回答量:9250
采纳率:85%
帮助的人:4026万
展开全部
这个没有什么好的办法,

只能自己改写。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式