Академический Документы
Профессиональный Документы
Культура Документы
pr_custom_pwc_conference_mtm_fetchdata_test
AS
BEGIN
DECLARE @co_line_of_service INT
SELECT @co_line_of_service=field_id from lo_custom_field where
tag='US_CO_LINE_OF_SERVICE'
SELECT
src as '@src',
[Date] as '@date',
(
SELECT
xid,
name,
internal
FROM [SQLREWR].__Integration_PWC_US__outbound_vendor as vendor
FOR XML AUTO, ROOT ('vendors'), TYPE
),
(
SELECT
email,
lname,
fname,
xid
FROM [SQLREWR].__Integration_PWC_US__outbound_instructor as instructor
FOR XML AUTO, ROOT ('instructors'), TYPE
),
(
SELECT
xid,
ol,
descr AS [desc],
name
FROM [SQLREWR].__Integration_PWC_US__outbound_course as course
FOR XML AUTO, ROOT ('courses'), TYPE
),
(
SELECT
xid,
name,
[to]
FROM [SQLREWR].__Integration_PWC_US__outbound_location as location
FOR XML AUTO, ROOT ('locations'), TYPE
),
(
SELECT
(
select conference.conf_id AS '@xid',
conference.descr AS '@desc',
conference.name AS '@name',
(
SELECT
conferenceanchora.xid AS '@xid',
conferenceanchora.xvendor AS '@xvendor',
--lp.provider_name AS '@xvendor',
conferenceanchora.classname AS '@classname',
conferenceanchora.xloc AS '@xloc',
CONVERT(VARCHAR(10),conferenceanchora.ed,101) AS '@ed',
CONVERT(VARCHAR(10),conferenceanchora.sd,101) AS '@sd',
(
SELECT
classInstructor.xid AS '@xid'
FROM [SQLREWR].__Integration_PWC_US_ValidSesn_Conference e
--on conf.conf_id=e.conf_id
inner join [SQLREWR].__Integration_PWC_US__outbound_class
conferenceanchor on e.session_id=conferenceanchor.classxid
inner join
[SQLREWR].__Integration_PWC_US__outbound_classInstructor classInstructor on
conferenceanchor.classxid=classInstructor.classxid
WHERE e.conf_id=conference.conf_id
FOR XML PATH ('classInstructor'), TYPE
),
(
SELECT
'true' as '@email',
LTRIM(RTRIM(title)) as '@sid'
FROM (
SELECT DISTINCT
title --as 'sid'
FROM
[SQLREWR].__Integration_PWC_US__outbound_survey survey
INNER JOIN
[SQLREWR].__Integration_PWC_US_ValidSesn_Conference e on
survey.object_id=e.session_id
WHERE ISNULL(title,'')<>'' and
e.conf_id=conference.conf_id and survey.flag=1
UNION ALL
SELECT DISTINCT
title1-- as 'sid'
FROM
[SQLREWR].__Integration_PWC_US__outbound_survey survey
INNER JOIN
[SQLREWR].__Integration_PWC_US_ValidSesn_Conference e on
survey.object_id=e.session_id
WHERE ISNULL(title1,'')<>'' and
e.conf_id=conference.conf_id and survey.flag=1
UNION ALL
SELECT DISTINCT
title2 --as 'sid'
FROM
[SQLREWR].__Integration_PWC_US__outbound_survey survey
INNER JOIN
[SQLREWR].__Integration_PWC_US_ValidSesn_Conference e on
survey.object_id=e.session_id
WHERE ISNULL(title2,'')<>'' and
e.conf_id=conference.conf_id and survey.flag=1
UNION ALL
SELECT DISTINCT
title3 --as 'sid'
FROM
[SQLREWR].__Integration_PWC_US__outbound_survey survey
INNER JOIN
[SQLREWR].__Integration_PWC_US_ValidSesn_Conference e on
survey.object_id=e.session_id
WHERE ISNULL(title3,'')<>'' and
e.conf_id=conference.conf_id and survey.flag=1
) survey
FOR XML PATH ('survey'), TYPE
),
(
SELECT
student.email AS '@email',
student.xid AS '@xid',
student.cancel AS '@cancel',
student.jt AS '@jt',
student.lastname AS '@lastname',
student.firstname AS '@firstname',
(
SELECT
xid as '@xid',
value as '@value',
qid as '@qid'
FROM
[SQLREWR].__Integration_PWC_US__outbound_sdata sdata
where sdata.user_id=student.user_id and
ISNULL(xid,'')<>''
FOR XML PATH ('sdata'), TYPE
)
FROM
[SQLREWR].__Integration_PWC_US__outbound_studenthelper student
WHERE student.conf_id=conference.conf_id
FOR XML PATH ('student'), TYPE
)
)
FROM [SQLREWR].__Integration_PWC_US__outbound_import o
FOR XML PATH('import'), TYPE
END