Subject:Please help convert SQL query to Xquery Author:Vincent Visconti Date:12 Jan 2010 11:30 AM
Hello,
I am new to Xquery and have been trying to find some examples and/or documentation on how to represent an sql select query in xquery but for some reason I am finding it very difficult to find some solid detailed documentation on how to do this.
I have established a connection to my IBM DB2 database and have a collection defined in Xquery file as: collection("SPFPRDDTA.PRL1HDRR00")
I need to know how to write an Xquery statement that is the equivalent to this sql statement:
SELECT
TRIM(XHTAXYR) AS dXHTAXYR,
TRIM(XHPKGTYP) AS dXHPKGTYP,
TRIM(XHSLIPSRC) AS dXHSLIPSRC,
TRIM(XHTRANSNUM) AS dXHTRANSNUM,
TRIM(XHTYPE) AS dXHTYPE,
TRIM(XHTRNML1) AS dXHTRNML1,
TRIM(XHTRNML2) AS dXHTRNML2,
TRIM(XHTRADL1) AS dXHTRADL1,
TRIM(XHTRADL2) AS dXHTRADL2,
TRIM(XHTRCTY) AS dXHTRCTY,
TRIM(XHTRPROV) AS dXHTRPROV,
TRIM(XHTRPSTLCD) AS dXHTRPSTLCD,
TRIM(XHTECHCNTN) AS dXHTECHCNTN,
TRIM(XHTECHARCD) AS dXHTECHARCD,
TRIM(XHTECHTNBR) AS dXHTECHTNBR,
TRIM(XHTECHXNBR) AS dXHTECHXNBR,
TRIM(XHTECHLANG) AS dXHTECHLANG,
TRIM(XHACCTCNTN) AS dXHACCTCNTN,
TRIM(XHACCTARCD) AS dXHACCTARCD,
TRIM(XHACCTTNBR) AS dXHACCTTNBR,
TRIM(XHACCTXNBR) AS dXHACCTXNBR,
TRIM(XHACCTLANG) AS dXHACCTLANG,
TRIM(XHDEVAUTHN) AS dXHDEVAUTHN
FROM PRL1HDRR00
I know there isn't a right or wrong way of getting the result you need, and I'm hoping this will get me to where I need to be. I guess what I want to know now is if there is a better way of doing this than manually adding nodes to a target document, typing their names, and then linking the columns from my table?