<%@ VERSION="0.92" %>
<%@ LANGUAGE="javascript" %>

<%@ IMPORT="util.es" %>

<SCRIPT RUNAT="server">
  var connection = "demo";
  var title = "*** Emp & Dept Productions ***";
</SCRIPT>

<%
  var sqlStatement = "SELECT * FROM dept ORDER BY deptno";

  var depts = sqlRowSet(page.connection, sqlStatement);

  if (depts == null)
  {
    showErrorPage("Database Error", dbError);
    return;
  }
%>

<HTML>
<HEAD>
  <TITLE>Department List</TITLE>
</HEAD>
<BODY BGCOLOR="#fcefc4">
  <CENTER>
  <H1><%= page.title %></H1>

  <BR>
  <TABLE BORDER="1">
    <CAPTION>
      <STRONG>Department List<STRONG><HR>
    </CAPTION>
    <TR>
      <TH>Deptno</TH>
      <TH>Dname</TH>
      <TH>Loc</TH>
    </TR>
    <%
      for (var i = 0; i < depts.length; i++)
      {
        %>
	  <TR>
	    <TD ALIGN="right">
	      <A HREF="<%= "emp.jsp?deptno=" + escape(depts[i].deptno) %>">
	        <%= depts[i].deptno %>
              </A>
	    </TD>
	    <TD><%= depts[i].dname %></TD>
	    <TD><%= depts[i].loc %></TD>
	  </TR>
	<%
      }
    %>
  </TABLE>
  </CENTER>
</BODY>
</HTML>
