101 lines
4.7 KiB
Plaintext
101 lines
4.7 KiB
Plaintext
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_TestSetupObjectsUpdateInsert]') AND type in (N'P', N'PC'))
|
|
DROP PROCEDURE [dbo].[sp_TestSetupObjectsUpdateInsert]
|
|
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_TestSetupObjectsUpdateInsert]') AND type in (N'P', N'PC'))
|
|
BEGIN
|
|
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_TestSetupObjectsUpdateInsert] AS'
|
|
END
|
|
GO
|
|
ALTER PROCEDURE [dbo].[sp_TestSetupObjectsUpdateInsert]
|
|
@TestSetupId int = 0
|
|
,@TestSetupName nvarchar(255) = null
|
|
|
|
,@TestObjectId int = 0
|
|
,@TestObjectName nvarchar(255) = null
|
|
|
|
,@TargetSampleRate float
|
|
,@ExcitationWarmupTimeMS int
|
|
,@LocalOnly bit
|
|
,@TestObjectType nvarchar(50)
|
|
,@TestObjectPosition nvarchar(50)
|
|
,@new_id int output
|
|
,@errorNumber int output
|
|
,@errorMessage nvarchar(250) output
|
|
AS
|
|
BEGIN
|
|
set @errorNumber = 0; set @errorMessage = space(0); set @new_id = 0;
|
|
|
|
if (@TestSetupId =0)
|
|
begin
|
|
set @TestSetupId = dbo.foo_IdGetTestSetup(@TestSetupName)
|
|
end
|
|
|
|
if(@TestObjectId =0)
|
|
begin
|
|
set @TestObjectId = dbo.foo_IdGetTestObject(@TestObjectName)
|
|
end
|
|
|
|
if(exists(select * from [dbo].[TestSetupObjects] where TestSetupId = @TestSetupId and TestObjectId = @TestObjectId))
|
|
begin
|
|
set @new_id = @TestObjectId
|
|
exec [dbo].[sp_TestSetupObjectsUpdate] @TestSetupId
|
|
,@TestObjectId
|
|
,@TestObjectName
|
|
,@TestSetupName
|
|
,@TargetSampleRate
|
|
,@ExcitationWarmupTimeMS
|
|
,@LocalOnly
|
|
,@TestObjectType
|
|
,@TestObjectPosition
|
|
,@errorNumber output
|
|
,@errorMessage output
|
|
end
|
|
else
|
|
begin
|
|
exec [dbo].[sp_TestSetupObjectsInsert] @TestSetupId
|
|
,@TestObjectId
|
|
,@TestObjectName
|
|
,@TestSetupName
|
|
,@TargetSampleRate
|
|
,@ExcitationWarmupTimeMS
|
|
,@LocalOnly
|
|
,@TestObjectType
|
|
,@TestObjectPosition
|
|
,@new_id output
|
|
,@errorNumber output
|
|
,@errorMessage output
|
|
|
|
end
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GO
|