我对Sybase存储过程的语法不是很熟悉。我收到字符串连接错误:
create procedure calendarList
as
declare @city varchar(20)
declare @aus varchar(20)
declare @combined varchar(200)
declare @result varchar(200)
declare curs cursor for select distinct M_CTN from UnionCal for read only
open curs
fetch curs into @city
while (@@sqlstatus!=2)
begin
declare curs2 cursor for
select * from UnionCal where M_CTN=@city for read only
open curs2
fetch curs2 into @aus
while (@@sqlstatus!=2)
begin
@combined = @combined + ";" + @aus
fetch curs2 into @aus
end
fetch curs into @city
select @city,@aus
close curs2
end
close curs
return
错误在这一行:
@combined = @combined + ";" + @aus
错误消息不是很有用:
Msg 102,Level 15,State 1 服务器'DS_LN_D01_X0427',过程'calendarList',第24行 '@combined'附近的语法不正确。
显然我没有以正确的方式连接字符串。有什么想法吗?
我正在使用Sybase 12。
答案 0 :(得分:4)
在该命令之前添加SELECT
或SET
非常简单:
SELECT @combined = @combined + ";" + @aus
或
SET @combined = @combined + ";" + @aus