CREATE procedure InfoSearch @wave varchar(2),@time1 varchar(22),@time2 varchar(22) asdeclare @salemainid varchar(13)
declare @goodslist varchar(250)
declare @temp1 varchar(100),@temp2 varchar(100),@temp3 varchar(100),@temp4 varchar(100),
        @temp5 varchar(100),@temp6 varchar(100),@temp7 varchar(100),@temp8 varchar(100),
        @temp9 varchar(100),@temp10 varchar(100),@temp11 varchar(100),@temp12 varchar(100),
        @temp13 varchar(100),@temp14 varchar(100),@temp15 varchar(100),@temp16 varchar(100)create table #tempa(salemainid varchar(13),goodslist varchar(250),temp1 varchar(100),
                    temp2 varchar(100),temp3 varchar(100),temp4 varchar(100),
                    temp5 varchar(100),temp6 varchar(100),temp7 varchar(100),
                    temp8 varchar(100),temp9 varchar(100),temp10 varchar(100),
                    temp11 varchar(100),temp12 varchar(100),temp13 varchar(100),
                    temp14 varchar(100),temp15 varchar(100),temp16 varchar(100))
  set @goodslist=''
  
  declare cursor1 cursor for 
(select * from vsendmain where rtrim(wave)=rtrim(@wave) and sendday between @time1 and @time2 and (right(rtrim(sendstate),1)='0' or right(rtrim(sendstate),1)='3'))
  open cursor1
  fetch next from cursor1 into @salemainid,@temp1,@temp2,@temp3,@temp4,@temp5,@temp6,@temp7,@temp8,@temp9,@temp10,@temp11,@temp12,@temp13,@temp14,@temp15,@temp16
  while @@fetch_status=0
  begin
    select @goodslist=@goodslist+goods+'('+convert(varchar(10),nowcount)+shave2+')(¥'+convert(varchar(20),realprice)+')  ' 
        from vsend where rtrim(salemainid)=rtrim(@salemainid)
    insert into #tempa select salemainid,@goodslist,@temp1,@temp2,@temp3,@temp4,
  @temp5,@temp6,@temp7,@temp8,@temp9,@temp10,@temp11,@temp12,@temp13,@temp14,@temp15,@temp16
    set @goodslist=''
    fetch next from cursor1 into @salemainid,@temp1,@temp2,@temp3,@temp4,@temp5,@temp6,@temp7,@temp8,@temp9,@temp10,@temp11,@temp12,@temp13,@temp14,@temp15,@temp16
  end
  close cursor1
  deallocate cursor1select * from #tempa
有点乱,麻烦大家了!!!解决了给高分

解决方案 »

  1.   

    close cursor1
    deallocate cursor1应该是执行这个的结果
      

  2.   

    你的select * from #tempa在“查询分析器”里应该有结果吧?
      

  3.   

    我试了一下,可能delphi不支持sqlserver的临时表
      

  4.   

    存储过程是没有问题的,关键是不是你用ado调用错误了,最好贴出来你ado调用的那一段代码
    select * from #tempa不应该写在存储过程里,而应该写在你的程序调用里
      

  5.   

    我把问题转到DELPHI版了,DELPHI中怎么解决这个存储过程的临时表的问题??
      

  6.   

    这种在存储过程中建立临时表并在结束前通过查询临时表产生数据集的办法是可行的, 甚至在select语句之后删除临时表都是可以的. 我在CB中用BDE, 采用过这种方法.
      

  7.   

    我用的是ADOSTOREDPORC
    with adostoredproc do
    begin
      close;
      parameters[1].value := xxx ;
      ......
      Open;
    end;
    发生错误,提示是“得不到返回的数据集”
      

  8.   

    你应该用ADOQuery或者ADOCommand,最好少用AdoStoredporc这种东西,AdoStoredporc是用于没有数据集返回的存储过程,这在Delphi的帮助里是有说明的。
      

  9.   

    我同意DepYuka() 的说法,最好用adodataset,有相当多的优越性