init
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
ALTER PROCEDURE [dbo].[sp_CalculatedChannelsGet]
|
||||
@CalculatedChannelsId int = null
|
||||
,@TestSetupName nvarchar(50) = null
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
SELECT c.[Id]
|
||||
,c.[Operation]
|
||||
,c.[CalculatedChannelValueCode]
|
||||
,c.[InputChannelIds]
|
||||
,c.[CFCForInputChannels]
|
||||
,c.[CFCForOutput]
|
||||
,t.[TestSetupName]
|
||||
,c.[CCName]
|
||||
,c.[ViewInRealtime]
|
||||
,c.[ClipLength]
|
||||
FROM [dbo].[CalculatedChannels] c
|
||||
inner join [dbo].[TestSetups] t on t.TestSetupId = c.TestSetupId
|
||||
where (@CalculatedChannelsId is null or c.Id = @CalculatedChannelsId)
|
||||
AND (@TestSetupName is null or t.TestSetupName = @TestSetupName)
|
||||
|
||||
END
|
||||
@@ -0,0 +1,58 @@
|
||||
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)
|
||||
,@ClipLength int
|
||||
,@ViewInRealtime bit
|
||||
,@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]
|
||||
,[ViewInRealtime]
|
||||
,[ClipLength])
|
||||
VALUES
|
||||
(@Operation
|
||||
,@CalculatedChannelValueCode
|
||||
,@InputChannelIds
|
||||
,@CFCForInputChannels
|
||||
,@CFCForOutput
|
||||
,@TestSetupId
|
||||
,@CCName
|
||||
,@ViewInRealtime
|
||||
,@ClipLength)
|
||||
set @new_id = scope_identity();
|
||||
end try
|
||||
begin catch
|
||||
set @errorMessage = error_message()
|
||||
set @errorNumber = error_number()
|
||||
end catch
|
||||
end
|
||||
END
|
||||
@@ -0,0 +1,64 @@
|
||||
ALTER PROCEDURE [dbo].[sp_CalculatedChannelsUpdateInsert]
|
||||
@id int = 0
|
||||
,@Operation int
|
||||
,@CalculatedChannelValueCode nvarchar(255)
|
||||
,@InputChannelIds varbinary(max)
|
||||
,@CFCForInputChannels nvarchar(255)
|
||||
,@CFCForOutput nvarchar(255)
|
||||
,@TestSetupName nvarchar(255)
|
||||
,@CCName nvarchar(255)
|
||||
,@ClipLength int
|
||||
,@ViewInRealtime bit
|
||||
,@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
|
||||
RAISERROR(15600,-1,-1, 'sp_CalculatedChannelsUpdateInsert') /* Error 1560 - An invalid parameter or option was specified for procedure*/
|
||||
end
|
||||
else
|
||||
begin
|
||||
declare @TestSetupId int
|
||||
set @TestSetupId = dbo.foo_IdGetTestSetup(@TestSetupName)
|
||||
|
||||
if(@id != 0 and exists(select Id from [dbo].[CalculatedChannels] where Id = @id and TestSetupId = @TestSetupId))
|
||||
begin
|
||||
set @new_id = @id
|
||||
|
||||
exec [dbo].[sp_CalculatedChannelsUpdate] @id
|
||||
,@Operation
|
||||
,@CalculatedChannelValueCode
|
||||
,@InputChannelIds
|
||||
,@CFCForInputChannels
|
||||
,@CFCForOutput
|
||||
,@TestSetupName
|
||||
,@CCName
|
||||
,@ClipLength
|
||||
,@ViewInRealtime
|
||||
,@errorNumber output
|
||||
,@errorMessage output
|
||||
|
||||
end
|
||||
else
|
||||
begin
|
||||
exec [dbo].[sp_CalculatedChannelsInsert] @Operation
|
||||
,@CalculatedChannelValueCode
|
||||
,@InputChannelIds
|
||||
,@CFCForInputChannels
|
||||
,@CFCForOutput
|
||||
,@TestSetupName
|
||||
,@CCName
|
||||
,@ViewInRealtime
|
||||
,@ClipLength
|
||||
,@new_id OUTPUT
|
||||
,@errorNumber output
|
||||
,@errorMessage output
|
||||
end
|
||||
end
|
||||
END
|
||||
@@ -0,0 +1,41 @@
|
||||
ALTER PROCEDURE [dbo].[sp_CalculatedChannelsUpdate]
|
||||
@id int = 0
|
||||
,@Operation int
|
||||
,@CalculatedChannelValueCode nvarchar(255)
|
||||
,@InputChannelIds varbinary(max)
|
||||
,@CFCForInputChannels nvarchar(255)
|
||||
,@CFCForOutput nvarchar(255)
|
||||
,@TestSetupName nvarchar(255) = null
|
||||
,@CCName nvarchar(255)
|
||||
,@ClipLength int
|
||||
,@ViewInRealtime bit
|
||||
,@errorNumber int output
|
||||
,@errorMessage nvarchar(250) output
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
set @errorNumber = 0
|
||||
set @errorMessage = space(0)
|
||||
|
||||
if(@id = 0 or @Operation is null or @TestSetupName is null)
|
||||
begin
|
||||
RAISERROR(15600,-1,-1, 'sp_CalculatedChannelsUpdate') /* Error 1560 - An invalid parameter or option was specified for procedure*/
|
||||
end
|
||||
else
|
||||
begin
|
||||
declare @TestSetupId int
|
||||
set @TestSetupId = dbo.foo_IdGetTestSetup(@TestSetupName)
|
||||
|
||||
UPDATE [dbo].[CalculatedChannels]
|
||||
SET [Operation] = @Operation
|
||||
,[CalculatedChannelValueCode] = @CalculatedChannelValueCode
|
||||
,[InputChannelIds] = @InputChannelIds
|
||||
,[CFCForInputChannels] = @CFCForInputChannels
|
||||
,[CFCForOutput] = @CFCForOutput
|
||||
,[TestSetupId] = @TestSetupId
|
||||
,[CCName] = @CCName
|
||||
,[ViewInRealtime] = @ViewInRealtime
|
||||
,[ClipLength] = @ClipLength
|
||||
WHERE [Id] = @id
|
||||
end
|
||||
END
|
||||
@@ -0,0 +1,3 @@
|
||||
UPDATE [dbo].[CalculatedChannels] SET [ViewInRealtime]=1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user