init
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,86 @@
|
||||
ALTER PROCEDURE [dbo].[sp_SensorCalibrationsInsert]
|
||||
@Id INT = NULL,
|
||||
@SensorSerialNumber NVARCHAR (50) = NULL,
|
||||
@SensorType TinyInt = NULL,
|
||||
@CalibrationDate DATETIME,
|
||||
@Username NVARCHAR (50),
|
||||
@LocalOnly BIT,
|
||||
@NonLinear BIT,
|
||||
@ModifyDate DATETIME,
|
||||
@IsProportional BIT,
|
||||
@RemoveOffset BIT,
|
||||
@ZeroMethod NVARCHAR (255),
|
||||
@CertificationDocuments NVARCHAR (2048),
|
||||
@InitialOffset NVARCHAR (MAX),
|
||||
@CalibrationRecords NVARCHAR (255),
|
||||
@SetLatestCalibrationId BIT,
|
||||
@new_id INT OUTPUT,
|
||||
@errorNumber INT OUTPUT,
|
||||
@errorMessage NVARCHAR (255) OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET @errorNumber = 0
|
||||
SET @errorMessage = space(0)
|
||||
DECLARE @SensorId AS INT
|
||||
SET @SensorId = @Id
|
||||
IF( @Id IS NULL)
|
||||
BEGIN
|
||||
SELECT @SensorId = [Id] FROM [dbo].[Sensors] WHERE [SensorType]=@SensorType AND [SerialNumber]=@SensorSerialNumber
|
||||
END
|
||||
IF( @SensorId IS NULL)
|
||||
BEGIN
|
||||
SET @errorNumber=1
|
||||
SET @errorMessage='Sensor not found'
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
DECLARE @CalibrationTypeId AS INT
|
||||
|
||||
SET @CalibrationTypeId = [dbo].[foo_IdGetCalibrationType](@NonLinear, @CalibrationRecords)
|
||||
|
||||
INSERT INTO [dbo].[SensorCalibrations] (
|
||||
[SensorId],
|
||||
[CalibrationDate],
|
||||
[Username],
|
||||
[LocalOnly],
|
||||
[NonLinear],
|
||||
[CalibrationTypeId],
|
||||
[CalibrationRecords],
|
||||
[ModifyDate],
|
||||
[IsProportional],
|
||||
[RemoveOffset],
|
||||
[ZeroMethod],
|
||||
[CertificationDocuments],
|
||||
[InitialOffset])
|
||||
VALUES (
|
||||
@SensorId,
|
||||
@CalibrationDate,
|
||||
@Username,
|
||||
@LocalOnly,
|
||||
@NonLinear,
|
||||
@CalibrationTypeId,
|
||||
@CalibrationRecords,
|
||||
@ModifyDate,
|
||||
@IsProportional,
|
||||
@RemoveOffset,
|
||||
@ZeroMethod,
|
||||
@CertificationDocuments,
|
||||
@InitialOffset)
|
||||
|
||||
SET @new_id = SCOPE_IDENTITY()
|
||||
|
||||
IF (@SetLatestCalibrationId = 1 )
|
||||
BEGIN
|
||||
UPDATE [dbo].[SensorsAnalog] SET [LatestCalibrationId]=@new_id WHERE [SensorId]=@SensorId
|
||||
END
|
||||
--IF(@CalibrationRecords != space(0) AND @SensorId !=0 AND @CalibrationTypeId != 0 AND @new_id !=0 )
|
||||
--BEGIN
|
||||
-- EXEC [dbo].[sp_SensorCalibrationRecordProsess] @SensorId, @new_id, @CalibrationTypeId, @CalibrationRecords, @errorNumber output, @errorMessage output
|
||||
--END
|
||||
IF(@@error!=0)
|
||||
BEGIN
|
||||
SET @errorNumber = error_number()
|
||||
SET @errorMessage = error_message()
|
||||
END
|
||||
END
|
||||
END
|
||||
Reference in New Issue
Block a user