Files
DP44/DataPRO/Modules/Database/DatabaseMigrationScripts/.svn/pristine/f3/f347fa008aa4e3f9531933c71e233e6030322269.svn-base

123 lines
2.9 KiB
Plaintext
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
ALTER PROCEDURE [dbo].[sp_DASInsert]
@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)
,@FirstUseDate datetime null
,@GroupId int null
,@TestId int null
,@StandIn bit null
,@MaxAAFRate decimal(18,0)
,@new_id int OUTPUT
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0
set @errorMessage = space(0)
SET NOCOUNT ON;
if(@SerialNumber is null)
begin
RAISERROR(15600,-1,-1, 'sp_DASInsert') /* Error 1560 - An invalid parameter or option was specified for procedure*/
end
else
begin
if EXISTS ( SELECT 1 FROM [DAS] WHERE [SerialNumber]=@SerialNumber)
BEGIN
SET @errorNumber = 1505
SET @errorMessage = N'Duplicate SerialNumber'
END
ELSE
BEGIN
INSERT INTO [dbo].[DAS]
([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]
,[FirstUseDate]
,[TestId]
,[GroupId]
,[StandIn]
,[MaxAAFRate])
VALUES
( @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
,@FirstUseDate
,@TestId
,@GroupId
,@StandIn
,@MaxAAFRate)
set @new_id = scope_identity();
END
end
END