BradR
2007-04-05 16:21:44 UTC
I'm trying to return the following:
<person>
<personal_info>
...
</personal_info>
<prof_quals>
...
</prof_quals>
</person>
The following results in an error:
XQuery [#xPerson.xPerson.modify()]: Top-level attribute nodes are not
supported
DECLARE @xPerson XML
SET @xPerson = (
SELECT first_name,middle_name,last_name,maiden_name,
LTRIM(RTRIM(addr_1+' '+addr_2+' '+addr_3+' '+addr_4)) address_line,
city municipality,
isnull(state_code,province_code) region,postal_code,
country_code,'PC' passport_code,
'652-78-9658' social_security_num,
isnull(birth_month,'00')+'/'+isnull(birth_day,'00')
+'/'+isnull(birth_year,'0000') birth_date,
gender
FROM peo_master_vw c
JOIN peo_address d ON c.person_id = d.person_id
WHERE c.person_id = 8008723 AND
d.addr_key = 1
FOR XML path('personal_info'), root('person'),type)
SELECT @xPerson xPerson INTO #xPerson
DECLARE @xProfQuals XML
SET @xProfQuals =
(SELECT isnull(lic_no,cert_code) license_number,
'Unknown' licensing_agency,
'XX' state_issued,
cert_year start_date,
NULL end_date FROM peo_prof_quals
WHERE person_id = 8008723
FOR XML path('prof_quals'),type)
SELECT @xProfQuals
UPDATE #xPerson SET xPerson.modify('
insert @xProfQuals
after (//*/personal_info)')
<person>
<personal_info>
...
</personal_info>
<prof_quals>
...
</prof_quals>
</person>
The following results in an error:
XQuery [#xPerson.xPerson.modify()]: Top-level attribute nodes are not
supported
DECLARE @xPerson XML
SET @xPerson = (
SELECT first_name,middle_name,last_name,maiden_name,
LTRIM(RTRIM(addr_1+' '+addr_2+' '+addr_3+' '+addr_4)) address_line,
city municipality,
isnull(state_code,province_code) region,postal_code,
country_code,'PC' passport_code,
'652-78-9658' social_security_num,
isnull(birth_month,'00')+'/'+isnull(birth_day,'00')
+'/'+isnull(birth_year,'0000') birth_date,
gender
FROM peo_master_vw c
JOIN peo_address d ON c.person_id = d.person_id
WHERE c.person_id = 8008723 AND
d.addr_key = 1
FOR XML path('personal_info'), root('person'),type)
SELECT @xPerson xPerson INTO #xPerson
DECLARE @xProfQuals XML
SET @xProfQuals =
(SELECT isnull(lic_no,cert_code) license_number,
'Unknown' licensing_agency,
'XX' state_issued,
cert_year start_date,
NULL end_date FROM peo_prof_quals
WHERE person_id = 8008723
FOR XML path('prof_quals'),type)
SELECT @xProfQuals
UPDATE #xPerson SET xPerson.modify('
insert @xProfQuals
after (//*/personal_info)')