<%@page contentType="text/xml" import="Examples, java.sql.*, oracle.xml.sql.query.*" %><% Connection cn = Examples.getConnection(); // Retrieve airport code to be found from the "find" URL parameter String code = request.getParameter("find"); // SQL Statement to search table of all known airports // Uses an Oracle8i Functional Index on UPPER(Description) String qry = "SELECT tla as \"Code\", description as \"Name\""+ " FROM airport "+ " WHERE tla = UPPER('" + code + "')"+ " OR UPPER(description) LIKE UPPER('%"+ code + "%')"+ " ORDER BY UPPER(description)"; // Create an OracleXMLQuery object OracleXMLQuery oxq = new OracleXMLQuery(cn, qry); // Retrieve only the first four matches oxq.setMaxRows(4); // Use <AirportList> as document element for Rowset oxq.setRowsetTag("AirportList"); // Use <Airport> for each row in the result oxq.setRowTag("Airport"); // Get the XML Results as a String as write to the output stream out.println(oxq.getXMLString()); cn.close(); %> |