帮我看看这个存储过程

[复制链接]
查看11 | 回复0 | 2008-12-17 10:40:00 | 显示全部楼层 |阅读模式
CREATE PROCEDURE proc_test
AS
declare @namevarchar(40)
declare cur_pstn_ods cursor for select * from view_test_huang
OPEN cur_pstn_ods
fetch cur_pstn_odsinto @name
while @@sqlstatus = 0
begin
insert into test01 values(@name)

fetch cur_pstn_odsinto @name
end
close cur_pstn_ods
DEALLOCATE cursor cur_pstn_ods

错误如下:
Server Message:Number156, Severity15
Server 'SYBASE', Procedure 'proc_pstn_ods', Line 18:
Incorrect syntax near the keyword 'select'.
Server Message:Number156, Severity15
Server 'SYBASE', Procedure 'proc_pstn_ods', Line 22:
Incorrect syntax near the keyword 'select'.
Server Message:Number156, Severity15
Server 'SYBASE', Procedure 'proc_pstn_ods', Line 22:
Incorrect syntax near the keyword 'where'.
Server Message:Number156, Severity15
Server 'SYBASE', Procedure 'proc_pstn_ods', Line 27:
Incorrect syntax near the keyword 'select'.
Server Message:Number156, Severity15
Server 'SYBASE', Procedure 'proc_pstn_ods', Line 27:
Incorrect syntax near the keyword 'where'.
Server Message:Number156, Severity15
Server 'SYBASE', Procedure 'proc_pstn_ods', Line 53:
Incorrect syntax near the keyword 'fetch'.

出错处的语句:
select @trunk_new_count =select count(*) from trunk_new where offi_id="+@offi_id+"and (dir=3 or dir=1)
print @trunk_new_count
exec (@trunk_new_count )
select @ta_count=select count(*) from " +@name+" where time>=dateadd(hh,-1,time) and timedateadd(hh,-1,time) and time=dateadd(hh,-1,time) and timedateadd(hh,-1,time) and time=dateadd(hh,-1,time) and timedateadd(hh,-1,time) and time=dateadd(hh,-1,time) and timedateadd(hh,-1,time) and time=dateadd(hh,-1,time) and timedateadd(hh,-1,time) and time=dateadd(hh,-1,time) and timedateadd(hh,-1,time) and time<dateadd(hh,1,time) and trk_name in ( select trk_name from trunk_new where offi_id=@offi_idand (dir=3 or dir=1)))"
exec(@time_char )
就是错的。感觉是SYBASE 在获得结果不能是字符串。哎!!!!!!!!!!!!!SYBASE 差距就是大啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行