Files
DP44/DataPRO_sql/dbo.foo_DBExportGroupTemplateChannel.UserDefinedFunction.sql

113 lines
7.4 KiB
MySQL
Raw Normal View History

2026-04-17 14:55:32 -04:00
<EFBFBD><EFBFBD>IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[foo_DBExportGroupTemplateChannel]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[foo_DBExportGroupTemplateChannel]
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].[foo_DBExportGroupTemplateChannel]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN
execute dbo.sp_executesql @statement = N'CREATE FUNCTION [dbo].[foo_DBExportGroupTemplateChannel]
(
@TemplateId int
)
RETURNS xml
AS
BEGIN
RETURN isnull((
SELECT TemplateChannel.[TestObjectNumber]
,TemplateChannel.[TemplateChannelId]
,TemplateChannel.[NameOfTheChannel]
,TemplateChannel.[LaboratoryChannelCode]
,TemplateChannel.[CustomerChannelCode]
,TemplateChannel.[Comments1]
,TemplateChannel.[Location]
,TemplateChannel.[Dimension]
,TemplateChannel.[Direction]
,TemplateChannel.[ChannelFrequencyClass]
,TemplateChannel.[Unit]
,TemplateChannel.[ReferenceSystem]
,TemplateChannel.[TransducerType]
,TemplateChannel.[TransducerId]
,TemplateChannel.[PreFilterType]
,TemplateChannel.[CutOffFrequency]
,TemplateChannel.[ChannelAmplitudeClass]
,TemplateChannel.[ReferenceChannel]
,TemplateChannel.[ReferenceChannelName]
,TemplateChannel.[DataSource]
,TemplateChannel.[DataStatus]
,TemplateChannel.[SamplingInterval]
,TemplateChannel.[BitResolution]
,TemplateChannel.[TimeOfFirstSample]
,TemplateChannel.[NumberOfSamples]
,TemplateChannel.[OffsetPostTest]
,TemplateChannel.[TransducerNaturalFrequency]
,TemplateChannel.[TransducerDampingRatio]
,TemplateChannel.[Comments]
,TemplateChannel.[FirstGlobalMaximumValue]
,TemplateChannel.[TimeOfMaximumValue]
,TemplateChannel.[FirstGlobalMinimumValue]
,TemplateChannel.[TimeOfMinimumValue]
,TemplateChannel.[StartOffsetInterval]
,TemplateChannel.[EndOffsetInterval]
,TemplateChannel.[Required]
,TemplateChannel.[MMEChannelId]
,TemplateChannel.[MMEChannelType]
,TemplateChannel.[Template]
,TemplateChannel.[TemplateId]
,TemplateChannel.[DisplayOrder]
,TemplateChannel.[LocalOnly]
from
(SELECT tch.[TestObjectNumber]
,tch.[TemplateChannelId]
,tch.[NameOfTheChannel]
,tch.[LaboratoryChannelCode]
,tch.[CustomerChannelCode]
,tch.[Comments1]
,tch.[Location]
,tch.[Dimension]
,tch.[Direction]
,tch.[ChannelFrequencyClass]
,tch.[Unit]
,tch.[ReferenceSystem]
,tch.[TransducerType]
,tch.[TransducerId]
,tch.[PreFilterType]
,tch.[CutOffFrequency]
,tch.[ChannelAmplitudeClass]
,tch.[ReferenceChannel]
,tch.[ReferenceChannelName]
,tch.[DataSource]
,tch.[DataStatus]
,tch.[SamplingInterval]
,tch.[BitResolution]
,tch.[TimeOfFirstSample]
,tch.[NumberOfSamples]
,tch.[OffsetPostTest]
,tch.[TransducerNaturalFrequency]
,tch.[TransducerDampingRatio]
,tch.[Comments]
,tch.[FirstGlobalMaximumValue]
,tch.[TimeOfMaximumValue]
,tch.[FirstGlobalMinimumValue]
,tch.[TimeOfMinimumValue]
,tch.[StartOffsetInterval]
,tch.[EndOffsetInterval]
,tch.[Required]
,tch.[MMEChannelId]
,tch.[MMEChannelType]
,tot.TemplateName as [Template]
,tot.TemplateId as [TemplateId]
,tch.[DisplayOrder]
,tch.[LocalOnly]
FROM [dbo].[TemplateChannels] tch
inner join [dbo].[TestObjectTemplates] tot on tot.TemplateId = tch.TemplateId
where tch.TemplateId = @TemplateId) TemplateChannel
for xml auto, BINARY BASE64, root (''TemplateChannels'')), ''<TemplateChannels />'')
END
'
END
GO