sql 返回多個值的儲存過程

2021-05-23 05:35:26 字數 987 閱讀 9852

create function [dpm].[getvalue](@processmanageid varchar(32))

returns  @temptable   table   (carrydeptid varchar(32),carrydept varchar(100),investmoney float,productionvalue float)

asbegin

declare @carrydeptid varchar(32);

declare mycur cursor for ( select distinct carrydeptid from dpm_yw_production_value where processmanageid = @processmanageid )

open mycur

fetch next from mycur into @carrydeptid

while @@fetch_status = 0

begin  

insert @temptable  select * from (select top 1 carrydeptid,carrydept, investmoney as '總投資' ,productionvalue as '產值' from dpm_yw_production_value  where

carrydeptid=@carrydeptid order by createtime desc) a where (isnull(a.investmoney,0)!=0 or isnull(a.productionvalue,0)!=0) and  (isnull(a.investmoney,0)=0 or isnull(a.productionvalue,0)!=0)

fetch next from mycur into @carrydeptid

end

close mycur

deallocate mycur

return

end

SQL儲存過程返回值

先靠一下自己。當我做多了oracle時,我就忘了sql的儲存過程可以返回資料集這個事實了。create procedure test t1 int,t2 nvarchar 200 out asset t2 這個是輸出引數 go呼叫 declare out t2 nvarchar 200 exec t...

mysql使用儲存過程返回多個值

可以使用out inout引數型別讓儲存過程返回多個結果值,儲存函式不能勝任,因為只能返回乙個值。比如統計student資料表裡男生和女生人數並通過它的引數返回這兩個計數值,讓呼叫者可以訪問它們 delimiter create procedure count students by out p m...

MySQL儲存過程返回多個值 5

mysql儲存函式只返回乙個值。要開發返回多個值的儲存過程,需要使用帶有inout或out引數的儲存過程。返回多個值的儲存過程示例 select from orders 原表的資料如上面所示。返回多個值,其實就是多設定幾個inout out的引數。sql 如下 use yiibaidb drop p...