我写了一个存储过程,但是有一行有问题,
不知大家能理解我的意思不
[code="java"]
create procedure addIdeaData
as
declare @taskId varchar(50)
declare @acceptid varchar(50)
declare @max int
declare @cx int
set @cx=1
declare my_cursor cursor scroll
for
select taskid,acceptid
from tk_task
select count(*) into @max/////////////////////////////这一行有问题.........
from tk_task
where islasttask=1
open my_cursor
while @cx<@max
begin
fetch from my_cursor into @taskId,@acceptid
insert into evoa_idea(taskid,acceptid) values (@taskId,@acceptid)
set @cx=@cx+1
end
close my_cursor
deallocate my_cursor
[/code]
更正
[code="sql"]select @max = count(*) from tk_task [/code]
[code="java"]
select count(*) into @max/////////////////////////////这一行有问题.........
from tk_task
where islasttask=1
[/code]
这段改成:
[code="java"]
set @max = select count(*) from tk_task
where islasttask=1
[/code]
或者
select @max = select count(*) from tk_task
where islasttask=1
看看行不行?
[quote] select count(*) into @max[/quote]
这是oracle写法,sqlserver应该
[code="java"]
select @max = select count(*) from tk_task
[/code]