Result set two few parameters exception!!?

when i use the following code:
       res = stat1.executeQuery("SELECT * FROM Word where word="+current );
where res is a result set
stat1 is a statement
current is a string
the following exception appears after running:
java.sql.sqlexception[microsoft][ODBC microsoft access Driver] Two few parameters.Expected 1.
Any one can help me with this problem plz?

is the (?) from the syntax?in:
PreparedStatement ps =
connection.prepareStatement("SELECT * FROM Word WHERE
word=?");
ps.setString(1, someWord);
rs = ps.executeQuery(); [url http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html#JDBC207]http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html#JDBC207

Similar Messages

  • Varying result set and binding parameters in sqlcmd from variable

    SSIS  - Support of Multiple versions of our product
    Our Enterprise Data warehouse consolidates data from multiple data sources.  We have a requirement that we should be able to support data collection from different version of these data sources at the same time.
    Ex. Customer has three different versions of our product installed 7.3,  7.3.1 and 7.3.2. The data warehouse would in this case would be on version 7.3.2, but should be able to collect data from prior versions of the data sources.
    We use stored procedures to collect data from sources into our staging area and then we transform and load it on to the warehouse. The design of SSIS packages are that, there is one main package that executes packages for each table that we collect data
    from the source. The main package is invoked per source that we need to collect data from, if there are three sources at run time there will be three instances of the main package running. These packages run on the warehouse machine to pull the data from the
    source system.
    We would like to maintain one version of these packages on the warehouse and support collecting data from different source versions.
    Challenges
    The signature of stored procedures on the source system has changed between versions
    There are some additional fields returned by these stored procedures in the newer release
     Example
     7.3 version signature :
    [dbo].[PDW_GetMediaAgentSummary](@LastVersionID
    AS BIGINT,
    @InitializeDays as
    INT = 60,
    @NextVersionID AS
    BIGINT OUTPUT)
    7.3 Sp1 version signature:  [dbo].[PDW_GetMediaAgentSummary](@LastVersionID
    AS BIGINT,
    @DataStartDate AS
    DateTime2(3),
    @NextVersionID AS
    BIGINT OUTPUT)
     Also, let us say in 7.3 this stored procedure returned 8 fields and 7.3 sp1 it is returning 10 fields.
    The way we are trying to accommodate is to use “SQLCmd from variable” option in the OLE DB source to cover the signature difference, but this option does not allow us to bind parameters
    to variables to get the output value. The second issue of additional fields (or the lack of additional fields from the 7.3 procedure), we tried to turned off the metadata validation, but we get field not found error at run time when we run the SSIS package
    against 7.3 version. Looks like the only way we could solve is to duplicate the data flow tasks, based on the source version. Looking for better way to do this, since this could go out of control as the number of releases increases.
    Appreciate help on this.

    I suggest you branch your package into one route vs another based on some flag that indicates version the package is connected to then it will execute one stored proc or another, this can be done
    using the Precedence Constraints, or make a wrapper stored proc that hides the data differences between the versions.
    Arthur
    MyBlog
    Twitter

  • Re: To few parameters exception in Access database

    I used to deal with Access quite a bit in the past.
    This error can occur for a few reasons:
    1. One of your field names is a reserved word for Access. You can work around this by changing the name of the field OR by putting square brackets around the field name. For list of reserved words see:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;321266
    So for example if your field name is BINARY you need to say:
    select [BINARY] From Table1
    2. This can also happen if you have a typo in a field name. Any token that Access cannot understand it turns into a parameter, check the spelling of the fields.
    3. In rare cases this could be that you are hitting a query and not a table and the query has a parameter in it. If you run the query in Access itself and a dialog box pops up asking you to enter a value this is the case.

    Hello there
    Thank you for your post first of all.
    Well, the first and the last are not the case. I wrote in the initial post that the query runs just fine in Access, and I have no reserved words that I use in my query.
    For the second reasons, I understand that if one of my fields from within the query does not corespond to a column in the access database, Access will turn it into a parameter. Well since the query runs just fine in Access, and I have problem when I run it from a Java program, then I think this reason does not apply also.
    Any further suggestions will be apreciated.
    Regards,
    Mihai

  • How to get the number of records of a streaming result set

    Hi guys.
    So if it wasn't a streaming result set, I would have done this:
    {noformat}myResultSet<code class="jive-code jive-java">.last();
    {color:navy}*int*{color} numResults = </code>myResultSet<code class="jive-code jive-java">.getRow();
    </code>myResultSet<code class="jive-code jive-java">.beforeFirst();
    </code>{noformat}
    but being a streaming result set, beforeFirst() throws an exception...
    So how do you get the number of records in that result set? I wanna avoid an extra count(*) query, so I would appreciate other solutions than that.

    JoachimSauer wrote:
    vanwil wrote:
    you see, for now I just use a count(*) query to get the number of records, but that's adding a lot of extra waiting time...Iterating over the result twice will surely be slower then doing the count(*).great! so what I got now is actually the fastest way there is... awesome...
    If you get an exception, then you surely have a stack trace. That should tell you what happens, or at least where.com.mysql.jdbc.MysqlIO.checkForOutstandingStreamingData(MysqlIO.java:2066)
    Why do you need to know the number of elements beforehand, anyway?I need to know the number of elements because the incoming data goes into a table. Now of course, I could use ArrayList<String[]> or something, but wouldn't that require more memory resources than Object[][] ?
    No one can tell you that, at least not without more information (say, the stack trace for example).Here's the exception message:
    java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@10c0ef2 is still active. Only one streaming result set may be open and in use per-connection. Ensure that you have called .close() on  any active result sets before attempting more queries.

  • Pls help for Exception "Too Few Parameters : Expected 35"

    Hi,
    I am expericing with the exception
    "Too Few Parameters : Expected 35".
    What's wrong with it? The following is my code.
    try {                                                                                                                                                                                                                
    String DRIVER = ("sun.jdbc.odbc.JdbcOdbcDriver");               
    String URL = "jdbc:odbc:Industrial_One_DSN";
    String sql = "UPDATE BusinessRegistration " +
    "SET [Date] = ?, ISIC = ?, BizName = ?, BizAddress = ?, " +
    "OwnerName = ?, OwnerNRC = ?, Investment = ?, EstablishedYear = ?, " +
    "L_Male = ?, L_Female = ?, F_Male = ?, F_Female = ?, " +
    "OwnershipType = ?, Remarks = ?, IndustialZoneName = ?, Unit = ?, " +
    "Fuel = ?, FactoryType = ?, FactoryName = ?, Township = ? " +
    "MainProductName = ?, MainProductCountType = ?, " +
    "MainProductQuantity = ?, MainProductValue = ?, RMName = ?, " +
    "RMCountType = ?, RMQuantity = ?, RMValue = ?, EnergyName = ?, " +
    "MachinePower = ?, AmountGallon = ?, StateDiv = ?, BizSize = ?  " +
    "WHERE RegistrationID = ?";
    Class.forName(DRIVER);
    Connection con = DriverManager.getConnection(URL);
    PreparedStatement pstmt = con.prepareStatement(sql);
    int ilmale = Integer.parseInt(lmale);
    int ilfemale = Integer.parseInt(lfemale);
    int ifmale = Integer.parseInt(fmale);
    int iffemale = Integer.parseInt(ffemale);
    int impq = Integer.parseInt(mpq);
    int impv = Integer.parseInt(mpv);
    int irmq = Integer.parseInt(rmq);
    int irmv = Integer.parseInt(rmv);
    int iamountgallon = Integer.parseInt(amountgallon);
    pstmt.setString(1, date);
    pstmt.setString(2, isic);
    pstmt.setString(3, bizname);
    pstmt.setString(4, bizaddress);
    pstmt.setString(5, ownername);
    pstmt.setString(6, ownernrc);
    pstmt.setString(7, investment);
    pstmt.setString(8, eyear);
    pstmt.setInt(9, ilmale);
    pstmt.setInt(10, ilfemale);
    pstmt.setInt(11, ifmale);
    pstmt.setInt(12, iffemale);
    pstmt.setString(13, ownershiptype);
    pstmt.setString(14, remark);
    pstmt.setString(15, izn);
    pstmt.setString(16, unit);
    pstmt.setString(17, fuel);
    pstmt.setString(18, ft);
    pstmt.setString(19, fname);
    pstmt.setString(20, township);
    pstmt.setString(21, mpn);
    pstmt.setString(22, mpct);
    pstmt.setInt(23, impq);               
    pstmt.setInt(24, impv);
    pstmt.setString(25, rmname);
    pstmt.setString(26, rmct);
    pstmt.setInt(27, irmq);
    pstmt.setInt(28, irmv);
    pstmt.setString(29, ename);
    pstmt.setString(30, mpower);
    pstmt.setInt(31, iamountgallon);
    pstmt.setString(32, statediv);
    pstmt.setString(33, bizsize);
    pstmt.setInt(34, Integer.parseInt(rid));
    pstmt.executeUpdate();
    }I have got 35 fields in my db. But I wanna edit 34 fields only. I have no primary key in my table. Is't alright?
    pls help me.
    With thanks,
    WTDAHL

    I presume you are using SQL server, hence the [Date] in your SQL?
    I counted 34 question marks in your SQL statement, And 34 parameters supplied.
    Looks ok to me.
    You say you have no primary key? What is RegistrationId then?
    My suggestion for debugging: start smaller.
    Try updating it with only 5 fields, then 10 then 15 and build it up like that.
    Trying to debug 35 fields is a nightmare - you have to break it down to solve it.
    Good luck,
    evnafets

  • How to Create a new column from two different result sets

    How to Create a new column from two different result sets, both the result set uses the different date dimensions.

    i got solutions for this is apply filters in column formula it self, based on the requirement.

  • How should i use the two results sets in one single report data region?

    Hi frnz,
     I have to create a report using the below condition...
    Here my given data  set query gives you the two result sets ,so how should i use that two result sets information in single report....when i accessing that data set query it will take the values off the first result set not for the second result set.
    without using sub report and look up functionality..... if possible
    is there any way to achieve this.....Please let me know..
    Thanks!

    You cant get both resultsets in SSRS. SSRS dataset will only take the first resultset
    you need to either create them as separate queries or merge them into a single resultset and return with ad additional hardcoded field which indicates resultset (ie resultset1,resultset2 etc)
    Then inside SSRS report you can filter on the field to fetch individual resultsets at required places. While merging you need to make sure metadata of two resultsets are made consistent ie number of columns and correcponding column data types should be same.
    In absence of required number of columns just put some placeholders using NULL
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Java.lang.Exception: org.hibernate.AssertionFailure: scrollable result sets

    Hi All,
    I am using Oracle 11g and I am trying to delete some records from database using some GUI. In that case I am getting following error:
    java.lang.Exception: org.hibernate.AssertionFailure: scrollable result sets are not enabled. When I restart the application's service, this error is going away and deletion is working fine.
    Other related jars that I am using is as follow:
    ojdbc5.jar
    hibernate-3.0.5.jar
    I am attaching the stack trace as well:
    <log4j:event logger="org.hibernate.AssertionFailure" timestamp="1263964931355" sequenceNumber="24" level="ERROR" thread="SocketListener0-2">
    <log4j:message><![CDATA[an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)]]></log4j:message>
    <log4j:throwable><![CDATA[org.hibernate.AssertionFailure: scrollable result sets are not enabled
    at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:368)
    at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:334)
    at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:88)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1162)
    at org.hibernate.loader.Loader.scroll(Loader.java:1634)
    at org.hibernate.loader.hql.QueryLoader.scroll(QueryLoader.java:443)
    at org.hibernate.hql.ast.QueryTranslatorImpl.scroll(QueryTranslatorImpl.java:291)
    at org.hibernate.impl.SessionImpl.scroll(SessionImpl.java:960)
    at org.hibernate.impl.QueryImpl.scroll(QueryImpl.java:62)
    at com.sample.persistence.WorklistItemDAO.purge(WorklistItemDAO.java:145)
    at com.sample.server.worklistmanager.WorklistManager.purge(WorklistManager.java:695)
    at com.sample.server.webservices.CCGPIWorklistHandler.purge(CCGPIWorklistHandler.java:329)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.xmlrpc.Invoker.execute(Invoker.java:130)
    at org.apache.xmlrpc.XmlRpcWorker.invokeHandler(XmlRpcWorker.java:84)
    at org.apache.xmlrpc.XmlRpcWorker.execute(XmlRpcWorker.java:146)
    at org.apache.xmlrpc.XmlRpcServer.execute(XmlRpcServer.java:139)
    at org.apache.xmlrpc.XmlRpcServer.execute(XmlRpcServer.java:114)
    at com.sample.server.webservices.XmlRpcServlet.service(XmlRpcServlet.java:63)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
    at org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:666)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
    at org.mortbay.http.HttpServer.service(HttpServer.java:909)
    at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
    at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
    at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
    at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
    at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
    at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
    ]]></log4j:throwable>
    </log4j:event>
    Thanks
    Shiv

    Hi All,
    anybody got a chance to look into it?
    --Shiv                                                                                                                                                                                                       

  • Result set is close exception

    here am sending with my code which i comile gets resultset is closed exception.am using this for my jsp page.
    team1Players gives the playerId of 11 players, and using this i wants to get the eir names from the second query,ie team1PlayerName.when i compile this the second query is executed and the message shows result set is closed,am not closing the result set any where.
    pls help
    package com.cricinfo.manager;
    import com.cricinfo.bizobj.*;
    import com.cricinfo.statuscodes.*;
    import java.sql.*;
    import java.util.HashMap;
    public class reporterMatchDetails
         public void reporterMatchDetails(){
         public HashMap matchDetails(Connection con,String matchId)
              HashMap <String,Object> responseMap=new HashMap <String,Object>();
              try
                   Statement st=con.createStatement();
                   String teamPlayerQuery="SELECT * from CRICINFOMATCHPLAYERTABLE where matchId='"+matchId+"'";
                   ResultSet teamPlayerSet=st.executeQuery(teamPlayerQuery);
                   if (teamPlayerSet.next())
                        String team1Players=teamPlayerSet.getString("team1PlayerId");
                        System.out.println("team1 playerId is "+team1Players);
                        String team1PlayerQuery="SELECT * FROM CRICINFOPLAYERTABLE WHERE playerId in ("+team1Players+")";
                        System.out.println(team1PlayerQuery);
                        ResultSet team1PlayerSet=st.executeQuery(team1PlayerQuery);
                        while (team1PlayerSet.next())
                             String team1PlayerId=team1PlayerSet.getString("playerId");
                             String team1PlayerName=teamPlayerSet.getString("playerName");
                             System.out.println("team1 playerId is "+team1PlayerId);
                             System.out.println("team1 PlayerName is "+team1PlayerName);
              catch (Exception e)
                   e.printStackTrace();
              return responseMap;
    }

    well i completely agree with what the previous poster has said...
    you need to associcate the second resultset to a different statement altogether in this senario.
    package com.cricinfo.manager;
    import com.cricinfo.bizobj.*;
    import com.cricinfo.statuscodes.*;
    import java.sql.*;
    import java.util.HashMap;
    public class reporterMatchDetails{
    public void reporterMatchDetails(){
    public HashMap matchDetails(Connection con,String matchId){
    HashMap <String,Object> responseMap=new HashMap <String,Object>();
    try{
    Statement st = con.createStatement();
    Statement st1 = con.createStatement();
    String teamPlayerQuery="SELECT * from CRICINFOMATCHPLAYERTABLE where matchId='"+matchId+"'";
    String team1PlayerQuery="SELECT * FROM CRICINFOPLAYERTABLE WHERE playerId in ("+team1Players+")";
    ResultSet teamPlayerSet = st.executeQuery(teamPlayerQuery);
    if (teamPlayerSet.next()){
      String team1Players=teamPlayerSet.getString("team1PlayerId");
      System.out.println("team1 playerId is "+team1Players);
      System.out.println(team1PlayerQuery);
       ResultSet team1PlayerSet=st1.executeQuery(team1PlayerQuery);
       while (team1PlayerSet.next()){
         String team1PlayerId=team1PlayerSet.getString("playerId");
         String team1PlayerName=teamPlayerSet.getString("playerName");
         System.out.println("team1 playerId is "+team1PlayerId);
         System.out.println("team1 PlayerName is "+team1PlayerName);
    catch (Exception e){
    e.printStackTrace();
    return responseMap;
    } check the above code.
    hope that might help :)
    REGARDS,
    RaHuL

  • How to use same RESULT SET for two different events

    hello friends,
    I need to use same result set for two different events. How to do it.
    here My code,
    private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {
    // TODO add your handling code here:
    try
    String selstate,selitem;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:tourismdatasource","sa","");
    selstate="select * from tab_places where state=?";
    PreparedStatement ps=con.prepareStatement(selstate);
    ps.setString(1, jComboBox1.getSelectedItem().toString().trim());
    ResultSet rs=ps.executeQuery();
    if(rs.next())
    jTextField1.setText(rs.getString("place_ID"));
    jTextField2.setText(rs.getString("place_name"));
    jTextField3.setText(rs.getString("category"));
    byte[] ba;
    ba=rs.getBytes("image");
    ImageIcon ic = new ImageIcon(ba);
    jLabel6.setIcon(ic);
    in=true;
    catch(ClassNotFoundException cfe){JOptionPane.showMessageDialog(null, cfe.getMessage());}
    catch(SQLException sqe){JOptionPane.showMessageDialog(null,sqe.getMessage());}
    Now i need the same Result Set(rs), in another event(jButton6ActionPerformed),
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    }  how do i get dat resultset,
    help me out

    One post wasn't enough?
    {color:0000ff}http://forum.java.sun.com/thread.jspa?threadID=5246634{color}
    db

  • Combining result set of two services into one result set

    Hi,
    I have a model where I am getting one result set (6 Fields) from BI query and another result set (3 Fields which gives real time values) from OLTP system. I want to show the output of these two result sets into single result set (7 Fields). I have a common field in both the result sets as key field.
    I tried this using UNION operator but I am not able to set the Key fields and also in the table view of UNION operator I am getting any field to be added to table.
    Can anyone help me to solve this problem?
    Any help is appreciated.
    Regards,
    Amit

    Hi Amit,
    in this case, you have to use the combine-operator. However, this operator needs a key-field in each of these sets. E.g. Combine set (<u>customer-id</u>, order-id, week, delivery-state) with set (<u>customer-id</u>, city, client-class).
    The combine operator might not be available when compiling to webdynpro, I did not check that.
    Best Regards, Benni

  • How to return two XML result sets using the function

    Hi Experts,
    Thanks.

    So that I want to return two XML result sets if the query returns more than 50,000 records.
    One XML result set with 50,000 and another XML result set with remaining records.
    How to incorporate this in my function.
    Have the function return a collection of CLOB then.
    DBMS_XMLGEN can handle pagination so it's easy to adapt your existing code.
    Here's an example fetching data in batches of max. 3 rows each, using a pipelined function :
    SQL> create or replace type clob_array is table of clob;
      2  /
    Type created
    SQL>
    SQL> create or replace function genXmlRowset (p_deptno in number) return clob_array pipelined
      2  is
      3    ctx    dbms_xmlgen.ctxHandle;
      4    doc    clob;
      5  begin
      6 
      7    ctx := dbms_xmlgen.newContext('SELECT empno, ename FROM scott.emp WHERE deptno = :1');
      8    dbms_xmlgen.setBindValue(ctx, '1', p_deptno);
      9    dbms_xmlgen.setMaxRows(ctx, 3);
    10 
    11    loop
    12 
    13      doc := dbms_xmlgen.getXML(ctx);
    14      exit when dbms_xmlgen.getNumRowsProcessed(ctx) = 0;
    15      pipe row (doc);
    16 
    17    end loop;
    18 
    19    dbms_xmlgen.closeContext(ctx);
    20 
    21    return;
    22 
    23  end;
    24  /
    Function created
    SQL> set long 5000
    SQL> select * from table(genXmlRowset(30));
    COLUMN_VALUE
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
      <EMPNO>7499</EMPNO>
      <ENAME>ALLEN</ENAME>
    </ROW>
    <ROW>
      <EMPNO>7521</EMPNO>
      <ENAME>WARD</ENAME>
    </ROW>
    <ROW>
      <EMPNO>7654</EMPNO>
      <ENAME>MARTIN</ENAME>
    </ROW>
    </ROWSET>
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
      <EMPNO>7698</EMPNO>
      <ENAME>BLAKE</ENAME>
    </ROW>
    <ROW>
      <EMPNO>7844</EMPNO>
      <ENAME>TURNER</ENAME>
    </ROW>
    <ROW>
      <EMPNO>7900</EMPNO>
      <ENAME>JAMES</ENAME>
    </ROW>
    </ROWSET>
    SQL>
    (and don't forget to use bind variables in your query)

  • Can I use same result set for two queries?

    Hi,
    Can I use the same result set for two queries?
    For example:
    ResultSet rs = null;
    rs = ps.executeQuery(query1);
    while (rs.next()) {
    rs = ps.executeQuery(query2);
    while (rs.next()) {
    Is it OK to use? or Is there any preformance issues?
    Appreciate your help.
    Thanks in advance.
    Prasad Vagolu

    Sure. You have a variable of ResultSet type. First you create a ResultSet and assign it to that variable. Then later you create another ResultSet and assign it to that same variable. Assigning an object reference to a variable takes essentially no time, and at any rate it isn't any faster to assign it to a different variable. Also, no matter whether you use one variable or two, you are still creating two ResultSets.
    However, you really should be closing your ResultSets after you finish using them. That's nothing to do with the assigning-to-a-variable question.

  • Advice Please: Adding Few Static Values to Stored Proc Returned Result Set

    Hello -
    The Stored Proc below returns about 1000 rows of result set when a date is passed to the query. In addition to that, there are about 5 rows of data (which is in my excel file) needs to be added to the result set. What is the best possible way?
    What I have done is I created a new table which has that 5 static rows. It has just the addresses and amount and customer number. There is no invoice date in that table. I tried UNION and the query did not like the fact that I had something like that in
    the first table:
    SELECT
    '0' as 'TYPE'
    ,'TBCCA' as 'Acc ID'
    ,'12882' as 'BEID'
    , '' as ' # OF UNITS'
    , Circuit_Total as 'AMT'
    ,'D' as 'D or C'
    , '' as ' FDOC yyyymmdd'
    , '' as ' LDOC yyyymmdd'
    , Address as 'Brief Comment'
    , city as 'Tax City'
    , State as 'Tax State'
    , Zip_Code as 'Tax Zip Code'
    , INV_DATE as 'Invoice Date'
    FROM [dbo].[TBC_MonthlyCircuitDetail]
    WHERE INV_DATE = '2014-07-01'
    AND [Circuit_Total] >0
    UNION
    SELECT 0
    '0' as 'TYPE' --DID NOT LIKE THIS <<
    ,'TBCCA' as 'Acc ID'
    ,'12882' as 'BEID'
    , '' as ' # OF UNITS'
    , Circuit_Total as 'AMT'
    ,'D' as 'D or C'
    , '' as ' FDOC yyyymmdd'
    , '' as ' LDOC yyyymmdd'
    , Address as 'Brief Comment'
    , city as 'Tax City'
    , State as 'Tax State'
    , Zip_Code as 'Tax Zip Code'
    , '' INV_DATE as 'Invoice Date'
    FROM [dbo].[TBC_MonthlyCircuitDetailStaticValues]
    WHERE INV_DATE = '2014-07-01'
    AND [Circuit_Total] >0
    Stored Proc below:
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE [dbo].[SP_TBC_ORBIT Process Form]
    -- Add the parameters for the stored procedure here
    @INVOICE_DATE varchar(20)
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    -- Insert statements for procedure here
    SELECT
    '0' as 'TYPE'
    ,'TBCCA' as 'Acc ID'
    ,'12882' as 'BEID'
    , '' as ' # OF UNITS'
    , Circuit_Total as 'AMT'
    ,'D' as 'D or C'
    , '' as ' FDOC yyyymmdd'
    , '' as ' LDOC yyyymmdd'
    , Address as 'Brief Comment'
    , city as 'Tax City'
    , State as 'Tax State'
    , Zip_Code as 'Tax Zip Code'
    , INV_DATE as 'Invoice Date'
    FROM [dbo].[TBC_MonthlyCircuitDetail]
    WHERE INV_DATE IN (@INVOICE_DATE)
    AND [Circuit_Total] >0
    END
    GO
    So, what do you suggest? As you can tell, I am quite a novice but I am learning by researching, asking questions and doing it. Thanks in advance!
    Sanjeev Jha

    Your second Select statement is as below:
    SELECT 0
      '0' as 'TYPE'
    --DID NOT LIKE THIS <<
    ,'TBCCA' as
    'Acc ID'
    ,'12882' as
    'BEID'
    , '' as
    ' # OF UNITS'
    , Circuit_Total as
    'AMT'
    ,'D' as 'D or C'
    , '' as
    ' FDOC yyyymmdd'
    , '' as
    ' LDOC yyyymmdd'
    , Address as
    'Brief Comment'
    , city as 'Tax City'
    , State as
    'Tax State'
    , Zip_Code as
    'Tax Zip Code'
    , ''INV_DATE
    as 'Invoice Date'  -- CHANGE HERE
    FROM [dbo].[TBC_MonthlyCircuitDetailStaticValues]
    WHERE INV_DATE = '2014-07-01'
    AND [Circuit_Total] >0
    You are receiving Invoice date from INV_DATE column from table or you want to set it as blank?
    Change it to either - ( '' as
    'Invoice Date' ) or  (INV_DATE as
    'Invoice Date'  )
    -Vaibhav Chaudhari

  • Can I pass parameters to a subquery to return a narrow result set?

    Hi-
    HERE'S WHAT I'M TRYING TO DO:
    Create a worksheet to aggregate the data that's returned from a subquery result set based on the user's specified date ranges.
    HERE'S MY PROBLEM:
    Discoverer is aggregating the data FOR EACH PARTICULAR DATE that shows up (ie-6/1, 6/2, 6/3) instead of across the entire specified date range (ie- 6/1-6/3) because the date parameters can only be applied to the main query instead of the subquery.
    In essence, I need to:
    SELECT location1, task1, sum(product1), max(product2)
    FROM
    (SELECT * FROM table1 WHERE date1 >= userSpecifiedDate1 and date1 <= userSpecifiedDate2)
    GROUP BY location1, task1
    ...but using Discoverer's "Parameters" and "Totals" tool, so far I can only get Discoverer to do this :
    SELECT location1, task1, sum(product1), max(product2), sum(product3)
    FROM
    (SELECT * FROM table1)
    WHERE date >= userSpecifiedDate1 and date <= userSpecifiedDate2
    GROUP BY location1, task1
    Is there any way to apply date parameters to the subquery first so I'm aggregating across the range and not on each date?
    Hope this makes sense. Any suggestions would be appreciated!

    Hi,
    Yes.
    You can pass parameter from search criteria to procedure.
    First u need write a method in the AmImpl java class to call the procedure.
    Like
    public void callingProcWithinParams(String sreachCriterParam)
    //pass the parameter to proc
    Then shuttle this method to client interface.

Maybe you are looking for