Retrieving the last node value

How actually I can get the last node value from the Tamino result set? For example in xml structure below:


01
Mary


02
John


03
Peter


From the above result, i need to get the last set of node that is id:3 so that when i want to create a new prospect, the id will increment based on the last node value. Can anybody help me? If possible, tell me the method used to retrieve the last node value…
What abt the last() method?? what actually it does?? :frowning:

If you are referring to the last() method of the iterator, it will give you the last document in the result list, but there is no guarantee that this is the document with the last id.
Also this method is not very performant , if you have a lot of documents.
There is certainly am XPath (X-Query) expression, which can do what you want. However, I’m no expert on XPath. Maybe somebody else here can help?
You also might want to post your question in the
"Native XML Store & X-Query" forum.

Hi,

For an element with multiplicity, the last() function will return the last element in the array.

However, in this case, each prospect element is a different instance in Tamino, so the last() method will not help you.

If you just want the value of the highest id, you could try max(/prospect/id).

For the purposes of auto increment, you could consider writing a generic schema in Tamino which stores an ID, and some code that automatically increments it when the next sequence is requested.

Hope this helps!

Regards,
Puny Sen