Shopping cart Business

Source: Internet
Author: User

Use [Quanli]
GO
/****** object:storedprocedure [dbo]. [Buycar] Script date:11/12/2016 08:25:25 ******/
SET ANSI_NULLS on
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo]. [Buycar]--Creating a stored procedure Bycar
(
@Purchase_State varchar (200),--Document status
@Purchase_Remark varchar (200),--remarks
@Supplier_Id int,--foreign key supplier code
@WareHose_Id int,--FOREIGN key warehouse code
@Employee_Id int,--operator
@xml XML--xml Data flow
)
As
Begin Tran T12--Transaction name
Insert into Purchase (purchase_curom,purchase_date,purchase_state,purchase_remark,supplier_id,warehose_id, EMPLOYEE_ID)
VALUES (CONVERT (int,getdate), GETDATE (), @Purchase_State, @Purchase_Remark, @Supplier_Id, @WareHose_Id, @ EMPLOYEE_ID)
declare @id int, @pointer INT--Define parameters
Set @[email protected] @IDENTITY;---get the self-increment field
CREATE TABLE #oo---creating a temp table
(
purchase_id int,--Purchase Main Table number (foreign key)
product_id int,--Product number (foreign key)
Purchasemate_num int,--Purchase quantity
Purchasemate_price Decimal,--Commodity price
Purchasemate_sum decimal--Total merchandise price

)
Execute sp_xml_preparedocument @pointer OUTPUT, @xml--sp_xml_preparedocument statement--Adds a data loop of XML type to the staging table
Insert into #oo (product_id,purchasemate_num,purchasemate_price,purchasemate_sum)
Select Product_id,purchasemate_num,purchasemate_price,purchasemate_sum from OpenXML (@pointer, '/xml/product ')-- System program sp_xml_preparedocument point to '/xml/product '
With (

product_id int,--Product code
Purchasemate_num int,--Purchase quantity
Purchasemate_price Decimal,--Commodity price
Purchasemate_sum decimal--Total merchandise price
)
Update #oo set [email protected]--Modify values
Insert into Purchasemate (purchase_id,product_id,purchasemate_num,purchasemate_price,purchasemate_sum) Select Purchase_id,product_id,purchasemate_num,purchasemate_price,purchasemate_sum from #oo

if (@ @ERROR <>0)
Begin
Rollback TRAN T12--rollback
return 0
End
Else
Begin
Commit Tran T12--Submit
Return 1
End

Shopping cart Business

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.