存储过程,我实在是很晕。

liuchanghu 2001-12-13 10:12:25
CREATE PROCEDURE ipqajizhong
(
@lineca as char(2)='C%',
@datestart as smalldatetime='2001-08-012',
@dateEnd as smalldatetime='2001-08-22'
)
AS
-------机种
declare @jizhongT char(7)
declare @jizhongT1 char(5)
declare @jizhongT2 char(5)

-------通过批
declare @tongguopi int

-------总批次
declare @zongpici int

--------检验数
declare @jianyanshu int

-------不良数
declare @buliangshu smallint
-------批量允收率
declare @jianpiliang int
declare @tongguoshu int
......................
.....................
以上是部分存储过程

/*********************
Set rs = Server.CreateObject("ADODB.Recordset")
time11="2001-11-12"
time22="2001-12-12"
sql="exec ipqajizhong '"&time11&"','"&time22&"','"&jizhong&"',"&tongguopi&""
为什么总是出错,说没有toonggupi
do while not rs.eof
怎么得到jizhong ,tonggupi 值,
...全文
77 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuchanghu 2001-12-13
  • 打赏
  • 举报
回复
全部源程序
CREATE PROCEDURE ipqajizhong
(
@lineca as char(2)='C%',
@datestart as smalldatetime='2001-08-012',
@dateEnd as smalldatetime='2001-08-22'
)
AS
-------机种
declare @jizhongT char(7)
declare @jizhongT1 char(5)
declare @jizhongT2 char(5)

-------通过批
declare @tongguopi int

-------总批次
declare @zongpici int

--------检验数
declare @jianyanshu int

-------不良数
declare @buliangshu smallint
-------批量允收率
declare @jianpiliang int
declare @tongguoshu int

-------
declare @buliangluT real

declare @yushouluT real
declare @buliangdaima char(40)
declare @buliangshuliang smallint
declare @weizhi smallint
declare @runcmd char(150)
declare @modelFirst char(5)
declare @modelSecond char(5)

-------创建不良临时表
create table #ipqa
(
jizhong char(7) null,
tongguopi int null,
zongpici int null,
jianpiliang int,
tongguoshu int,
jianyanshu int null,

buliangshu smallint null,
yushoulu real null,
bulianglu real null,


top1 char(40) null,
top2 char(40) null,
top3 char(40) null,
top4 char(40) null,
top5 char(40) null,
top6 char(40) null,
top7 char(40) null,
top8 char(40) null,
top9 char(40) null,
top10 char(40) null,
topN1 int null,
topN2 int null,
topN3 int null,
topN4 int null,
topN5 int null,
topN6 int null,
topN7 int null,
topN8 int null,
topN9 int null,
topN10 int null,

)
--select line into #linemodel
--from line_ipqa
declare jizhong scroll cursor for select model,modelbak from tpvmodel order by substring(model,2,1)
open jizhong
fetch first from jizhong into @jizhongT1,@jizhongT2
while @@fetch_status=0
begin

if @jizhongT1=@jizhongT2
select @jizhongT=@jizhongT1
else
select @jizhongT=@jizhongT1+'/'+substring(@jizhongT2,5,1)




select @jianyanshu=sum(tipqaa06), @tongguopi=sum(tipqaa11),@zongpici=sum(tipqaa10+tipqaa11),@jianpiliang=sum(tipqaa05),@tongguoshu=sum(tipqaa05-tipqaa09) from tipqaa_file
where tipqaa03 between @datestart and @dateend and (tipqaa02 like @jizhongT1+'%' or tipqaa02 like @jizhongT2+'%') and tipqaadep='A' and tipqaa04 like @lineca
select @buliangshu=sum(tipqab03) from tipqaa_file,tipqab_file
where tipqaa03 between @datestart and @dateend and (tipqaa02 like @jizhongT1+'%' or tipqaa02 like @jizhongT2+'%') and tipqaadep='A' and tipqaa_id*=tipqab_id and tipqaa04 like @lineca
--print @tongguopi
--print @zongpici
--print @tongguoshu
if @jianpiliang is null
begin
goto lable1
end
if @jianyanshu is null
begin
select @jianyanshu=0
select @tongguopi=0
select @zongpici=0

select @buliangshu=0
select @buliangluT=0
end

if @tongguopi is null
begin
select @tongguopi=0
end
if @zongpici is null
begin
select @zongpici=0
end

if @buliangshu is null
begin
select @buliangshu=0
end
insert into #ipqa (jizhong,tongguopi,zongpici,jianyanshu,buliangshu,jianpiliang,tongguoshu) values(@jizhongT,@tongguopi,@zongpici,@jianyanshu,@buliangshu,@jianpiliang,@tongguoshu)

----------写入不良总数
--print @line
--print @jianyanshu
--print @zhitongshu
--print @buliangshu

declare buliang scroll cursor for select top 10 name,sum(tipqab03) from tipqaa_file,tipqab_file,badcode
where tipqaa_id=tipqab_id and tipqab01=code
and tipqaa03 between @datestart and @dateend and tipqaadep='A' AND (tipqaa02 like @jizhongT1+'%' or tipqaa02 like @jizhongT2+'%') and tipqaa04 like @lineca
group by name
order by sum(tipqab03) desc

open buliang
fetch first from buliang into @buliangdaima,@buliangshuliang

--print @buliangdaima
--print @buliangshuliang

select @weizhi=1
while @@fetch_status=0 and @weizhi<11
begin
select @runcmd="update #ipqa set top"+convert(varchar(2),@weizhi)+"='"+@buliangdaima+"', topN"+convert(varchar(2),@weizhi)+"="+convert(varchar(3),@buliangshuliang)+" where jizhong='"+@jizhongT+"'"
execute master..sp_sqlexec @runcmd
fetch next from buliang into @buliangdaima,@buliangshuliang
select @weizhi=@weizhi+1
end
close buliang
deallocate buliang
----------不良总数结束
----------------------------------------总的jizhong的循环结束
lable1:
fetch next from jizhong into @jizhongT1,@jizhongT2
end
----------------------------------------
close jizhong
deallocate jizhong

--delete from #ipqa where jianyanshu=0

--if @jianyanshu <> 0
--begin]
update #ipqa set bulianglu=0
,yushoulu=0
where jianyanshu=0 --and tipqadep='A'

update #ipqa set bulianglu=convert(real,buliangshu*1000000/convert(real,jianyanshu))
,yushoulu=convert(real,tongguoshu)/convert(real,jianpiliang)
where jianyanshu<>0 --and tipqadep='A'


--end
select * from #ipqa order by jizhong
drop table #ipqa

以上是存储过程,
我想传入两个值,@datestart 和 @dateEnd
得到不良临时表 table #ipqak中所有的值,这样大家懂了吗?我想大家一定有办法,我实在是很……
Set rs = Server.CreateObject("ADODB.Recordset")
time11="2001-11-12"
time22="2001-12-12"
sql="exec ipqajizhong '"&time11&"','"&time22&"','"&jizhong&"',"&tongguopi&"。。。。。。。。"
为什么总是出错,说没有toonggupi
do while not rs.eof
我写了一点,就写不去了。
jadesun 2001-12-13
  • 打赏
  • 举报
回复
@lineca as char(2)='C%',
@datestart as smalldatetime='2001-08-012',
@dateEnd as smalldatetime='2001-08-22'

这儿只有三个

"&time11&"','"&time22&"','"&jizhong&"',"&tongguopi&""

这儿传递了四个

tongguopi 往哪放?

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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