2

我对 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

错误消息不是很有帮助:

消息 102,级别 15,状态 1 服务器“DS_LN_D01_X0427”,过程“日历列表”,第 24 行“@combined”附近的语法不正确。

显然我没有以正确的方式连接字符串。有任何想法吗?

我正在使用 Sybase 12。

4

1 回答 1

4

只需在该命令之前添加SELECTor就非常简单:SET

SELECT @combined = @combined + ";" + @aus

或者

SET @combined = @combined + ";" + @aus
于 2012-06-15T16:27:24.337 回答