91 lines
3.5 KiB
Transact-SQL
91 lines
3.5 KiB
Transact-SQL
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_TestSetupHardwareInsert]') AND type in (N'P', N'PC'))
|
||
DROP PROCEDURE [dbo].[sp_TestSetupHardwareInsert]
|
||
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_TestSetupHardwareInsert]') AND type in (N'P', N'PC'))
|
||
BEGIN
|
||
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_TestSetupHardwareInsert] AS'
|
||
END
|
||
GO
|
||
ALTER PROCEDURE [dbo].[sp_TestSetupHardwareInsert]
|
||
@DASId int = 0
|
||
,@DASSerialNumber varchar(50) = null
|
||
,@TestSetupId int = 0
|
||
,@TestSetupName nvarchar(255) = null
|
||
,@AddOrRemove bit
|
||
,@new_id int output
|
||
,@errorNumber int output
|
||
,@errorMessage nvarchar(250) output
|
||
AS
|
||
BEGIN
|
||
set @errorNumber = 0; set @errorMessage = space(0);
|
||
begin try
|
||
if((@TestSetupName is null or @TestSetupId =0) and (@DASSerialNumber is null or @DASId = 0))
|
||
begin
|
||
set @errorNumber = 15600
|
||
set @errorMessage = 'An invalid parameter or option was specified for procedure'
|
||
|
||
end
|
||
else
|
||
begin
|
||
SET NOCOUNT ON;
|
||
if (@TestSetupId =0)
|
||
begin
|
||
set @TestSetupId = dbo.foo_IdGetTestSetup(@TestSetupName)
|
||
end
|
||
if(@DASId =0)
|
||
begin
|
||
set @DASId = dbo.foo_IdGetDAS(@DASSerialNumber )
|
||
end
|
||
|
||
insert into [dbo].[TestSetupHardware]
|
||
([DASId]
|
||
,[TestSetupId]
|
||
,[AddOrRemove])
|
||
values
|
||
(@DASId
|
||
,@TestSetupId
|
||
,@AddOrRemove)
|
||
|
||
set @new_id = scope_identity();
|
||
|
||
end
|
||
end try
|
||
begin catch
|
||
set @errorNumber = ERROR_NUMBER()
|
||
set @errorMessage = ERROR_MESSAGE()
|
||
end catch;
|
||
END
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
GO
|