23 lines
1.3 KiB
Plaintext
23 lines
1.3 KiB
Plaintext
CREATE PROCEDURE [dbo].[sp_SensorsUARTGet]
|
|
@Id INT = null,
|
|
@SerialNumber NVARCHAR (50) = null
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON;
|
|
|
|
IF( @Id IS NULL)
|
|
BEGIN
|
|
IF NULLIF(@SerialNumber, '') IS NULL
|
|
BEGIN
|
|
SELECT A.id, A.SerialNumber, B.BaudRate, B.DataBits, B.StopBits, B.Parity, B.FlowControl, B.DataFormat, B.LastModified, B.LastModifiedBy, B.UserTags, B.Broken, B.DoNotUse FROM [dbo].[Sensors] AS A INNER JOIN [dbo].[SensorsUART] AS B ON A.id=B.SensorId INNER JOIN [dbo].SensorsType AS C ON A.SensorType=C.TypeId WHERE C.SensorType='UART'
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
SELECT A.id, A.SerialNumber, B.BaudRate, B.DataBits, B.StopBits, B.Parity, B.FlowControl, B.DataFormat, B.LastModified, B.LastModifiedBy, B.UserTags, B.Broken, B.DoNotUse FROM [dbo].[Sensors] AS A INNER JOIN [dbo].[SensorsUART] AS B ON A.id=B.SensorId INNER JOIN [dbo].SensorsType AS C ON A.SensorType=C.TypeId WHERE C.SensorType='UART' AND A.SerialNumber=@SerialNumber
|
|
END
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
SELECT A.id, A.SerialNumber, B.BaudRate, B.DataBits, B.StopBits, B.Parity, B.FlowControl, B.DataFormat, B.LastModified, B.LastModifiedBy, B.UserTags, B.Broken, B.DoNotUse FROM [dbo].[Sensors] AS A INNER JOIN [dbo].[SensorsUART] AS B ON A.id=B.SensorId INNER JOIN [dbo].SensorsType AS C ON A.SensorType=C.TypeId WHERE C.SensorType='UART' AND A.id=@Id
|
|
END
|
|
END |