Changes

Jump to navigation Jump to search
130 bytes removed ,  18:30, 12 December 2010
no edit summary
of the query object.</p>
<h2>==Usage</h2> ==
<p>The query execution works as follows:</p>
<ol start="1"> <li>#Create a new session instance with hostname, port, username and password.</li> <li>#Call the <code>query()</code> function of the session with the query as argument to get your query object.</li> <li>#Optionally bind variables to the query with the <code>bind()</code> function.</li> <li>#Initialize query output via <code>init()</code>.</li> <li>#Iterate through the query object with the <code>more()</code> and <code>next()</code> functions.If an error occurs, an exception is thrown.</li> <li>#Close the query with <code>close()</code>.</li> </ol>
<h2>==Example</h2> ==
<ol start="1"> <li>#Create a session object: <code>Session session = new Session("localhost", 1984, "admin", "admin");</code></li> <li>#Define a query and create a query object:<br/> <codepre class="brush:java">String q = "declare variable $name external; " + "for $i in 1 to 10 return element { $name } { $i }";Query query = session.query(q);</code></lipre> <li>#Call the bind method of your query object:<br/> <codepre class="brush:java">query.bind("$name", "Number");</code></lipre> <li>#Call the init method of your query object:<br/> <code<pre class="brush:java">print query.init();</code></lipre> <li>#Iterate through the query object:<br/> <codepre class="brush:java">while(query.more()) print query.next();</code></lipre> <li>#Close your query object:<br/> <codepre class="brush:java">print query.close();</code></lipre> </ol>[[Category:Wikify]]
bueraucrat, Bureaucrats, editor, reviewer, Administrators
907

edits

Navigation menu