Grade Changes
The Grade Change result set is used for creating, modifying and/or deleting grade changes. There is no End_Time field in this result set so when it is issued the DBMgr will create the record with either a NULL End_Time (for example, it is the current grade selection) or it will use the start time of the next grade change as the end time. If the current grade is the same as the specified product id in the result set then it will be ignored. If the next grade change already exists and is the same product as that specified in the result set, then the Start_Time of the next grade change will be modified to the one specified in the result set.
To update a grade change record with a different product, query the Start_Id out of the Production_Starts table and include that in the result set (along with the other fields) along with a different Prod_Id. As stated above, if you want to modify the Start_Time to an earlier then, simply issue the result set with the same product and an earlier start time. To modify it with a later time, you must delete and then recreate the grade change record from scratch.
To delete a grade change, you must find the product id of the previous grade change and then update the target grade change with the previous grade change’s product id. The DBMgr will then delete the target grade change.
Order | Field Name | Values/Table Reference |
---|---|---|
0 | Result Set Type | 3 |
1 | Grade Change Id | Production_Starts.Start_Id |
2 | Unit Id |
|
3 | Product Id | Products.Prod_Id |
4 | TimeStamp | Production_Starts.Start_Time |
5 | Update Type |
|
6 | User Id |
|
Example
DECLARE @PUID INT, @ProdId INT;
DECLARE @ProductionStarts TABLE
(
ResultSetType INT DEFAULT 3,
StartId INT NULL,
PUID INT NULL,
ProdID INT NULL,
StartTime VARCHAR(50) NULL,
PostUpdate INT DEFAULT 0
);
SELECT @PUId=PU_Id FROM dbo.Prod_Units WHERE PU_Desc='MyUnit';
SELECt @ProdId=Prod_Id FROM dbo.Products WHERE Prod_Code='MyProductCode';
INSERT INTO @ProductionStarts(PU_Id, ProdId, Startime)
VALUES(@PUID, @ProdId, CONVERT(VARCHAR(50), GETDATE(), 120));
-- Output results
SELECT ResultSetType, StartId, PUId, ProdId, Startime, PostUpdate
FROM @ProductionStarts;