Problems with getLastModified() function

Hi!

in my new application I want to store a spezial Index of several values that are calculated from Elements in a Document. To keep the consistency with the Document, I want to check, if the Document was changed since the Index was stored.
Therefor I want to store the creation-time of the Index und compare it with the lastModified-Date of the Document.

I tried the following X-Query:


declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"

for $a in input()/Gebaeude
where $a/@grundstueck_id="5"

return tf:getLastModified($a)

But I always get the following Error-Message:


 <?xml version="1.0" encoding="windows-1252" ?> 
- <ino:response xmlns:ino="http://namespaces.softwareag.com/tamino/response2" xmlns:xql="http://metalab.unc.edu/xql/">
- <xq:query xmlns:xq="http://namespaces.softwareag.com/tamino/XQuery/result">
- <![CDATA[ 
declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"

for $a in input()/Gebaeude
where $a/@grundstueck_id="5"

return tf:getLastModified($a)

  ]]> 
  </xq:query>
- <ino:message ino:returnvalue="0">
  <ino:messageline>XQuery Request processing</ino:messageline> 
  </ino:message>
  <xq:result xmlns:xq="http://namespaces.softwareag.com/tamino/XQuery/result" /> 
- <ino:message ino:returnvalue="6301">
  <ino:messagetext ino:code="INOXQE6301">Runtime type exception</ino:messagetext> 
  </ino:message>
  </ino:response>

I’m sure, you’ve got a solution for me.

Thanks!

I tried to run the X-Query in a small Java-App. See the code:


try {
			TaminoClient tc = new TaminoClient("http://localhost/tamino/BSDB30032005");
			tc.setSAXimplementer("com.jclark.xml.sax.Driver");
			String query = "Gewichtungsfaktoren[@ino:id='1']";
			TaminoResult tr = tc.query(query, "Hessen");
			System.err.println(tr.getInoId());
			System.err.println("Last: "+tr.getLastModified().toString());
		} catch (TaminoError e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

I always get the following output:


null
Last: Thu Jan 01 01:00:00 CET 1970

For me, it seems as if the program doesn’t get any documents from the database. But I don’t understand why?

Hi,

the error is probably that tf:getLastModified can only be applied on document node, i.e. try the following:

declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction

for $a in input()/Gebaeude
where $a/@grundstueck_id=“5”

return tf:getLastModified(root($a))

But you might consider using a trigger to keep your “index” up to date.

Regards

Harald

This doesn’t work either.

Can you tell me something more about a trigger. I’ve never heard anything about it before.

Ok, it works now in the Interactive Interface. I had an Error in the Where-clause.

The correct code looks like this:


declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"

for $a in input()/Gebaeude[@grundstueck_id = 5]

return <time>{tf:getLastModified(root($a))}</time>

Can you tell me, how I implement the “root($a)”-part in Java?

Thanks!

Tamino schema editor allows you to bind an action to a node, where the action is called whenever the node is inserted, modified or deleted (onInsert, onUpdate, onDelete). The action is a server extension that you can write in Java or another supported programming language and install in the database (see section on Server Extensions in the documentation)