设为首页 加入收藏

TOP

自己写的游标操作语句(二)
2014-11-23 22:13:40 来源: 作者: 【 】 浏览:29
Tags:自己 游标 操作 语句
tachmentNum
,0
,0 www.2cto.com
,0
,0
,0)
set @NewTopicId=@@IDENTITY
end
else
begin
set @NewTopicId=isnull((select tid from [nsd_forum_discuz25].[dbo].[dnt_posts1] where pid=@REPLY_TO),999)
end
if @AttachmentNum=1
begin
INSERT INTO [nsd_forum_discuz25].[dbo].[dnt_attachments]
([uid]
,[tid]
,[pid]
,[postdatetime]
,[readperm]
,[filename]
,[description]
,[filetype]
,[filesize]
,[attachment]
,[downloads])
VALUES
(@AUTHOR_ID
,@NewTopicId
,@ID
,@POST_TIME
,0
,isnull(@Flinkurl,'')
,' '
,'image/pjpeg'
,751660
,isnull(@Flinkurl,'')
,100)
end
INSERT INTO [nsd_forum_discuz25].[dbo].[dnt_posts1]
([pid],[fid]
,[tid]
,[parentid]
,[layer]
,[poster]
,[posterid]
,[title]
,[postdatetime]
,[message]
,[ip]
,[lastedit]
,[invisible]
,[usesig]
,[ htmlon]
,[smileyoff]
,[parseurloff]
,[bbcodeoff]
,[attachment]
,[rate]
,[ratetimes])
VALUES
(@ID
,@BELONG_TO
,@NewTopicId
,isnull(@REPLY_TO,0)
,@newlayer
,@AUTHOR_NAME
,@AUTHOR_ID
,@TITLE
,@POST_TIME
,@CONTENT
,@IP
,@AUTHOR_NAME
,0
,1
,1
,1
,1
,1
,@AttachmentNum
,0 www.2cto.com
,0)
set @lastpostId=@ID
update [nsd_forum_discuz25].[dbo].[dnt_topics] set [lastpostId]=@lastpostId where tid=@NewTopicId
fetch next from my_cursor into @ID ,@TITLE
,@CONTENT
,@AUTHOR_ID
,@AUTHOR_NAME
,@AUTHOR_TEXT
,@AUTHOR_SIG
,@REPLY_TO
,@POST_TIME
,@BELONG_TO
,@LOCKED
,@POLL_COUNT
,@CLICK_COUNT
,@REPLY_COUNT
,@LAST_UPDATE
,@DELETED
,@IP
,@LINKURL
,@LINKIMG
,@Flinkname
,@Flinkurl
end
go
--fetch first from my_cursor into @fname
--
--update authors set au_fname='aa' where current of my_cursor
close my_cursor
deallocate my_cursor
--更新论坛dnt_topics的fid
--update [nsd_forum_discuz25].[dbo].[dnt_topics] a set a.fid=(select b.fid from [nsd_forum_discuz25].[dbo].[dnt_forums] b where b.oldfid=a.fid)
declare topic_cursor cursor scroll
for
SELECT [tid],[fid] from [nsd_forum_discuz25].[dbo].[dnt_topics] where fid<>0 ORDER BY tid
open topic_cursor
declare @tid int,@fid int
fetch next from topic_cursor into @tid,@FID
while(@@fetch_status=0)
begin
update [nsd_forum_discuz25].[dbo].[dnt_topics] set fid=isnull((select fid from [nsd_forum_discuz25].[dbo].[dnt_forums] where oldfid=@fid),999) where tid=@tid
print str(@fid)
fetch next from topic_cursor into @tid,@
首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇SQL游标语法及举例 下一篇SQL SERVER通过游标查询两个数据..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: