<%@ page import="java.util.StringTokenizer" %>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/sqltaglib.tld" prefix="sql" %>
<%! String dataSrcStr, searchCondition, left, right, operator, newCondition; %>
<HTML>
<HEAD> <TITLE> Nested Tag with Query inside Open  </TITLE> </HEAD>
<BODY BGCOLOR=white>

<% if (dataSrcStr == null) { %>
<%@ include file="checkDataSource.jsp" %>

<% } 
searchCondition = request.getParameter("cond");
if (searchCondition != null && verifyCondition(searchCondition)) { 
       pageContext.setAttribute(left, right); %>
       <H3> Search results for : <I> <%= searchCondition %> </I> </H3>
       <HR><BR>
<% } else if (searchCondition != null) { 
            searchCondition = ""; %>
            <h2>Invalid search condition </h2>
<%        }
     else searchCondition = "";
%>

<B>Enter <a href="../conditionHelp.html">search condition</a>:</B>

<FORM METHOD=get>
<INPUT TYPE="text" NAME="cond" SIZE=30>
<INPUT TYPE="submit" VALUE="Ask Oracle");
</FORM>
<HR>

<% if (searchCondition.equals("") || right.equalsIgnoreCase("null")) { %>
<sql:dbOpen dataSource="<%= dataSrcStr %>">
    <sql:dbQuery>
       SELECT ename, sal FROM scott.emp 
       <%=newCondition%>
       order by ename
    </sql:dbQuery>
</sql:dbOpen>
<% } else { %> 
<sql:dbOpen dataSource="<%= dataSrcStr %>" >
    <sql:dbQuery bindParams='<%=left%>'>
       SELECT ename, sal FROM scott.emp 
       <%=newCondition%> 
       order by ename
    </sql:dbQuery>
</sql:dbOpen>
<% } %>

<% searchCondition=null;
   newCondition=null; %>
</HR> 
</BODY> 
</HTML> 
<%@ include file="../verifyCondition.jsp" %>
