以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请狐爸高手解答foxtable 的质疑,关于对调用存储过程 ?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=56903)

--  作者:well_nick
--  发布时间:2014/9/15 9:21:00
--  请狐爸高手解答foxtable 的质疑,关于对调用存储过程 ?
foxtable 调用存储过程 ,exec mypro ,mypro 返回一个查询表。我搞了半天,返回值是空的。我的foxtable是试用版。 跟这个有关系吗?
 我在想是不是foxtable 改造了后,调用复杂的存储过程就不行或者有限制?请狐爸解答,另外有替代解决方法吗?
sql: 
ALTER PROCEDURE    [dbo].[gup_p_filtermoney]
AS
BEGIN
CREATE TABLE  #temp1(
[code] [varchar](10) NOT NULL,
[name] [varchar](50) NULL,
[run_time] [datetime] NOT NULL,
[amounts] [decimal](18, 5) NULL,
[counts] [int] NULL,
)
declare @day_count int ,@daysuc_count int
declare @days int
declare @run_time datetime
set @days=15
set @run_time=GETDATE()
 select @day_count= count(update_time) from 
 (select distinct update_time  
 from dde_fund_flow  
where   DATEPART(hour,update_time) =16
and   DateDiff(dd,update_time,getdate())<=@days ) a
set @daysuc_count=@day_count/2 +2
Insert into #temp1 (code,name,run_time,amounts,counts)  
select a.share_code AS code,a.name ,convert(varchar(23),@run_time,120) as run_time  ,a.amounts,b.counts from 
(select share_code,name ,SUM (net_amount) as amounts  
 from dde_fund_flow , shares 
where dde_fund_flow.share_code =shares.code 
 and DateDiff(dd,update_time,getdate())<=15 
 and  DATEPART(hour,update_time) =16
group by share_code,name
having  SUM (net_amount)>0  ) a , 
 (select share_code, count (net_amount) as counts from dde_fund_flow 
where  DateDiff(dd,update_time,getdate())<=15 
 and net_amount >0 and  DATEPART(hour,update_time) =16
group by share_code
having count (net_amount) >1 ) b
where a.share_code=b.share_code 
 and b.counts>@daysuc_count
 order by counts desc ,a.amounts desc
 select * from #temp1  
 end

button click :
 Dim sql,sqlstr As String
Dim  P_Cmd As new SQLCommand
Dim P_Dt,Pr_Dt As DataTable
\'sql ="select * from shares"
P_Cmd.C
P_Cmd.CommandText ="Exec gup_p_filtermoney "
P_Dt=P_Cmd.ExecuteReader()
返回空记录,存储过程应返回记录集,大家有没有碰到过啊

我在 sql 后台执行 exec gup_p_filtermoney
是有数据的,返回#temp1  表数据。




[此贴子已经被作者于2014-9-15 9:27:00编辑过]

--  作者:有点甜
--  发布时间:2014/9/15 9:24:00
--  

 存储过程,是不会返回值的。

 

 要么你写成函数,函数才会返回值

 

 http://blog.csdn.net/simpleiseasy/article/details/5816447

 


--  作者:有点甜
--  发布时间:2014/9/15 9:28:00
--  
 或者你直接写 select * from #temp
--  作者:well_nick
--  发布时间:2014/9/15 9:43:00
--  
函数比起储存过程好像有限制吧?另外select * from #temp 这个储存过程建立的临时表,在程序里不能只能直接调用。
--  作者:有点甜
--  发布时间:2014/9/15 9:46:00
--  

 函数和存储过程是一样的,只是它可以直接返回值。

 

 1、要么你把这个#temp当做变量返回;

 

 2、要么你这个#temp可以在外部访问得到。


--  作者:well_nick
--  发布时间:2014/9/15 10:21:00
--  
谢谢,可以解决,不过就是绕了圈,没有正面解决这个问题。
--  作者:逛逛
--  发布时间:2014/9/15 10:50:00
--  
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=42263&replyID=&skin=1