94 lines
3.9 KiB
Transact-SQL
94 lines
3.9 KiB
Transact-SQL
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_CalculatedChannelsInsert]') AND type in (N'P', N'PC'))
|
||
DROP PROCEDURE [dbo].[sp_CalculatedChannelsInsert]
|
||
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_CalculatedChannelsInsert]') AND type in (N'P', N'PC'))
|
||
BEGIN
|
||
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_CalculatedChannelsInsert] AS'
|
||
END
|
||
GO
|
||
ALTER PROCEDURE [dbo].[sp_CalculatedChannelsInsert]
|
||
@Operation int
|
||
,@CalculatedChannelValueCode nvarchar(255)
|
||
,@InputChannelIds varbinary(max)
|
||
,@CFCForInputChannels nvarchar(255)
|
||
,@CFCForOutput nvarchar(255)
|
||
,@TestSetupName nvarchar(255)
|
||
,@CCName nvarchar(255)
|
||
,@new_id int OUTPUT
|
||
,@errorNumber int output
|
||
,@errorMessage nvarchar(250) output
|
||
AS
|
||
BEGIN
|
||
SET NOCOUNT ON;
|
||
set @errorNumber = 0
|
||
set @errorMessage = space(0)
|
||
|
||
if(@Operation is null or @TestSetupName is null)
|
||
begin
|
||
set @errorMessage = 'sp_CalculatedChannelsInsert: Error 1560 - An invalid parameter or option was specified for procedure'
|
||
set @errorNumber = 1560
|
||
end
|
||
else
|
||
begin
|
||
begin try
|
||
declare @TestSetupId int
|
||
set @TestSetupId = dbo.foo_IdGetTestSetup(@TestSetupName)
|
||
|
||
INSERT INTO [dbo].[CalculatedChannels]
|
||
([Operation]
|
||
,[CalculatedChannelValueCode]
|
||
,[InputChannelIds]
|
||
,[CFCForInputChannels]
|
||
,[CFCForOutput]
|
||
,[TestSetupId]
|
||
,[CCName])
|
||
VALUES
|
||
(@Operation
|
||
,@CalculatedChannelValueCode
|
||
,@InputChannelIds
|
||
,@CFCForInputChannels
|
||
,@CFCForOutput
|
||
,@TestSetupId
|
||
,@CCName)
|
||
set @new_id = scope_identity();
|
||
end try
|
||
begin catch
|
||
set @errorMessage = error_message()
|
||
set @errorNumber = error_number()
|
||
end catch
|
||
end
|
||
END
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
GO
|