Returning sql statement instead of values from database

hi am reading value from database but my problem is am get sql statement values instead of values in database
my code is
java:337)

There is no doubt: you get what you want:
    return s_getValue;
bye
TPD

Similar Messages

  • Unable to access values from database in login page..

    Hey all,
    Friends I have a login.jsp page and I want if i enter username and password then it will be accessed from database and after verifying the details it will open main.jsp.I made a database as "abc" and created DSN as 1st_login having table 1st_login. But the problem is that I am unable to access values from database.
    So Please help me.
    Following is my code:
    <HTML>
    <body background="a.jpg">
    <marquee>
                        <CENTER><font size="5" face="times" color="#993300"><b>Welcome to the"<U><I>XYZ</I></U>" of ABC</font></b></CENTER></marquee>
              <br>
              <br>
              <br>
              <br><br>
              <br>
         <form name="login_form">
              <CENTER><font size="4" face="times new roman">
    Username          
              <input name="username" type="text" class="inputbox" alt="username" size="20"  />
              <br>
         <br>
              Password          
              <input type="password" name="pwd" class="inputbox" size="20" alt="password" />
              <br/>
              <input type="hidden" name="option" value="login" />
              <br>
              <input type="SUBMIT" name="SUBMIT" class="button" value="Submit" onClick="return check();"> </CENTER>
              </td>
         </tr>
         <tr>
              <td>
              </form>
              </table>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection connection = DriverManager.getConnection("jdbc:odbc:1st_login");
    Statement statement = connection.createStatement();
    String query = "SELECT username, password FROM 1st_login WHERE username='";
    query += request.getParameter("username") + "' AND password='";
    query += request.getParameter("password") + "';";
    ResultSet resSum = statement.executeQuery(query);
    //change: you gotta move the pointer to the first row of the result set.
    resSum.next();
    if (request.getParameter("username").equalsIgnoreCase(resSum.getString("username")) && request.getParameter("password").equalsIgnoreCase(resSum.getString("password")))
    %>
    //now it must connected to next page..
    <%
    else
    %>
    <h2>You better check your username and password!</h2>
    <%
    }catch (SQLException ex ){
    System.err.println( ex);
    }catch (Exception er){
    er.printStackTrace();
    %>
    <input type="hidden" name="op2" value="login" />
         <input type="hidden" name="lang" value="english" />
         <input type="hidden" name="return" value="/" />
         <input type="hidden" name="message" value="0" />
         <br>
              <br><br>
              <br><br>
              <br><br><br><br><br>
              <font size="2" face="arial" color="#993300">
         <p align="center"> <B>ABC &copy; PQR</B>
    </BODY>
    </HTML>
    and in this code i am getting following error
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:93: cannot find symbol_
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:93: cannot find symbol_
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:94: cannot find symbol_
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:95: cannot find symbol_
    4 errors
    C:\Project\SRS\nbproject\build-impl.xml:360: The following error occurred while executing this line:
    C:\Project\SRS\nbproject\build-impl.xml:142: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 6 seconds)

    As long as you're unable to compile Java code, please use the 'New to Java' forum. This is really trival.
    To ease writing, debugging and maintenance, I highly recommend you to write Java code in Java classes rather than JSP files. Start learning Servlets.

  • How to get string value from database table using Visual Studio 2005?

    Hi,
    Im developing plugin in illustrator cs3 using visual studio 2005. I need to get the values eneterd in database. Im able to get the integer values. But while getting string values it is returning empty value.
    Im using the below code to get the values from database table
    bool Table::Get(char* FieldName,int& FieldValue)
        try
            _variant_t  vtValue;
            vtValue = m_Rec->Fields->GetItem(FieldName)->GetValue();
            FieldValue=vtValue.intVal;
        CATCHERRGET
        sprintf(m_ErrStr,"Success");
        return 1;
    Im using the below code to get the values.
    AIErr getProjects()
        char buf[5000];
        int i;   
        std::string  catName;
        ::CoInitialize(NULL);
        Database db;
        Table tbl;
        errno_t err;
        err = fopen(&file,"c:\\DBResult.txt","w");
        fprintf(file, "Before Connection Established\n");
        //MessageBox(NULL,CnnStr,"Connection String",0);
        if(!db.Open(g->username,g->password,CnnStr))
            db.GetErrorErrStr(ErrStr);
            fprintf(file,"Error: %s\n",ErrStr);
        fprintf(file, "After Connection Established\n");
    if(!db.Execute("select ProjectID,ProjectName from projectsample",tbl))
            db.GetErrorErrStr(ErrStr);
            fprintf(file,"Error: %s\n",ErrStr);
        int ProjectID;
        int UserID;
        int ProjectTitle;
        char ProjectName[ProjectNameSize];
        if(!tbl.ISEOF())
            tbl.MoveFirst();
        ProjectArrCnt=0;
        for(i=0;i<128;i++)
            buf[i]='\0';
            int j=0;
        while(!tbl.ISEOF())
            if(tbl.Get("ProjectID",ProjectID))
                fprintf(file,"Project ID: %d ",ProjectID);
                ProjectInfo[ProjectArrCnt].ProjectID = ProjectID;
                sprintf(buf,"%d",ProjectID);
                //MessageBox(NULL, buf,"f ID", 0);
                j++;
            else
                tbl.GetErrorErrStr(ErrStr);
                fprintf(file,"Error: %s\n",ErrStr);
                break;
            //if(tbl.Get("ProjectTitle",ProjectName))
            if(tbl.Get("ProjectName",ProjectName))
                MessageBox(NULL,"Inside","",0);
                fprintf(file,"ProjectTitle: %s\n",ProjectName);
                //catName=CategoryName;
                ProjectInfo[ProjectArrCnt].ProjectName=ProjectName;
                //sprintf(buf,"%s",ProjectName);
                MessageBox(NULL,(LPCSTR)ProjectName,"",0);
            else
                tbl.GetErrorErrStr(ErrStr);
                fprintf(file,"Error: %s\n",ErrStr);
                break;
            ProjectArrCnt++;
            //MessageBox(NULL, "While", "WIN API Test",0);
            tbl.MoveNext();
        //MessageBox(NULL, ProjectInfo[i].ProjectName.c_str(),"f Name", 0);
        ::CoUninitialize();
        //sprintf(buf,"%s",file);
        //MessageBox(NULL,buf,"File",0);
        fprintf(file, "Connection closed\n");
        fclose(file);
        for(i=0;i<ProjectArrCnt;i++)
            sprintf(buf,"%i",ProjectInfo[i].ProjectID);
            //MessageBox(NULL,buf,"Proj ID",0);
            //MessageBox(NULL,ProjectInfo[i].ProjectName.c_str(),"Project Name",0);
        return 0;
    In the above code im geeting project D which is an integer value. But not able to get the project name.
    Please some one guide me.

    As I said in the other thread, this really isn't the place to ask questions about a database API unrelated to the Illustrator SDK. You're far more like to find people familliar with your problem on a forum that is dedicated to answering those kinds of questions instead.

  • How can i get the random values from database?

    Hi,
    i want to get random values from database.
    I try my best find no solution
    plz give solution in either sql query or java method.
    thanks in advance.

    try this:
    Give a numeric row-id to each row of database.
    say (1-100) for 100 rows
    In the program use random function to get random number between 0 and 1. this value u multiply with 100(or total number of rows) and take integer value of it . u then perform sql query to select the a row which matches randomly genarated value with row-id assigned to each row of database
    madhu

  • Fetching values from database into a drop down box

    in my JSP page there are 3 drop down boxes for date of birth......
    what i need is i want to get the values from database into that drop down box when i access the JSP page.......
    session is there....'m getting all other values.......
    I will attach the JSP page.....
    Please help me...........
    Thanks in Advance......
    <%@ taglib uri='/WEB-INF/taglib/struts-bean.tld' prefix='bean'%>
    <%@ taglib uri='/WEB-INF/taglib/struts-logic.tld' prefix='logic'%>
    <%@ taglib uri='/WEB-INF/taglib/dyna.tld' prefix='dyna'%>
    <%@ taglib uri='/WEB-INF/taglib/struts-html.tld' prefix='html'%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title><bean:message key="page_title"/></title>
    <link href="<bean:message key="context"/>/CSS/default.css" rel="stylesheet" type="text/css" />
    <script src="<bean:message key="context"/>/js/AC_RunActiveContent.js" type="text/javascript"></script>
    <link href="<bean:message key="context"/>/CSS/screen.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <%!
    Membership mShip = null;
    %>
    <script language="javascript" >
    function checkDate(Form){
    var d;
    d = Form.year.value+"-"+Form.month.value+"-"+Form.day.value;
    alert("Date is:"+d);
    Form.dob.value = d;
    </script>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>
         <jsp:include flush="true" page="../templates/header.jsp"/>     </td>
    </tr>
    <tr>
    <td class="menuTD">     
         <jsp:include flush="true" page="../templates/menu.jsp"/>     </td>
    </tr>
    <tr>
    <td class="sub_menuTR"> </td>
    </tr>
    <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="column" valign="top" width="170"><jsp:include flush="true" page="../templates/left_panel.jsp"/></td>
    <td valign="top" align="left">
              <dyna:message error="error" warning="warning" message="message"/>
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="80%" valign="top" align="left">
                   <%
                   if(session != null){
                   mShip = (Membership)session.getAttribute("member");
                   %>
                        <form action="updateContactDetails.dy" method="post" name="form1">
                        <input type="hidden" name="m" value="<%=request.getParameter("m")%>" />
                             <table width="100%" border="0">
                             <tr>
                                  <td>First Name</td>
                                  <td><input name="first_name" type="text" id= "first_name" value = "<bean:write name = "member" property = "first_name" />" /></td>
                             </tr>
                             <tr>
                                  <td>Last Name </td>
                                  <td><input name="last_name" type="text" id="last_name" value = "<bean:write name = "member" property = "last_name" />" > </td>
                             </tr>
                             <tr>
                                  <td>Address</td>
                                  <td><input name="address1" type="text" id="address1" value = "<bean:write name = "member" property = "address1" />" ></td>
                             </tr>
                             <tr>
                                  <td> </td>
                                  <td><input name="address2" type="text" id="address2" value = "<bean:write name = "member" property = "address2" />" ></td>
                             </tr>
                             <tr>
                                  <td>Suburb/City </td>
                                  <td><input name="city" type="text" id="city" value= "<bean:write name = "member" property = "city" />" ></td>
                             </tr>
                             <tr>
                                  <td>State/Territory</td>
                                  <td><input type="text" name="state" value = "<bean:write name = "member" property = "state" />" ></td>
                             </tr>
                             <tr>
                                  <td>Postcode</td>
                                  <td><input type="text" name="postcode" value = "<bean:write name = "member" property = "postcode" />" ></td>
                             </tr>
                             <tr>
                                  <td>Contact Phone</td>
                                  <td><input type="text" name="home_phone" value = "<bean:write name = "member" property = "home_phone" />" ></td>
                             </tr>
                             <tr>
                                  <td>Mobile</td>
                                  <td><input type="text" name="mobile" value = "<bean:write name = "member" property = "mobile" />" ></td>
                             </tr>
                             <tr>
                                  <td>Date of birth</td>
                                  <td nowrap="nowrap"><select name="day">
    <option>Day</option>
    <option value="01">1</option>
    <option value="02">2</option>
    <option value="03">3</option>
    <option value="04">4</option>
    <option value="05">5</option>
    <option value="06">6</option>
    <option value="07">7</option>
    <option value="08">8</option>
    <option value="09">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    <option value="16">16</option>
    <option value="17">17</option>
    <option value="18">18</option>
    <option value="19">19</option>
    <option value="20">20</option>
    <option value="21">21</option>
    <option value="22">22</option>
    <option value="23">23</option>
    <option value="24">24</option>
    <option value="25">25</option>
    <option value="26">26</option>
    <option value="27">27</option>
    <option value="28">28</option>
    <option value="29">29</option>
    <option value="30">30</option>
    <option value="31">31</option>
    </select>
                                  <select name="month">
                                       <option>Month</option>
                                       <option value="01">January</option>
                                       <option value="02">February</option>
                                       <option value="03">March</option>
                                       <option value="04">April</option>
                                       <option value="05">May</option>
                                       <option value="06">June</option>
                                       <option value="07">July</option>
                                       <option value="08">August</option>
                                       <option value="09">September</option>
                                       <option value="10">October</option>
                                       <option value="11">November</option>
                                       <option value="12">Decembber</option>
                                  </select>
                                       <select name="year" onChange = "checkDate(this.form);" >
                                       <option>Year</option>
                                       <option value="1957">1957</option>
                                       <option value="1956">1956</option>
                                       <option value="1955">1955</option>
                                       <option value="1954">1954</option>
                                       <option value="1955">1955</option>
                                       <option value="1956">1956</option>
                                       <option value="1957">1957</option>
                                       <option value="1958">1958</option>
                                       <option value="1959">1959</option>
                                       <option value="1960">1960</option>
                                       <option value="1961">1961</option>
                                       <option value="1962">1962</option>
                                       <option value="1963">1963</option>
                                       <option value="1964">1964</option>
                                       <option value="1965">1965</option>
                                       <option value="1966">1966</option>
                                       <option value="1967">1967</option>
                                       <option value="1968">1968</option>
                                       <option value="1969">1969</option>
                                       <option value="1970">1970</option>
                                       <option value="1971">1971</option>
                                       <option value="1972">1972</option>
                                       <option value="1973">1973</option>
                                       <option value="1974">1974</option>
                                       <option value="1975">1975</option>
                                       <option value="1976">1976</option>
                                       <option value="1977">1977</option>
                                       <option value="1978">1978</option>
                                       <option value="1979">1979</option>
                                       <option value="1980">1980</option>
                                       <option value="1981">1981</option>
                                       <option value="1982">1982</option>
                                       <option value="1983">1983</option>
                                       <option value="1984">1984</option>
                                       <option value="1985">1985</option>
                                       <option value="1986">1986</option>
                                       <option value="1987">1987</option>
                                       <option value="1988">1988</option>
                                       <option value="1989">1989</option>
                                       <option value="1990">1990</option>
                                       <option value="1991">1991</option>
                                       <option value="1992">1992</option>
                                       <option value="1993">1993</option>
                                       <option value="1994">1994</option>
                                       <option value="1995">1995</option>
                                       <option value="1996">1996</option>
                                       <option value="1997">1997</option>
                                       <option value="1998">1998</option>
                                       <option value="1999">1999</option>
                                       <option value="2000">2000</option>
                                       <option value="2001">2001</option>
                                       <option value="2002">2002</option>
                                       <option value="2003">2003</option>
                                       <option value="2004">2004</option>
                                       <option value="2005">2005</option>
                                       <option value="2006">2006</option>
                                       <option value="2007">2007</option>
                             </select ></td></tr>
                             <tr>
                                  <td><input type="hidden" name = "dob" /> </td>
                                  <td nowrap="nowrap"><input type="submit" value="Submit" /></td>
                             </tr>
                             </table>
                        </form>
                   </td>
    <td width="40"></td>
    <td width="200" valign="top">
                   <div id="headlines">
    <jsp:include flush="true" page="../templates/profile.jsp"/>
    </div>
                   </td>
    </tr>
    </table>
              </td>
    <td> </td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td><jsp:include flush="true" page="../templates/footer.jsp"/></td>
    </tr>
    </table>
    </body>
    </html>

    i think normally u will get data from databsae as objects.they are like java beans having getter and setter methods.so you create a collection of those objects like collect all the objects coming from database into an arraylist or....
    suppose you want to populate the dropdown box with say "username" from database object s, your code will look like that
    <html:select property="name">
    <html:options collection="databaseList" property="username" />
    </html:select>
    "databaseList" is collection(say.. ArrayList) of objects you are getting from database.this dropdown will contain all the "usernames" you are getting from database.

  • List of values from Database Adapter - BPM Forms

    Hi all,
    Can anyone tell me how to get list of values from Database adapter and a ServiceTask.
    As example lets say a table has Employee and Department columns.
    I want to list down all the Employees in BPM form (Select One List Box) once i provide the department to the Database Adapter.
    Is it possible from the DB Adapter?? What will be the variable type?
    Thanks,
    Nir

    Hi DanielAtwood,
    Thanks for your reply...
    Actually when i send the variable in 'WHERE Clause' in Db Adapter query it will retrieve more than one record as the output.
    I want to put that values to a 'SelectOneChoice' component and list down all the values..
    First I tried with data control. But i couldn't find the way to pass the value to the variable(in WHERE clause) to the query in data control view.
    Thanks,
    Nir

  • How to popup values from database tables to SelectOneMenu

    Hi friends,
    I am doing a jsf application, in which there is a selectOneMenu
    control and I want that, iwhen this page is loaded after clicking button
    on the previous page, the selectOne Menu should be populated with
    the values from database.
    Also I want , if i will select any menu item from the menu , acccordingly
    another selectOneMenu control should be filled with respective values
    thanx,
    bye

    Oh dear. I don't think anybody can advise you until you are not "kinda" new to Java anymore. Learn Java itself (the language, the platform and the tools), only then should you start considering going into web development.

  • How to fill bean area with values from database

    i have a bean area in form which act as acombobox autocomplete , i want to fill it with dynamic values from database , any help will be appreciated.
    http://forms.pjc.bean.over-blog.com/article-16369664.html "this is the example i'm working on"
    Best Regards.

    An example with the EMP table:
    DECLARE
      cursor cur is select empno,ename from emp;
    BEGIN
      -- initialise the ComboBox twin values --
      for c in cur loop
       if c.empno is not null then
        Set_Custom_Property('BL.BEAN',1,'ADD_TWIN',c.empno||','||c.ename);
       else
        Set_Custom_Property('BL.BEAN',1,'ADD_TWIN_NULL',c.empno||','||c.ename);
       end if ;
      end loop;
      Set_Custom_Property('BL.BEAN',1,'ADD_TWIN','[END_DATA]');
      Set_Custom_Property('BL.BEAN',1,'SET_ALIGNMENT','right');
    END;Francois

  • Multiple values from database on a single text item

    i am trying to do the following
    on a single text item in a form
    (under form property pallete->records->number of items displayed is 5) run a triger "when-new-block-instance" with the following pl/sql statement
    declare
    menu_item VARCHAR2(35);
    begin
    select label into menu_item
    from menu_options;
    end;
    however, once i run the form it gives me
    WHEN-NEW-BLOCK-INSTANCE trigger raised unhandeled exception ORA-01422
    however, if in the pl/sql statement contains only
    begin
    execute querry;
    end;
    then it works fine
    The problem i beleive is the fact that the first querry retreives multiple values or recordset instead of A record.
    How can i go arond this and allow the form to list all the values in this form. Eventually i will need to add conditional SQL statments and that is why just execute querry will not work.
    Also, is there a way to dynamically assign a number to "number of records shown" property?
    All help is very much appreciated!
    null

    Hi, Marko
    I teach Forms, and I usually find a bad idea to use SQL statements directly (in particular when you can "make" Forms to do what you want).
    Inside PL/SQL, a SELECT..INTO statement is supposed to select a single row, otherwise an error occurs.
    EXECUTE_QUERY works.
    If by "conditional SQL statements" you mean restricted (filtered) queries, you don't need to write SQL to do this.
    You can set the DEFAULT_WHERE block property to a different value before using EXECUTE_QUERY, like:
    SET_BLOCK_PROPERTY('your_block', DEFAULT_WHERE, 'where menu_id > 100');
    And the answer to your second question is no, you cannot dynamically change the number of records a block is displaying.
    You can limit the number of records your block queries from the database table using Maximum Records Fetched block property (available in Forms 6 and above, not sure about Forms 5). However, this will only work as expected if you set Query All Records to Yes.
    Hope this helps,
    Pedro

  • Retrieve values from database

    Hi,
    one of the search form contains the select option for country , state and
    distributor type.
    the country drop down has 2 values - US and canada
    the conditions needed to be satisfied are :
    (1) if the country selected is US - then the states dropdown should only show the states that are associated with US in the table in the database(TABLE name is - "distributors")
    and if country selected is Canada - then should show states in canada only
    (2) if canada is selected in the country dropdown, the distributor type which has 2 values - stationary and automotive - should show only the stationary in the dropdown and not show the automotive
    This is done with the LocateQueryServlet.java...can someone please tell me how this needs to be updates so that the above conditions are satisfied...
    Attaching the code from LocateQueryServlet.java and the prolog.sql
    --------------------------------------------------------------------------------------------------LocateQueryServlet.java
    package com.dupont.refrigerants.distributorlocator;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Iterator;
    import java.util.List;
    import javax.ejb.CreateException;
    import javax.naming.NamingException;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import com.proxicom.util.MiscEJBFunctions;
    * This servlet displays a query form for locating distributors. It relies on
    * the 'countries', 'states' and 'types' tables in the database to fill its
    * forms. If a table is empty, it doesn't display the corresponding select
    * (pulldown) widget. This only displays the form fragment of HTML, and should
    * be included in a complete page, probably with JSP or the like.
    * XXX Currently, the form is populated when the servlet is initialized, which
    * is a hack because I don't remember the appropriate j2ee idiom.
    * @web.servlet name="queryServlet" display-name="Distributor Locator Query
    * Servlet" description="Servlet that gets a query form for finding
    * distributors in a given region"
    * @web.servlet-mapping url-pattern="/queryServlet"
    public class LocateQueryServlet extends HttpServlet {
         * Abstract class for converting a java object into
         * an option element for an HTML select form widget.
         private abstract static class Object2Option {
              * Gets the default option at the top of the select.
              * To have no default, override this to return the
              * empty string.
              * @return <code>>option selected='true' value=''<-- Select One -->/option<</code>
              public String getDefault() {
                   return "<option selected='true' value=''>-- Select One --</option>";
              * The option element that represents the given info object.
              * @param o the info object
              * @return an unselected HTML option element.
              abstract public String getOptionFor(Object o);
              * Helper method for generating a select option element
              * with the given un-encoded value and text.
              * @param value
              * unencoded string to be passed as the form
              * value when selected
              * @param text
              * unencoded string to be displayed in the select
              * box pulldown
              * @return the concatenated and appropriately escaped
              * option element
              protected static String getOptionWith(String value, String text) {
                   return "<option value='" + Utilities.webify(value, false) + "'>"
                             + Utilities.webify(text, false) + "</option>";
         * Function object for generating 'Country' select box items.
         private static class Object2CountryOption extends Object2Option {
              * Converts a CountryInformation object into an appropriate
              * HTML option element.
              public String getOptionFor(Object o) {
                   CountryInformation c = (CountryInformation) o;
                   return getOptionWith(c.getCode(), c.getName());
         * Function object for generating 'Distributor Type' select box items.
         private static class Object2DistributorTypeOption extends Object2Option {
              * Converts a DistributorTypeInformation object into an appropriate
              * HTML option element.
              public String getOptionFor(Object o) {
                   DistributorTypeInformation c = (DistributorTypeInformation) o;
                   return getOptionWith(String.valueOf(c.getId()), c.getDescription());
         * Function object for generating 'State/Province' select box items.
         private static class Object2StateOption extends Object2Option {
              * Converts a StateInformation object into an appropriate
              * HTML option element.
              public String getOptionFor(Object o) {
                   StateInformation c = (StateInformation) o;
                   return getOptionWith(c.getCode(), c.getName());
         private String countries;
         private String states;
         private String types;
         * Constructs a simple locate query servlet.
         public LocateQueryServlet() {
              super();
         * Generates an HTML select form widget for the given list of values.
         * @param formName the name of the widget for the HTML name attribute
         * @param values the values to convert into a list
         * @param factory the method for converting each value into an option.
         * @return the complete 'select' element
         private String generateSelectFor(String formName, List values,
                   Object2Option factory) {
              StringBuffer sb = new StringBuffer();
              sb.append("<select name='").append(Utilities.webify(formName, false)).append("'>");
              sb.append(factory.getDefault());
              for (Iterator iter = values.iterator(); iter.hasNext();) {
                   sb.append(factory.getOptionFor(iter.next()));
              sb.append("</select>");
              return sb.toString();
         * Initializes the servlet. Actually results in some queries getting run.
         * @param config
         * @throws ServletException
         public void init(ServletConfig config) throws ServletException {
              try {
                   DistributorDBABeanHome distBean = (DistributorDBABeanHome) MiscEJBFunctions.getBeanHomeInterface(null, null, Utilities.EJB_DISTRIBUTOR_DBA_NAME);
                   DistributorDBABean dists = distBean.create();
                   this.countries = this.generateSelectFor("country", dists.getCountries(),
                             new Object2CountryOption());
                   this.states = this.generateSelectFor("state", dists.getStates(),
                             new Object2StateOption());
                   this.types = this.generateSelectFor("type", dists.getDistributorTypes(),
                             new Object2DistributorTypeOption());
              } catch (NamingException e) {
                   throw new ServletException("Lookup of "
                             + Utilities.EJB_DISTRIBUTOR_DBA_NAME + " failed", e);
              } catch (CreateException e) {
                   throw new ServletException(
                             "Error while creating distributor session bean", e);
              } catch (java.rmi.RemoteException e) {
                   throw new ServletException(
                             "Error while initializing distributor locator", e);
         * Executes the HTTP request and return the appropriate HTML form fragment.
         * @param request
         * @param response
         * @throws ServletException
         * @throws IOException
         protected void doGet(HttpServletRequest request,
                   HttpServletResponse response) throws ServletException, IOException {
              PrintWriter out = response.getWriter();
              response.setContentType("text/html");
              String action = request.getParameter("action");
              if (action == null) {
                   action = "where-to-buy-results";
              } else {
                   action = Utilities.webify(action, false);
              // Open form and table elements.
              out.println("<form id='distributorLocator' action='" + action + "' method='get'>"
                                  + "<table width='100%' border='0' cellpadding='4' cellspacing='0'>");
              // buffer row
              //out.println("<tr><td colspan='2'><hr width='65%' size='1' noshade></td></tr>");
              // 'Country' row
              out.println("<tr><td><div align='right' class='formSubHead'>Country:</div></td>"
                                  + "<td>" + this.countries + "</td></tr>");
              // 'States' row
              out.println("<tr><td><div align='right' class='formSubHead'>State/Province:</div></td>"
                                  + "<td>" + this.states + "</td></tr>");
              // 'Application' row
              out.println("<tr><td><div align='right' class='formSubHead'>Application:</div></td>");
              out.println("<td>" + this.types + "</td></tr>");
              // or row
              out.println("<tr><td><div align='right'></div></td><td><em><strong>or</strong></em></td></tr>");
              // zip code row
              out.println("<tr><td><div align='right' class='formSubHead'>Zip Code/Postal Code: </div></td>"
                                  + "<td><input id='zip' name='zip' type='text' /></td></tr>");
              // buffer row
              out.println("<tr><td colspan='2'><hr width='65%' size='1' noshade></td></tr>");
              // submit row
              out.println("<tr><td> </td><td><input type='submit' value='Find' /></td></tr>");
              // end table and form
              out.println("</table></form>");
    prolog.sql
    SET DEFINE OFF;
    CREATE SEQUENCE distributor_id_seq START WITH 1 INCREMENT BY 1 NOMAXVALUE;
    CREATE TABLE countries (code CHAR(2), name VARCHAR(254),
         CONSTRAINT country_pk PRIMARY KEY(code));
    CREATE TABLE states (code CHAR(5), name VARCHAR(254), country CHAR(2),
         CONSTRAINT state_pk PRIMARY KEY(code),
         CONSTRAINT fk_country FOREIGN KEY(country) REFERENCES countries(code));
    CREATE TABLE distributorTypes (id INTEGER, name VARCHAR(254),
         CONSTRAINT distributorType_pk PRIMARY KEY(id));
    CREATE TABLE distributors
         (id INTEGER,
         name VARCHAR(254),
         zip VARCHAR(12),
         country CHAR(2),
         state CHAR(5),
         city VARCHAR(63),
         address1 VARCHAR(254),
         address2 VARCHAR(254),
         fax VARCHAR(32),
         phone VARCHAR(32),
         managers VARCHAR(254),
         type INTEGER,
         email VARCHAR(254),
         url VARCHAR(254),
         CONSTRAINT distributor_pk PRIMARY KEY(id),
         CONSTRAINT fk_dist_country FOREIGN KEY(country) REFERENCES countries(code),
         CONSTRAINT fk_dist_state FOREIGN KEY(state) REFERENCES states(code),
         CONSTRAINT fk_dist_type FOREIGN KEY(type) REFERENCES distributorTypes(id));
    CREATE TABLE statesApply (state CHAR(5), distributor INTEGER,
         CONSTRAINT fk_apply_state FOREIGN KEY(state) REFERENCES states(code),
         CONSTRAINT fk_apply_distributor FOREIGN KEY(distributor) REFERENCES distributors(id));
    INSERT INTO
              distributorTypes (id, name) VALUES (1, 'Air Conditioning - Stationary and Refrigeration');
    INSERT INTO
              distributorTypes (id, name) VALUES (2, 'Air Conditioning - Automotive');
    INSERT INTO
              countries (code, name) VALUES ('CA', 'Canada');
    INSERT INTO
              countries (code, name) VALUES ('US', 'United States of America');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_AL', 'Alabama');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_KS', 'Kansas');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_ND', 'North Dakota');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_AK', 'Alaska');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_KY', 'Kentucky');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MP', 'N. Mariana Islands');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_AS', 'American Samoa');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_LA', 'Louisiana');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_OH', 'Ohio');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_AZ', 'Arizona');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_ME', 'Maine');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_OK', 'Oklahoma');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_AR', 'Arkansas');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MH', 'Marshall Islands');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_OR', 'Oregon');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_CA', 'California');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MD', 'Maryland');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_PW', 'Palau');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_CO', 'Colorado');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MA', 'Massachusetts');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_PA', 'Pennsylvania');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_CT', 'Connecticut');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MI', 'Michigan');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_PR', 'Puerto Rico');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_DE', 'Deleware');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MN', 'Minnesota');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_RI', 'Rhode Island');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_DC', 'District of Columbia');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MS', 'Mississippi');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_SC', 'South Carolina');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_FM', 'FS Micronesia');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MO', 'Missouri');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_SD', 'South Dakota');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_FL', 'Florida');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_MT', 'Montana');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_TN', 'Tennessee');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_GA', 'Georgia');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NE', 'Nebraska');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_TX', 'Texas');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_GU', 'Guam');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NV', 'Nevada');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_UT', 'Utah');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_HI', 'Hawaii');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NH', 'New Hampshire');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_VT', 'Vermont');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_ID', 'Idaho');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NJ', 'New Jersey');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_VI', 'Virgin Islands');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_IL', 'Illinois');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NM', 'New Mexico');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_VA', 'Virginia');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_IN', 'Indiana');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NY', 'New York');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_WA', 'Washington');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_IA', 'Iowa');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_NC', 'North Carolina');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_WV', 'West Virginia');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_WI', 'Wisconsin');
    INSERT INTO
              states (country, code, name) VALUES ('US', 'US_WY', 'Wyoming');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_AB', 'Alberta');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_BC', 'British Columbia');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_MB', 'Manitoba');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_NB', 'New Brunswick');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_NL', 'Newfoundland and Labrador');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_NS', 'Nova Scotia');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_NT', 'Northwest Territories');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_NU', 'Nunavut');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_ON', 'Ontario');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_PE', 'Prince Edward Island');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_QC', 'Qu�bec');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_SK', 'Saskatchewan');
    INSERT INTO
              states (country, code, name) VALUES ('CA', 'CA_YT', 'Yukon');
    Any immediate help is truly appreciated.
    Thanks in advance

    I thank you for the link, it's something I've already done several times ....
    actually this code tries to manage a key incremental, I am obliged to do that because I am in MS SQL Server and therefore what works for oracle does not work for SQL Server, which is why I want to do it manual, I also posted this in a previous post and I was asked to retrieve the field value by Code: Help please : dbsequence refresh on MS sql server
    now admitting that it is not what I want to do and I have the following code:
    if (it1.getValue () == null) (
    Connection connection = ConnectionManager.getInstance (). GetConnection ();
    Statement statement = connection.createStatement ();
    ResultSet resultset = statement.executeQuery ("SELECT id FROM WHERE name = spider" it2.getValue + () + "");
    while (resultSet.next ())
    it1.setValue (resultSet.getInt (1));
    BindingContainer getBindings bindings = ();
    OperationBinding operationBinding bindings.getOperationBinding = ("Commit");
    OperationBinding.execute Object result = ();
    if (! operationBinding.getErrors (). isEmpty ()) (
    return null;
    else (
    BindingContainer bindings2 getBindings = ();
    OperationBinding operationBinding2 bindings2.getOperationBinding = ("Commit");
    OperationBinding2.execute Object result = ();
    if (! operationBinding2.getErrors (). isEmpty ()) (
    return null;
    What code ADF BC I will put in place of jdbc code

  • Retrieving values from Database in Excel Task Pane App

    So far,
    I created a website with a database on Azure, I then published my App to Azure. My problem is that I'm not sure how I retrieve values from the database (in SQL: SELECT * FROM EXAMPLE_TABLE WHERE date = str). If someone could provide me with sample code,
    that would be amazing! :D
    It would also be very helpful if anyone knew a method to automatically update the database using information from a xml stream on another website, once a day.
    Thank you!

    Hi,
    >> My problem is that I'm not sure how I retrieve values from the database
    You can use jquery ajax call to call your webserivce or REST API, which will query the database and return a json result.
    Sample:
    Apps for Office: Create a web service using the ASP.NET Web API
    >> It would also be very helpful if anyone knew a method to automatically update the database using information from a xml stream on another website
    For the database sync-up question, I suggest you posting them on the forums like SQL Server Forum.
    Thanks for your understanding.
    Best Regards
    Lan
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Have a error in getting the values from database randomly

    Hi to all
    I am new member to this community and new to java programming, i am the one of them who got benefited through this site , with that hope i am asking u to clear my doubt.
    Actually i want to get the data from database randomly, i dont have problem either in database connection and generating random number,its working fine. but when i have to get the data from database with generated random no using absolute function , i am getting an exception
    eg : rs.absolute(2);
    i could not move to the second row of my result set.
    not only absolute function whatever the function i am using except next method, getting exception.
    my code :
    package practical;
    import java.util.*;
    import java.sql.*;
    public class gen {
         Connection con;
         Statement s;
         ResultSet rs;
         public void get(int t)
              try
                   rs.absolute(t);
                   String question=rs.getString("question");
                   System.out.println("Random question : "+question);
              catch(Exception e)
                   System.out.println("get error");
         public void ran()
              Random r=new Random();
                   for(int i=0;i<10;i++)
                        int j=r.nextInt(10);
                        System.out.println("random value : "+j);
                        if(j!=0)
                             try
                                  get(j);
                             catch(Exception e)
                                  System.out.println("ran error");
         public void connect()
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con=DriverManager.getConnection("jdbc:odbc:ds","sa","server");
                   s=con.createStatement();
                   rs=s.executeQuery("select question from qa");
                   ran();
                   con.close();
              catch(Exception e)
                   System.out.println("error");
         public static void main(String... strins)
              new gen().connect();
    }

    but i acheived through the code which is pasted below but i have to close the database connection for every iteration.
    package practical;
    import java.util.*;
    import java.sql.*;
    public class gen {
         Connection con;
         Statement s;
         ResultSet rs;
         public void get(int t)
              int c=0;
              while(c!=t)
                   try
                   rs.next();
                   c++;
                   catch(Exception e)
                        System.out.println("next error");
              if(c==t)
              {     try
                        String question=rs.getString("question");
                        System.out.println("Random question : "+question);
                   catch(Exception e)
                        System.out.println("iteration error");
         public void ran()
              Random r=new Random();
                   int j=r.nextInt(10);
                   System.out.println("random value : "+j);
                   if(j!=0)
                        try
                             get(j);
                        catch(Exception e)
                             System.out.println("ran error");
         public void connect()
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con=DriverManager.getConnection("jdbc:odbc:ds","sa","server");
                   s=con.createStatement();
                   rs=s.executeQuery("select question from qa");
                   ran();
                   con.close();
              catch(Exception e)
                   System.out.println("error");
         public static void main(String... strins)
              for(int i=0;i<10;i++)
                   new gen().connect();
    }

  • How to gather option values from database in jsp

    jsp experts
    my problem is that i have to populate the optional values that user has to selecet his choice .
    we could have done it by :
    <optional value="item1">item1
    <optional value="item2">item2
    </select>
    but in our database if new category of item is enlisted then what ??? ,thats why we go for populating the values from fetching from database by simple class & populate values in the optional values.
    can any one help about it

    Hi Avina,
    You need to invoke a method from your jsp file which interacts with the database. If you are following the MVC pattern which segregates the View and Contoller part, invoke the controller jsp from your View using the include tag.
    Say this is the View.jsp
    // all your initial page include statements --
    <%
    // all your java code (if necessary)
    %>
    <jsp:include page="Controller.jsp" >
    <jsp:param name="command" value="getOptionList"/>
    </jsp:include>
    <!-- all your html tags -->
    // If you are following my technique, there should be a Controller.jsp which interacts with your database thru some class which you instantiate in this jsp, which invokes some method (that is why i have passed a parameter, so that if u want to make a check you can do so - u may or may not pass the parameters - based on ur requirements).
    Code in Controller.jsp:
    <%
    // MyClass is the class which does the querying into the database.
    // obj.getOptions() is a method in that class which returns a Vector
    // containing all the options from your database.
    // Please ensure that you import the package in this jsp file, so as
    // to get the MyClass.class in this jsp.
    String getWhat = request.getParameter("command");
    if ( getWhat != null && getWhat.equalsIgnoreCase("command") ) {
    MyClass obj = new MyClass();
    java.util.Vector optionsAvailable = obj.getOptions();
    session.setAttribute("Options", optionsAvailable);
    %>
    -------------- End of Controller.jsp related work ---------------
    // Returning back to the code in the View.jsp:
    Once the including is over, the control will return to the next line of code in View.jsp. Just retrieve the data from the session:
    Continued - View.jsp
    <select name="itemsInDB">
    <option value="Select"> Select </option>
    <%
    /* Now you have a vector containing all the options from
    your database. */
    java.util.Vector vecOptions = (java.util.Vector)
    session.getAttribute("Options");
    for (int i=0; i<vecOptions.size(); i++) {
    %>
    <option value="<%=vecOptions.elementAt(i)%>"><%=vecOptions.elementAt(i)%></option>
    <%
    %>
    </select>
    Well thats all thats required. Your problem is solved. You will get a list of all the options in your database. Happy Coding

  • SQL Developer - Pulling column value from previous row

    I am using Oracle SQL developer and trying to pull a value from a column from the previous row.
    Currently this is an example from the code im using.
    Select CD1.nbr_dw, CD1.SEQ_DW, CD1.CDL_NET_PAID, CD1.UNITS_ALLOW,CD1.ALLOW_AMT, CD1.UNIT_PRICE, CD1.BACKED_OUT,
    case
    When CD1.NET_PAID = 0 then 0
    ****NEW CODE*****
    Else CD1.ALLOW_AMT / CD1.UNIT_PRICE
    end as NEW_UNITS
    From Table_A CD1
    join (Select nbr_dw, DET_DW, SEQ_DW
    From Table_B
    ) CD2
    on CD1.nbr_dw = CD2.nbr_dw
    I need to add another when statement that says when CD1.BACKED_OUT = 'Y' populated the NEW_UNITS field with the previous rows value of CD1.UNIT_PRICE. Note, the CD1.SEQ_DW can be used to determine the previous row. Any ideas?

    Hi,
    Welcome to the forum!
    The analytic LAG function can return a value from the previous row:
    LAG (cd1.unit_price) OVER ( -- PARTITION BY  x          -- if needed
                                   ORDER BY          cd1.seq_dw
                     )It's unclear if you need a PARTITION BY clause or not.
    "PARTITION BY x" means that you want the value from the last row that has the same value of x as the current row.
    If you omit the PARTITION BY clause, it means you want the last row regardless of what any other columns are.
    Whenever you have a problem, it ehlps if you post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
    Explain how you get those results from that data.
    Always say what version of Oracle you're using.

  • One SQL Statement executed abnormally in Oracle10g Database

    One programmer sent the following SQL to me, and ask why no result was returned. I knew that the SQL Statement was not good in writting and designing.
    So, first we don't focus on it. we only focus on why no result was returned.
    SELECT 'other Accts', 'Other Accts', TO_NUMBER(''),TO_DATE('2010-10-9', 'yyyy-MM-dd')
    FROM dual
    WHERE *0 = (SELECT COUNT(*)*
    FROM (SELECT 'other Accts', 'Other Accts',SUM(a.qty_invoiced), a.sell_week_date
    FROM sales_in_oracle_data a
    WHERE NOT EXISTS
    (SELECT pa.partner_number
    FROM partner pa
    WHERE pa.partner_number = a.customer_number)
    AND a.sell_week_date >=TO_DATE('2010-10-9', 'yyyy-MM-dd')
    AND a.sell_week_date <=TO_DATE('2011-1-1', 'yyyy-MM-dd')
    AND a.qty_invoiced >= 0
    AND EXISTS
    (SELECT pp.product_id
    FROM product_pn pp, product p
    WHERE pp.magellan_pn = a.material
    AND pp.product_id = p.product_id )
    GROUP BY a.sell_week_date
    the SQL sub Statement:
    SELECT COUNT(*)*
    FROM (SELECT 'other Accts', 'Other Accts',SUM(a.qty_invoiced), a.sell_week_date
    FROM sales_in_oracle_data a
    WHERE NOT EXISTS
    (SELECT pa.partner_number
    FROM partner pa
    WHERE pa.partner_number = a.customer_number)
    AND a.sell_week_date >=TO_DATE('2010-10-9', 'yyyy-MM-dd')
    AND a.sell_week_date <=TO_DATE('2011-1-1', 'yyyy-MM-dd')
    AND a.qty_invoiced >= 0
    AND EXISTS
    (SELECT pp.product_id
    FROM product_pn pp, product p
    WHERE pp.magellan_pn = a.material
    AND pp.product_id = p.product_id )
    GROUP BY a.sell_week_date
    it returned 0 truely. But the entire SQL didn't return any data.
    why can it execute like above description?  I guess that it maybe go against oracle basic rule.
    Any one give me some suggestion?
    Edited by: [email protected] on 2010/7/19 下午 6:09

    I managed to track down a 10.2.0.4 instance and can confirm that this statement does not return the correct results.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select *
      2  from   dual
      3  where  0 = (select count(*)
      4              from  (select dummy, sum(1)
      5                     from   dual
      6                     where  dummy = 'z'
      7                     group  by dummy
      8                    )
      9             );
    no rows selected
    SQL> explain plan for
      2  select *
      3  from   dual
      4  where  0 = (select count(*)
      5              from  (select dummy, sum(1)
      6                     from   dual
      7                     where  dummy = 'z'
      8                     group  by dummy
      9                    )
    10             );
    Explained.
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |     1 |     2 |     4   (0)| 00:00:01 |
    |*  1 |  FILTER             |      |       |       |            |          |
    |   2 |   TABLE ACCESS FULL | DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    |   3 |   SORT AGGREGATE    |      |     1 |     2 |            |          |
    |*  4 |    TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter( NOT EXISTS (SELECT /*+ */ 0 FROM "SYS"."DUAL" "DUAL"
                  WHERE "DUMMY"='z'))
       4 - filter("DUMMY"='z')
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP, Data Mining
    and Real Application Testing options
    SQL> select *
      2  from   dual
      3  where  0 = (select count(*)
      4              from  (select dummy, sum(1)
      5                     from   dual
      6                     where  dummy = 'z'
      7                     group  by dummy
      8                    )
      9             );
    D
    X
    SQL> explain plan for
      2  select *
      3  from   dual
      4  where  0 = (select count(*)
      5              from  (select dummy, sum(1)
      6                     from   dual
      7                     where  dummy = 'z'
      8                     group  by dummy
      9                    )
    10             );
    Explained.
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |     1 |     2 |     6   (0)| 00:00:01 |
    |*  1 |  FILTER            |      |       |       |            |          |
    |   2 |   TABLE ACCESS FULL| DUAL |     1 |     2 |     3   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| DUAL |     1 |     2 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter( NOT EXISTS (SELECT 0 FROM "SYS"."DUAL" "DUAL" WHERE
                  "DUMMY"='z'))
       3 - filter("DUMMY"='z')
    17 rows selected.Notice that the explain plan is a bit different compared to the 11.2.0.1 release. My guess is that the optimizer is doing something weird.

Maybe you are looking for