94 lines
3.6 KiB
Transact-SQL
94 lines
3.6 KiB
Transact-SQL
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_TestObjectChannelSettingsInsert]') AND type in (N'P', N'PC'))
|
||
DROP PROCEDURE [dbo].[sp_TestObjectChannelSettingsInsert]
|
||
GO
|
||
SET ANSI_NULLS ON
|
||
GO
|
||
SET QUOTED_IDENTIFIER ON
|
||
GO
|
||
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_TestObjectChannelSettingsInsert]') AND type in (N'P', N'PC'))
|
||
BEGIN
|
||
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_TestObjectChannelSettingsInsert] AS'
|
||
END
|
||
GO
|
||
ALTER PROCEDURE [dbo].[sp_TestObjectChannelSettingsInsert]
|
||
@TestObjectId int = 0
|
||
,@TestObjectName nvarchar(255) = null
|
||
,@ChannelId nvarchar(255)
|
||
,@Setting nvarchar(255)
|
||
,@SensorSerialNumber nvarchar(255)
|
||
,@Disabled bit
|
||
,@new_id int output
|
||
,@errorNumber int output
|
||
,@errorMessage nvarchar(250) output
|
||
AS
|
||
BEGIN
|
||
set @errorNumber = 0; set @errorMessage = space(0);
|
||
|
||
begin try
|
||
if(@TestObjectName is null)
|
||
begin
|
||
set @errorMessage = 'An invalid parameter or option was specified for procedure'
|
||
set @errorNumber = 15600
|
||
end
|
||
else
|
||
begin
|
||
|
||
if(@TestObjectId = 0)
|
||
begin
|
||
set @TestObjectId = dbo.foo_IdGetTestObject(@TestObjectName)
|
||
end
|
||
|
||
declare @SensorId int
|
||
set @SensorId = dbo.foo_IdGetSensor(@SensorSerialNumber)
|
||
|
||
INSERT INTO [dbo].[TestObjectChannelSettings]
|
||
([TestObjectId]
|
||
,[ChannelId]
|
||
,[Setting]
|
||
,[SensorId]
|
||
,[Disabled])
|
||
VALUES
|
||
(@TestObjectId
|
||
,@ChannelId
|
||
,@Setting
|
||
,@SensorId
|
||
,@Disabled)
|
||
|
||
set @new_id = scope_identity();
|
||
end
|
||
end try
|
||
begin catch
|
||
set @errorMessage = error_message()
|
||
set @errorNumber = error_number()
|
||
end catch;
|
||
END
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
GO
|