153 lines
6.2 KiB
Transact-SQL
153 lines
6.2 KiB
Transact-SQL
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_DASUpdateInsert]') AND type in (N'P', N'PC'))
|
||
DROP PROCEDURE [dbo].[sp_DASUpdateInsert]
|
||
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_DASUpdateInsert]') AND type in (N'P', N'PC'))
|
||
BEGIN
|
||
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_DASUpdateInsert] AS'
|
||
END
|
||
GO
|
||
ALTER PROCEDURE [dbo].[sp_DASUpdateInsert]
|
||
@DASId int = 0
|
||
,@SerialNumber nvarchar(50) = null
|
||
,@Type int
|
||
,@MaxModules int
|
||
,@MaxMemory bigint
|
||
,@MaxSampleRate decimal(18,0)
|
||
,@MinSampleRate decimal(18,0)
|
||
,@FirmwareVersion nvarchar(50)
|
||
,@CalDate datetime
|
||
,@ProtocolVersion int
|
||
,@LastModified datetime
|
||
,@LastModifiedBy nvarchar(50)
|
||
,@Version int
|
||
,@LocalOnly bit
|
||
,@LastUsed datetime
|
||
,@LastUsedBy nvarchar(50)
|
||
,@Connection nvarchar(50)
|
||
,@Channels int
|
||
,@Position nvarchar(50)
|
||
,@ChannelTypes nvarchar(255)
|
||
,@Reprogramable bit
|
||
,@Reconfigurable bit
|
||
,@IsModule bit
|
||
,@PositionOnDistributor smallint
|
||
,@PositionOnChain smallint
|
||
,@Port smallint
|
||
,@ParentDAS nvarchar(50)
|
||
,@new_id int OUTPUT
|
||
,@errorNumber int output
|
||
,@errorMessage nvarchar(250) output
|
||
|
||
AS
|
||
BEGIN
|
||
set @errorNumber = 0
|
||
set @errorMessage = space(0)
|
||
|
||
SET NOCOUNT ON;
|
||
if(@DASId = 0)
|
||
begin
|
||
set @DASId = dbo.foo_IdGetDAS(@SerialNumber)
|
||
end
|
||
|
||
if(@DASId != 0)
|
||
begin
|
||
exec dbo.sp_DASUpdate @DASId
|
||
,@SerialNumber
|
||
,@Type
|
||
,@MaxModules
|
||
,@MaxMemory
|
||
,@MaxSampleRate
|
||
,@MinSampleRate
|
||
,@FirmwareVersion
|
||
,@CalDate
|
||
,@ProtocolVersion
|
||
,@LastModified
|
||
,@LastModifiedBy
|
||
,@Version
|
||
,@LocalOnly
|
||
,@LastUsed
|
||
,@LastUsedBy
|
||
,@Connection
|
||
,@Channels
|
||
,@Position
|
||
,@ChannelTypes
|
||
,@Reprogramable
|
||
,@Reconfigurable
|
||
,@IsModule
|
||
,@PositionOnDistributor
|
||
,@PositionOnChain
|
||
,@Port
|
||
,@ParentDAS
|
||
,@errorNumber output, @errorMessage output
|
||
|
||
end
|
||
else
|
||
begin
|
||
exec dbo.sp_DASInsert @SerialNumber
|
||
,@Type
|
||
,@MaxModules
|
||
,@MaxMemory
|
||
,@MaxSampleRate
|
||
,@MinSampleRate
|
||
,@FirmwareVersion
|
||
,@CalDate
|
||
,@ProtocolVersion
|
||
,@LastModified
|
||
,@LastModifiedBy
|
||
,@Version
|
||
,@LocalOnly
|
||
,@LastUsed
|
||
,@LastUsedBy
|
||
,@Connection
|
||
,@Channels
|
||
,@Position
|
||
,@ChannelTypes
|
||
,@Reprogramable
|
||
,@Reconfigurable
|
||
,@IsModule
|
||
,@PositionOnDistributor
|
||
,@PositionOnChain
|
||
,@Port
|
||
,@ParentDAS
|
||
,@new_id output
|
||
,@errorNumber output, @errorMessage output
|
||
set @new_id = scope_identity();
|
||
end
|
||
END
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
GO
|