Learn XQuery |
Home:Learn XQuery: XQuery Tips and Tricks:Numbering Records Is there a way to number records extracted from a database?I need to extract data from my relational database as XML, and I need to assign a number to each record that I extract. I wrote the following XQuery... <myRecords> { ... I don't get the result I expected: <myRecords> … The record number isn't incremented. Why? XQuery is a functional language without side effects — you can't really create a notion of state in XQuery as you might in Java or C#, for example. In some cases, you can simulate state using a recursive function, but to solve this problem there is a much simpler solution: you can use a positional variable. Here's the XQuery: <myRecords> { And here's the (hoped-for) result: <myRecords> … Next Question! Can I use |
Submit Your DataDirect XQuery Tip or TrickTell us your XQuery Tip or Trick – if it gets published on our site, you’ll receive a |





