XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Issue with Processing Instruct... (2)
-> + problem converting json to XML... (2)
-> + Problem base64 decoding string... (3)
-> + Problems posting multipart for... (5)
-> + trouble with download of price... (2)
-> + Problem with http-post not bei... (3)
-> + path problem, xps_file:writeAl... (9)
-> + Xquery update support? (2)
-> + problem with Stylus studio try... (5)
-> + adding dtd reference to xml ou... (4)
-> + xquery escaping ambarsand when... (3)
-> + Whitespace problem when return... (5)
-> + Problem with namespace prefix ... (5)
-> - Sending via SFTP returns unexp... (1)
-> + Query and Sftp clent (4)
-> + xquery and try - catch (3)
-> + Query + ddtek:http-post optio... (5)
-> + Example files referenced in do... (3)
-> + Automatic Error Detection and ... (3)
-> + Working with result of ddtek:h... (2)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Amy GordonSubject: Converting SQL query to XQuery
Author: Amy Gordon
Date: 15 Aug 2005 11:11 PM
Hi everyone!
I'm trying to convert an SQL query into XQuery format (we're viewing the relational database in an XML view). I've had a look at the XQuery tutorials but how to replicate an inner join is confusing me.

The query is as follows:

SELECT ACTIVITIES_ITS_VESSEL.Activity_Num­ ber, VESSELSDATASHEET.Equipment_No, VESSELSDATASHEET.Function_Loc,
SCHEDULE_ITS_VESSEL.DateScheduled,­ ACTIVITIES_ITS_VESSEL.Inspection_T­ ask
FROM ACTIVITIES_ITS_VESSEL INNER JOIN
VESSELSDATASHEET ON ACTIVITIES_ITS_VESSEL.Vessel_Equip­ ment_ID = VESSELSDATASHEET.Vessel_Equipment_­ ID INNER JOIN
SCHEDULE_ITS_VESSEL ON ACTIVITIES_ITS_VESSEL.Vessel_Equip­ ment_ID = SCHEDULE_ITS_VESSEL.Vessel_Equipme­ nt_ID AND
ACTIVITIES_ITS_VESSEL.Activity_Num­ ber = SCHEDULE_ITS_VESSEL.Activity_Numbe­ r

And the XQuery code I have so far is:
<query>
{

for $act doc("database.xml") /DATABASE/ACTIVITIES_ITS_VESSEL
$vds doc("database.xml) DATABASE//VESSELSDATASHEET
$sch doc("database.xml) /DATABASE/SCHEDULE_ITS_VESSEL

where $act/Vessel_Equipment_ID = $vds/Vessel_Equipment_ID
and $act/Vessel_Equipment_ID = $sch/Vessel_Equipment_ID
and $act/Activity_Number = $sch/Activity_Number

return
<record>


</record>
}
</query>

However I'm not sure what to put in the return section to emulate the inner join.

Any help would be appreciated.
Thanks!

Postnext
(Deleted User) Subject: Converting SQL query to XQuery
Author: (Deleted User)
Date: 22 Aug 2005 04:06 AM
Hi Amy,

>The query is as follows:
>
>SELECT ACTIVITIES_ITS_VESSEL.Activity_Number,
>VESSELSDATASHEET.Equipment_No,
>VESSELSDATASHEET.Function_Loc,
>SCHEDULE_ITS_VESSEL.DateScheduled,­
>ACTIVITIES_ITS_VESSEL.Inspection_Task

Given these columns, you need this "return" statement:

return
<record>
{$act/Activity_Number}
{$vds/Equipment_No}
{$vds/Function_Loc}
{$sch/DateScheduled}
{$act/Inspection_Task}
</record>

Hope this helps,
Alberto

Postnext
Amy GordonSubject: Converting SQL query to XQuery
Author: Amy Gordon
Date: 22 Aug 2005 09:29 PM
Thanks!
I assume that includes the inner joins that were present in the SQL statement?

Posttop
(Deleted User) Subject: Re: Converting SQL query to XQuery
Author: (Deleted User)
Date: 25 Aug 2005 05:42 AM
Hi Amy,

>I assume that includes the inner joins that were present in the SQL statement?

Yes, the behavior of a FLWOR loop on multiple variables with a
"where" condition testing all of them is the same of a INNER JOIN
statement (i.e. the "return" expression will be evaluated only if all
the IDs match)

Hope this helps,
Alberto


   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.