Learn XQuery |
Home:Learn XQuery:White Papers:Generating SQL:Relaxing XQuery Semantics Relaxing XQuery SemanticsWhen translating XQuery to SQL, DataDirect XQuery® is careful to preserve XQuery semantics, even if this complicates the generated SQL. For example, unlike XQuery string comparison, SQL character comparison is not sensitive to differences in trailing spaces. To accommodate this semantic difference, the SQL statements that DataDirect XQuery® executes compare both the strings and the length of the strings. Example 18. String Comparison and Trailing Spaces (XQuery Semantics)XQuery for $u in collection('USERS')/USERS
SQL SELECT ALL Note the additional comparison on the string length, which is needed to fully conform to the XQuery specification. But in most cases VARCHAR columns don't have trailing spaces, and trailing spaces in a CHAR column are not significant. Using a declaration option, you can instruct DataDirect XQuery® to ignore the trailing spaces for character comparisons, which corresponds to the semantics of SQL string comparisons, and thus simplifies the generated SQL. Example 19. String Comparison and Trailing Spaces (Ignoring Trailing Spaces)XQuery declare option ddtek:sql-options "ignore-trailing-spaces=yes"; SQL SELECT ALL The DataDirect XQuery® User's Guide lists more declaration options that can be used to simplify the generated SQL. |
Try DataDirect XQuery® Free!Put the power, scalability, and performance of DataDirect XQuery® to work for you today! Our free trial lets you see for yourself how easy it is to build data integration applications that access relational, EDI, and other file formats as XML! Online Video Tutorials!Our easy-to-follow online video tutorials are a great way to get acquainted with the many features of DataDirect XQuery®. And if you like what you see, download a free copy today and try DataDirect XQuery® for yourself! Stay Informed!XQuery is one of the hottest XML technologies being developed today. Stay informed with vital news about standards, tools, and trends by signing up for the DataDirect XQuery® newsletter. |





