SQL中的游标什么时候搜索结束
printf("输入电影名称\n");scanf("%s",where);EXECSQLDECLAREtitleCursorCURSORFORselecttitle,iy...
printf("输入电影名称\n");
scanf("%s",where);
EXEC SQL DECLARE titleCursor CURSOR FOR
select title,iyear,length,genre,studioname,producerc
from movies
where title=:where;
EXEC SQL OPEN titleCursor;
EXEC SQL FETCH titleCursor INTO :title, :iyear, :length,:genre,:studioname,:producerc;
printf("%s %d %d %s %s %d\n",title,iyear,length,genre,studioname,producerc);
EXEC SQL CLOSE titleCursor;
break;
比如上面有三条结果,
EXEC SQL FETCH titleCursor INTO :title, :iyear, :length,:genre,:studioname,:producerc;
printf("%s %d %d %s %s %d\n",title,iyear,length,genre,studioname,producerc);
这边怎么改? 展开
scanf("%s",where);
EXEC SQL DECLARE titleCursor CURSOR FOR
select title,iyear,length,genre,studioname,producerc
from movies
where title=:where;
EXEC SQL OPEN titleCursor;
EXEC SQL FETCH titleCursor INTO :title, :iyear, :length,:genre,:studioname,:producerc;
printf("%s %d %d %s %s %d\n",title,iyear,length,genre,studioname,producerc);
EXEC SQL CLOSE titleCursor;
break;
比如上面有三条结果,
EXEC SQL FETCH titleCursor INTO :title, :iyear, :length,:genre,:studioname,:producerc;
printf("%s %d %d %s %s %d\n",title,iyear,length,genre,studioname,producerc);
这边怎么改? 展开
1个回答
展开全部
declare @a int
declare t1 CURSOR for select Fielda from tablename
open t1
FETCH NEXT FROM t1 INTO @a
WHILE (@@FETCH_STATUS = 0)
BEGIN
--do something
FETCH NEXT FROM t1 INTO @a
END
CLOSE t1
DEALLOCATE t1
declare t1 CURSOR for select Fielda from tablename
open t1
FETCH NEXT FROM t1 INTO @a
WHILE (@@FETCH_STATUS = 0)
BEGIN
--do something
FETCH NEXT FROM t1 INTO @a
END
CLOSE t1
DEALLOCATE t1
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询