86 lines
3.2 KiB
Plaintext
86 lines
3.2 KiB
Plaintext
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_TestObjectHardwareInsert]') AND type in (N'P', N'PC'))
|
|
DROP PROCEDURE [dbo].[sp_TestObjectHardwareInsert]
|
|
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_TestObjectHardwareInsert]') AND type in (N'P', N'PC'))
|
|
BEGIN
|
|
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_TestObjectHardwareInsert] AS'
|
|
END
|
|
GO
|
|
ALTER PROCEDURE [dbo].[sp_TestObjectHardwareInsert]
|
|
@TestObjectId int = 0
|
|
,@TestObjectName nvarchar(255) = null
|
|
,@HardwareId nvarchar(255)
|
|
,@LocalOnly bit
|
|
,@new_id int output
|
|
,@errorNumber int output
|
|
,@errorMessage nvarchar(250) output
|
|
AS
|
|
BEGIN
|
|
begin try
|
|
set @errorNumber = 0; set @errorMessage = space(0);
|
|
|
|
if(@TestObjectName is null)
|
|
begin
|
|
set @errorMessage = 'An invalid parameter or option was specified for procedure'
|
|
set @errorNumber = 1560
|
|
end
|
|
else
|
|
begin
|
|
declare @DASId int
|
|
set @DASId = dbo.foo_IdGetDAS(@HardwareId)
|
|
|
|
if(@TestObjectId=0)
|
|
begin
|
|
set @TestObjectId = dbo.foo_IdGetTestObject(@TestObjectName)
|
|
end
|
|
select @TestObjectId
|
|
insert into [dbo].[TestObjectHardware]
|
|
([TestObjectId]
|
|
,[DASId]
|
|
,[LocalOnly])
|
|
values
|
|
(@TestObjectId
|
|
,@DASId
|
|
,@LocalOnly)
|
|
set @new_id = SCOPE_IDENTITY()
|
|
end
|
|
end try
|
|
begin catch
|
|
set @errorMessage = error_message()
|
|
set @errorNumber = error_number()
|
|
end catch;
|
|
END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GO
|