哪的错啊请问

wuhaozhiyuan 2007-12-01 02:04:02
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

alter function getProductList(@customerguid char(36)) returns varchar(1024) as
begin
declare @product varchar(50)
declare @ReturnListProduct varchar(1024)
declare @ReturnListProductTemp varchar(300)
declare @fuhao char(1)
declare Product_list cursor for select p.productdesc from customer_surrogate cs left join product p on cs.productid = p.product_id
where cs.customer_guid = @customerguid

open Product_list;
--+ltrim(rtrim(@Currkey))+('''')
begin

while(1=1)
begin
fetch Product_list into @product
if @@fetch_status=-1
break

else
begin
select @ReturnListProductTemp=@ReturnListProduct
select @ReturnListProduct=ltrim(rtrim(@product))+','+@ReturnListProductTemp
end
end

end

close Product_list
return @ReturnListProduct
end

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dawugui 2007-12-02
  • 打赏
  • 举报
回复
知道原因就好。
wuhaozhiyuan 2007-12-01
  • 打赏
  • 举报
回复
我知道了 是因为变量没有负初始值 所以负不上值.
fa_ge 2007-12-01
  • 打赏
  • 举报
回复

open Product_list;
--+ltrim(rtrim(@Currkey))+('''')
begin

while(1=1)
begin
fetch next Product_list into @product
if @@fetch_status=-1
break

else
begin
select @ReturnListProductTemp=@ReturnListProduct
select @ReturnListProduct=ltrim(rtrim(@product) +','+@ReturnListProductTemp
end
fetch next Product_list into @product --这里少了这句,不然while是个死循环
end

end

close Product_list

sunhonglei2004 2007-12-01
  • 打赏
  • 举报
回复
没有看到有报错,还是以上语句没有达到LZ想要的效果
fa_ge 2007-12-01
  • 打赏
  • 举报
回复
报什么错?

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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