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 差距就是大啊 |