import oracle.xml.xsql.*; import org.w3c.dom.Node; public class Sequence extends XSQLActionHandlerImpl { public void handleAction( Node root ) { // Get the value of the name attribute String seqname = this.getAttributeAllowingParam("name",getActionElement()); // Report an error if the attribute is missing since it's required if (seqname == null || seqname.equals("")) { reportMissingAttribute(root,"name"); return; } // Build a select statement to retrieve the next value from the sequence String query = "select "+seqname+".nextval from dual"; // Retrieve the value of the first column of the first row of the result String nextval = this.firstColumnOfFirstRow(root,query); if (nextval != null) { // Add a <NextValue> element to the page with the new sequence number addResultElement(root,"NextValue",nextval); } } } |