TomBarrand
Programmer
I would like to select all of the records that meet the criteria below, then increment the Revision_No by 1 and insert this as a new record into the Purch_Ord_Hdr table.
SELECT (Purch_Ord_No, Revision_No, Status, Curr_ISO_Code, Retailer_No, Retailer_Contact, Retailer_Email, Ben_No, Ben_Contact, Ben_Email, Sales_Agent_No, Sales_Agent_Contact, Sales_Agent_Email, User_No, Factory_No, Factory_Contact, Factory_Email, Business_Unit, Terms, Freight_Mode, Season, Purch_Ord_Date, Auth_Notes, Assumptions, Quantity_Total, Ord_Value_Total, Expiry_Date)
FROM Purch_Ord_Hdr
where Purch_Ord_No = @PONo
I have tried to use a stored procedure with the syntax below, but I get errors.
Any ideas would be appreciated
CREATE PROCEDURE sp_NewRevision
@PONo INT,
@PORevNo INT,
@NewPORevNo INT
AS
begin
select @NewPORevNo = @PORevNo + 1
end
INSERT into Purch_Ord_Hdr (Purch_Ord_No, @NewPORevNo, Status, Curr_ISO_Code, Retailer_No, Retailer_Contact, Retailer_Email, Ben_No, Ben_Contact, Ben_Email, Sales_Agent_No, Sales_Agent_Contact, Sales_Agent_Email, User_No, Factory_No, Factory_Contact, Factory_Email, Business_Unit, Terms, Freight_Mode, Season, Purch_Ord_Date, Auth_Notes, Assumptions, Quantity_Total, Ord_Value_Total, Expiry_Date)
SELECT (Purch_Ord_No, Revision_No, Status, Curr_ISO_Code, Retailer_No, Retailer_Contact, Retailer_Email, Ben_No, Ben_Contact, Ben_Email, Sales_Agent_No, Sales_Agent_Contact, Sales_Agent_Email, User_No, Factory_No, Factory_Contact, Factory_Email, Business_Unit, Terms, Freight_Mode, Season, Purch_Ord_Date, Auth_Notes, Assumptions, Quantity_Total, Ord_Value_Total, Expiry_Date)
FROM Purch_Ord_Hdr
where Purch_Ord_No = @PONo
SELECT (Purch_Ord_No, Revision_No, Status, Curr_ISO_Code, Retailer_No, Retailer_Contact, Retailer_Email, Ben_No, Ben_Contact, Ben_Email, Sales_Agent_No, Sales_Agent_Contact, Sales_Agent_Email, User_No, Factory_No, Factory_Contact, Factory_Email, Business_Unit, Terms, Freight_Mode, Season, Purch_Ord_Date, Auth_Notes, Assumptions, Quantity_Total, Ord_Value_Total, Expiry_Date)
FROM Purch_Ord_Hdr
where Purch_Ord_No = @PONo
I have tried to use a stored procedure with the syntax below, but I get errors.
Any ideas would be appreciated
CREATE PROCEDURE sp_NewRevision
@PONo INT,
@PORevNo INT,
@NewPORevNo INT
AS
begin
select @NewPORevNo = @PORevNo + 1
end
INSERT into Purch_Ord_Hdr (Purch_Ord_No, @NewPORevNo, Status, Curr_ISO_Code, Retailer_No, Retailer_Contact, Retailer_Email, Ben_No, Ben_Contact, Ben_Email, Sales_Agent_No, Sales_Agent_Contact, Sales_Agent_Email, User_No, Factory_No, Factory_Contact, Factory_Email, Business_Unit, Terms, Freight_Mode, Season, Purch_Ord_Date, Auth_Notes, Assumptions, Quantity_Total, Ord_Value_Total, Expiry_Date)
SELECT (Purch_Ord_No, Revision_No, Status, Curr_ISO_Code, Retailer_No, Retailer_Contact, Retailer_Email, Ben_No, Ben_Contact, Ben_Email, Sales_Agent_No, Sales_Agent_Contact, Sales_Agent_Email, User_No, Factory_No, Factory_Contact, Factory_Email, Business_Unit, Terms, Freight_Mode, Season, Purch_Ord_Date, Auth_Notes, Assumptions, Quantity_Total, Ord_Value_Total, Expiry_Date)
FROM Purch_Ord_Hdr
where Purch_Ord_No = @PONo