我有6个表,要从中创建XML输出。它们需要按照1,2,2,3,4,2的顺序嵌套(患者,转诊,转诊类型,约会,活动,患者的GP)是否可以使用XML AUTO ELEMENTS?我已经使用XML EXPLICIT完成了此操作,但是AUTO是首选方法,因为我们在使用显式表和NULL值时遇到了麻烦。 使用的表是:
CREATE TABLE Header (ReportStartDate varchar(800), ExtractDate varchar(800))
CREATE TABLE Patient (PatientID varchar(800), DateOfBirth varchar(800))
CREATE TABLE Referral (ReferralID varchar(800), PatientID varchar(800))
CREATE TABLE Appointment (AppointmentID varchar(800), ReferralID varchar(800))
CREATE TABLE Activity (ActivityID varchar(800),AppointmentID varchar(800))
CREATE TABLE MedHistory (MedHistoryID varchar(800), ActivityID varchar(800))
CREATE TABLE Gp (GpID varchar(800), PatientID varchar(800))
CREATE TABLE StaffHistory (StaffHistoryID varchar(800))
表格必须按此顺序排列。页眉是一个根表,病人,转诊,约会和活动是嵌套的。 MedHistory嵌套在活动级别,GP Inside Patient和患者历史记录的末尾,而不是嵌套的。这可能吗? 抱歉-这是我需要的输出:
<Header>
<ReportStartDate>2017-02-02</ReportStartDate>
<ExtractDate>2018-08-16</ExtractDate>
<Patient>
<PatientID>123456</PatientID>
<DateOfBirth>1984-11-15</DateOfBirth>
<Referral>
<ReferralID>ABC</ReferralID>
<PatientID>123456</PatientID>
<Appointment>
<AppointmentID>XYZ</AppointmentID>
<ReferralID>ABC</ReferralID>
<Activity>
<ActivityID>MNL</ActivityID>
<AppointmentID>XYZ</AppointmentID>
/Activity
<MedHistory>
<MedHistoryID>789</MedHistoryID>
<ActivityID>MNL</ActivityID>
</MedHistory>
</Appointment>
</Referral>
<Gp>
<GpID>654</GpID>
<PatientID>123456>
</Gp>
</Patient>
<Patient>
<PatientID>Z765883</PatientID>
<DateOfBirth>1952-02-06</DateOfBirth>
<Referral>
<ReferralID>N66</ReferralID>
<PatientID>Z765883</PatientID>
<Appointment>
<AppointmentID>479</AppointmentID>
<ReferralID>N66</ReferralID>
<Activity>
<ActivityID>G33</ActivityID>
<AppointmentID>479</AppointmentID>
/Activity
<MedHistory>
<MedHistoryID>F45</MedHistoryID>
<ActivityID>G33</ActivityID>
</MedHistory>
</Appointment>
</Referral>
<Gp>
<GpID>PGF</GpID>
<PatientID>Z765883>
</Gp>
</Patient>
<StaffHistory>
<StaffHistoryID>JHI</StaffHistoryID>
</Header>