Variable Values
Order | Field Name | Values/Table Reference |
---|---|---|
0 | Result Set Type | 2 |
1 | Variable Id | Tests.Var_Id |
2 | Production Unit Id | Variables.PU_Id |
3 | User Id | Tests.User_Id |
4 | Cancelled |
|
5 | Value | Tests.Result |
6 | Timestamp | Tests.Result_On |
7 | Transaction Type |
|
8 | Update Type |
|
The following should be taken into consideration when using the Variable Values result set:
- There is no delete functionality with the Variable Values result set so to effectively delete variable values you must update the value to NULL.
- If the update type is set to post-update, calculations that depend on the variable value will not be fired.
Example
DECLARE @VarId INT, @PUId INT, @VarPrecision INT;
DECLARE @VariableResults TABLE
(
ResultSetype INT DEFAULT 2,
VarId INT NULL,
PUId INT NULL,
UserId INT NULL,
Cancelled INT DEFAULT 0,
Result VARCHAR(50) NULL,
ResultOn VARCHAR(50) NULL,
TransType INT DEAFAULT 1,
PostUpdate INT DEFAULT 0
);
SELECT @VarId=Var_Id, @PUId=PU_Id, @VarPrecision=Var_Precision
FROM dbo.variables
WHERE Var_Desc='MyVariable';
INSERT INTO @VariableResults(VarId, PUId, Result, ResultOn)
VALUES(@VarId, @PUId, LTRIM(STR(1.234, 50, @VarPrecision)), CONVERT(VARCHAR(50), GETDATE(), 120));
-- Output results
SELECT ResultSetType, VarId, PUId, UserId, Cancelled, Result, ResultOn, TransType, PostUpdate
FROM @VariableResults;