<!--
 * BIDrillOutRelationalPopup.jsp
 *
 * Copyright © 1994-2004, Oracle. All rights reserved. Oracle grants
 * you ("Licensee") a non-exclusive, royalty-free, worldwide license to use,
 * modify and redistribute this software in source and binary code form, provided
 * that (i) this copyright notice and license appear on all copies of the
 * software; (ii) Licensee does not utilize the software in a manner disparaging
 * to Oracle; and (iii) Licensee does not utilize the software in a manner that
 * violates the terms of any Licensee agreement with Oracle.
 -->
<%@page contentType="text/html;charset=windows-1252" %>
<%@page import="java.sql.*" %>
<%@page import="oracle.jdbc.*" %>

<%-- Constants for connection information --%>
<%-- Change this information to point to your relational database instance --%>
<%! public static final String HOST_NAME    = "atsqesun1"; %> 
<%! public static final String PORT_NUMBER  = "1521"; %>
<%! public static final String SID          = "ora925"; %>
<%! public static final String USER_NAME    = "CS_OLAP"; %>
<%! public static final String PASSWORD     = "CS_OLAP"; %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=windows-1252">
<title>Sales Revenue, Costs and Quantity Detail</title>
<link href="css/jdeveloper.css" rel="stylesheet" media="screen"/>
</head>
<body>

<% 
  // Get the Product and Geography members from the URL 
  String product = request.getParameter("PRODUCT");
  String geography = request.getParameter("GEOGRAPHY");
  String productLabel = request.getParameter("PRODUCT_LABEL");
  String geographyLabel = request.getParameter("GEOGRAPHY_LABEL");
%>
<h2>Facts for Geography: <%=geographyLabel %>, Product: <%=productLabel %></h2>
<table border="1" cellspacing="0" cellpadding="0">
	
    <tr>
		<td>
		  <b>Sales</b>
		</td>
		<td>
		  <b>Costs</b>
		</td>
		<td>
		  <b>Quantity</b>
		</td>
	</tr>
<%
  if (product != null && geography != null)
  {
 
    // Change the following SQL statement to work against your data
    String sqlQuery = "select amount_sold, quantity_sold, costs from cs_o_shaw_shawsale14view " +
                     " where shawgeographies_et='" + geography + 
                     "' and shawproducts_et='" + product +
                     "' and amount_sold > 0 and quantity_sold > 0 and costs > 0";

    // Change the following connection string to work against your instance
    String _connStr =  "jdbc:oracle:thin:@" +
                          "(DESCRIPTION=(ADDRESS=(HOST=" + HOST_NAME + ")"+
                          "(PROTOCOL=tcp)"+
                          "(PORT=" + PORT_NUMBER + "))"+
                          "(CONNECT_DATA=(SID=" + SID + ")))";

    // Connect to the Database
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    OracleConnection _conn = (OracleConnection)DriverManager.getConnection(_connStr, USER_NAME, PASSWORD);
    Statement _s = _conn.createStatement();
    ResultSet _rs = _s.executeQuery(sqlQuery);

    System.out.println(sqlQuery);

    // Get the information from the JDBC result set
    while (_rs.next()) {
        out.println("<tr>");
        out.println("<td align=\"right\">" + "$" + _rs.getObject("Amount_sold") + "</td>");
        out.println("<td align=\"right\">" + "$" + _rs.getObject("Costs") + "</td>");
        out.println("<td align=\"right\">"  + _rs.getObject("Quantity_sold") + "</td>");
        out.println("</tr>");
    }

    _rs.close();
    _s.close();
    _conn.close(); 
}
%>
</table>

</body>
</html>

