采集器存储过程

USE [800Fc#Com#System]
GO
/****** Object: StoredProcedure [dbo].[insertArticle] Script Date: 02/01/2013 13:39:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[insertArticle]
@f_title nvarchar(100),
@f_author nvarchar(50),@f_comefrom nvarchar(50),@f_keywords nvarchar(50),
@f_tpath varchar(250),@f_intro nvarchar(500),@f_url varchar(250),
@f_gathertime datetime,@source varchar(500)
as
if exists(select 1 from dbo.cms_article where f_url=@f_url)
begin
return -1--'采集失败,库里存在相同记录!'
end
else
begin
--第一步先插入到cms_article_autoid表获取新的id,复制给@id
insert into dbo.cms_article_autoid(f_addtime) values(GETDATE())
declare @id int = 0
set @id = @@IDENTITY
--第三步将获取到的字段添加到表中
insert into dbo.cms_article
(id,f_siteid,f_channel_id,f_channel_guid,f_channel_name,f_title,f_author,f_comefrom,f_keywords,f_tpath,f_intro,f_url,f_gathertime,f_addtime)
select @id,f_siteid,id,f_guid,f_name,@f_title,@f_author,@f_comefrom,@f_keywords,@f_tpath,@f_intro,@f_url,@f_gathertime,GETDATE()
from cms_channel
where f_gather_url=@source
if(@@ERROR>0)
begin
return 1--'异常错误!'
end
else
begin
return 2--'采集成功!'

end
end

posted @ 2013-02-01 14:44  张涵哲琪  阅读(306)  评论(0编辑  收藏  举报