ALTER PROCEDURE [dbo].[Purchase_Create]
@Docid varchar(100), ---- 搜索唯一编号
@Title varchar(100), ---- 求购标题
@Province varchar(20), ---- 来自区域省
@City varchar(50), ---- 来自区域市
@Area varchar(50), ---- 来自区域
@Address varchar(200), ---- 交货详细地点
@CompanyID int, ---- 发布公司ID
@IssueDate datetime, ---- 发布时间
@Period int, ---- 有效期
@limitDate datetime, ---- 到期时间
@CateID int, ---- 品类ID
@ExpectLowPrice decimal(18,2),---- 期望最低价格
@Exigence tinyint, ---- 紧急求购
@RelationName varchar(50), ---- 联系人姓名
@RelationSex bit, ---- 联系人性别
@RelationTele varchar(20), ---- 联系人电话
@Contents varchar(4000), ---- 采购数量
@Amounts int, ---- 采购数量
@IsTop bit, ---- 是否置顶
@MoID int, ---- 置顶栏目ID
@MobilePhone varchar(50), ---- 移动电话
@Fax varchar(50), ---- 传真
@Email varchar(100), ---- 电子邮件
@Author varchar(50), ---- 发布者
@Company varchar(100), ---- 公司名称
@Details varchar(4000) ---- 详细信息
AS
BEGIN
BEGIN Transaction
INSERT INTO [Purchase](
[Docid],[Title],[Province],[City],[Area],[Address],[CompanyID],[IssueDate],[Period],[limitDate],[CateID],[ExpectLowPrice],[Exigence],[RelationName],[RelationSex],[RelationTele],[Contents],[Amounts],[IsTop],[MoID],[MobilePhone],[Fax],[Email],[Author],[Company],[Details]
)VALUES(
@Docid,@Title,@Province,@City,@Area,@Address,@CompanyID,@IssueDate,@Period,@limitDate,@CateID,@ExpectLowPrice,@Exigence,@RelationName,@RelationSex,@RelationTele,@Contents,@Amounts,@IsTop,@MoID,@MobilePhone,@Fax,@Email,@Author,@Company,@Details
);
if not exists(select Docid from PurchaseDetails where Docid=@Docid)
BEGIN
insert into PurchaseDetails(Docid,Details) values(@Docid,@Details)
END
ELSE
BEGIN
UPDATE PurchaseDetails SET Details=@Details WHERE Docid=@Docid
END
Commit Transaction
IF(@@ERROR<>0)
Rollback Transaction
END
GO