以文本方式查看主题

-  蓝色快车PB俱乐部论坛  (http://pb.besoft.com.cnhttp://pb.besoft.com.cn/bbs/index.aspindex.asp)
--  PowerBuilder MIS编程  (http://pb.besoft.com.cnhttp://pb.besoft.com.cn/bbs/index.aspbbs.asp?boardid=1)
----  pb中调用存储过程问题  (http://pb.besoft.com.cnhttp://pb.besoft.com.cn/bbs/index.aspdispbbs.asp?boardid=1&rootid=3847&id=3847)


--  作者:fengsheng
--  发布时间:2006/6/19 14:45:46

--  pb中调用存储过程问题
if exists(select name from syso b j e c ts where name='select_money_total_time')
drop procedure select_money_total_time
CREATE PROCEDURE Select_money_total_time @eno varchar(10),@year varchar(4),@month varchar(2)

Select round ( ( sum ( isnull ( T_Hour.h_dayhour , 0 ) ) + sum ( isnull ( h_addhour , 0 ) ) ) / 9 , 1 ) 
From T_Hour Where ( T_Hour.h_eno =@eno ) And ( T_Hour.h_year =@year ) And ( t_hour.h_month =@month )
(Select round ( sum ( T_Salary.s_quantity ) / 9 , 1 ) From T_Salary 
Where ( T_Salary.s_eno =@eno ) And ( T_Salary.s_year =@year ) And ( T_Salary.s_month =@month ) And Left ( s_pno , 1 ) ='T')
(Select round ( sum ( isnull ( T_Salary.s_price *T_Salary.s_quantity , 0 ) ) , 0 ) From T_Salary 
Where ( T_Salary.s_eno =@eno ) And ( T_Salary.s_year =@year ) And ( T_Salary.s_month =@month ) And ( Left ( t_salary.s_pno , 1 ) ='T' ) )
(Select round ( sum ( isnull ( T_Salary.s_price *T_Salary.s_quantity , 0 ) ) , 0 ) From T_Salary 
Where ( T_Salary.s_eno =@eno ) And ( T_Salary.s_year =@year ) And ( T_Salary.s_month =@month ) And ( Left ( t_salary.s_pno , 1 ) <>'T' ) )
(Select round ( sum ( isnull ( T_Salary.s_price *T_Salary.s_quantity , 0 ) ) , 0 ) From T_Salary 
Where ( T_Salary.s_eno =@eno ) And ( T_Salary.s_year =@year ) And ( t_salary.s_month =@month )) 
GO

在sqlserver2000中用查询分析器执行是可以得到五个数,但是在pb中调用的话就只能得到五个数全部为0了,应该怎么做
DECLARE select_money PROCEDURE FOR Select_money_total_time  
        @eno = :ls_eno,   
         @year = :ls_year,   
       @month = :ls_month 
   using sqlca;
execute select_money;
do while sqlca.sqlcode=0 
fetch select_money into :ld_allday, :ld_hourday,:ld_hoursum,:ld_itemsum,:ld_sum;
close select_money;
loop

如果是这样的话就可以得到一个值

DECLARE select_money PROCEDURE FOR Select_money_total_time  
        @eno = :ls_eno,   
         @year = :ls_year,   
       @month = :ls_month 
   using sqlca;
execute select_money;
do while sqlca.sqlcode=0 
fetch select_money into :ld_allday;
close select_money;
loop


--  作者:sqsss
--  发布时间:2006/9/2 12:08:10

--  
帮顶一下

">