这个存储过程是什么意思,怎么使用呀

xiongying18 xiongying18 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
怎么使用SQL语句代替这个存储过程呀



/****** Object: Stored Procedure dbo.sp_ppc_techPlan1 Script Date: 2007-11-2 20:47:57 ******/


-- sp_ppc_techPlan1 '57',''

CREATE PROCEDURE sp_ppc_techPlan1
@paratechno char(2), --工艺编号
@lcErrMsg varchar(500) output
AS
declare @isfinP int
declare @isfinU int
declare @plancleardate datetime
select @isfinP=0
select @isfinU=0


select pdctno,units,planqty,procwip,case when tmpout>planqty then planqty else tmpout end as outqty,scrapunit,substring(convert(char(20),intotime,20),6,11) as intotime,kind,
case when pdctdate is null
then ''
else convert(char(10),pdctdate,111)
end as pdctdate,
chgstocktime as deldate,
lackqty=case when planqty-outqty>0
then planqty-outqty
else 0 end,
batchno,
case when deldate is null
then ''
else convert(char(10),deldate,111)
end as senddate,
byfield1,
finishplan,kind1,
case when kind1='结存' then 'Z' else 'A' end +pdctno+left(batchno,10)+convert(char(2),len(batchno))+substring(batchno,11,len(batchno)) as kind3,
case when kind1='结存' then 'Z' else 'A' end +convert(char(20),pdctdate,111) as kind4,
convert(char(1),isyl)+case when kind1='结存' then 'Z' else 'A' end +case when kind='辅计' then 'A' else case when kind='主计' then 'B' else case when kind='调计' then 'C' else 'Z' end end end
+(ISNULL(convert(char(10),pdctdate,111),' ')+convert(char(20),wiptime,20)+convert(char(2),len(batchno))+rtrim(batchno)) as kind5,
case when kind1='结存' then 'Z' else 'A' end +convert(char(20),intotime) as kind2,intotime as shijian,
case when kind1='结存' then 'Z' else 'A' end +convert(char(20),chgstocktime,111) as kind6,isworking,ispause,tasktime,plantime,
@isfinP as isfinP,@isfinU as isfinU,intoqty,wipstate,byfield5,byfield6,outqty as cpck,byfield8,eqptname as techclass,isyl
into #tmpscjhb1
from proscjhb
where techno=@paratechno
and (procwip<>0 or scrapunit<>0 or planqty<>0 or outqty<>0 or endtime<>'')
and pdctno in (select pdctno from mktxhglb where ppeonly='0')
and (procwip<>0 or scrapunit<>0 or outqty<>0)
order by pdctno

----select * from proscjhb where kind1='结存' and wipstate=1 order by intoqty

select a.odrbno,a.taskno,DATEADD(hour,a.workhour+a.waithour+a.prehour,getdate()) as cacudate,
ceiling(((a.workhour+a.waithour+a.prehour)-datediff(hour,getdate(),b.deldate))/24) as tqdays
into #tqdays
from ppcautoplan a left join mktjhxxb b ON(a.odrbno=b.odrbno and b.state='有效' and b.odrbno<>'')
where a.taskno in (select batchno from #tmpscjhb1)


---select distinct taskno,bcutqty into #tmptlblb from ppctlblb1 where taskno in (select batchno from #tmpscjhb1) and taskno<>''


select IDENTITY(int, 1,1) AS ID_Num,a.pdctno,convert(char(10),case when a.units='U' then f.unitqty*isnull(e.bcutqty,0) else isnull(e.bcutqty,0) end ) as bcutqty,
a.units+' '+convert(char(10),(a.planqty+case when a.units='U' then (isnull(a.byfield8,0)) else convert(decimal(6,0),(isnull(a.byfield8,0))*1.000/f.unitqty) end)) as planqty,
case when a.kind1<>'结存' then case when a.wipstate=1 then '*' else case when a.isworking=0 then ' ' else case when a.ispause=1 then '\' else '/' end end end else '' end
+case when a.kind1='结存' then case when a.intoqty=0 then ' ' else case when a.intoqty=1 then case when a.wipstate=1 then '*' else 'H' end else case when a.wipstate=1 then '*' else 'F' end end end else '' end
+ltrim(rtrim(convert(char(20),a.procwip))) as procworking,
isnull(rtrim(convert(char(6),case when a.isworking=1 then datediff(minute,a.shijian,getdate()) else a.tasktime end)),'') as tasktime,
(case when @paratechno='24' then a.outqty-a.cpck else a.outqty end) as outqty,a.scrapunit,a.intotime,a.kind,isnull(convert(char(4),a.plantime),'0') as plantime,
a.pdctdate,a.deldate,isnull(c.chgcount,0) as chgcount,a.lackqty,a.batchno,a.byfield5,a.senddate,a.byfield1,a.finishplan,a.kind1,
a.kind3,a.kind4,a.kind5,a.kind2,a.kind6,a.procwip,isfinP,isfinU,d.odrkind as odrkind,a.byfield6,a.units,isnull(a.techclass,'') as techclass,
isnull(g.class,0) as class,a.isyl,i.cacudate,i.tqdays
into #tmpOutTbl
from #tmpscjhb1 a
left join (select taskno,count(taskno) as chgcount from ppcjhtzb1 group by taskno) c on (a.batchno=c.taskno)
left join (select taskno,max(kind) as odrkind from mktjhxxb1 group by taskno) d on(left(a.batchno,10)=left(d.taskno,10))
left join ppctlstate e on (a.batchno=e.taskno)
left join mktxhglb f on(a.pdctno=f.pdctno)
left join proscgdb g on(a.batchno=g.batchno)
left join #tqdays i on(a.batchno=i.taskno and i.taskno<>'')
order by a.kind5


if @paratechno='54'
update #tmpOutTbl set planqty=left(planqty,1) where batchno not like '%)%'

select * from #tmpOutTbl





GO
...全文

相关推荐

oracle存储过程超详细使用手册

oracle存储过程超详细使用手册,内容很详细,绝对受用

cplover25

SQL中存储过程的创建和使用

如何创建存储过程 user testdatabase(数据库名称) go create procedure testname(存储过程名称) @test1 int, @test2 nvarchar(50) as insert into testtable values(@test1,@test2) return //select * from users where truename like '%[王刘]%' //只能分词查询,查询姓刘和姓王的信息 2 如何使用 public string[] TestLogin(string uname, string upwd) {

weixin_38689824

实验9 存储过程的创建和使用

实验内容和步骤: 阅读实验教材《SQL Server 2012数据库管理与开发》第137页到155页的内容,掌握存储过程的概念、了解存储过程的类别(系统存储过程,用户自定义存储过程,扩展存储过程);掌握存储过程的建立;掌握存储过程的两种执行方式;掌握查看、修改、重命名存储过程的方法;掌握删除存储过程的方法。 存储过程是一系列预先编辑好的、能实现特定数据操作功能的SQL代码集,它与特定的数据库相关联,存储在SQL Server服务器上。用户可以像使用自定义函数那样重复调用这些存储过程,实现它所定义的操作。本实验所需数据库为前面实验已经建立好的学生选课管理数据库。 1.编写带输入参数的存储过程proc_St:在查询分析器中创建一个存储过程,要求输入学号和姓名-----即要求以学号(@SSno)和姓名(@SSname)为存储过程的输入参数(存储过程的参数名必须以@开头,每个参数都应当有数据类型),如果学生选课数据库中存在所指定的学号和姓名的学生,则返回这个学生的信息及选课信息;否则给出“没有该学生”的提示信息。

江枫渔火@

PLSQL中存储过程的建立,导出,导入,使用

PLSQL中存储过程的建立,导出,导入,加入图示详细描述

liyu1059915776

Oracle存储过程中使用临时表

Oracle存储过程中使用临时表 会话级临时表 事务级临时表

wcz2008nihao
评论 1
收藏 已收藏
分享
返回顶部
xiongying18
VB 16,718 成员 110,520 内容