Using the Previous Row in a Calculator Formula

Hello.  I am using the calculator to create a new channel that is a custom filtered version of an existing channel.  Unfortunately, I have not been able to identify the previous row entry in the channel.  To make things easier, let's say my filter is a simple averager.  Here is simple pseudocode for what I want to do:
New_Channel = (Existing_Channel[n] + Existing_Channel[n-1]) / 2
where n is the current row.
This is the calculator formula I have come up with:
ch("[1]/New_Channel") = (CHD(chnRow - 1, "[1]/Existing_Channel") + ch("[1]/Existing_Channel")) / 2 + CTNV(chnRow > 1)
Unfortunately, I think chnRow only returns 0.
Obviously, I am a beginner.  I am open to other approaches to creating a new channel with a custom filter. 
Thanks!
Solved!
Go to Solution.

Hi jbuttron,
What you need to do is to copy the channel and delete the first value from the copied channel-- then the Nth row of the original channel will line up with the (N-1)th row of the copied channel.  You should also add the last value of the copied channel to the end of that channel as a new value so both channels end up with the same channel length.  Now you can reference the channels with Ch("[1]/old") and Ch("[1]/new") in the channel calculator expression, assuming that the channel names are "old" and "new" respectively and that both are in the first group.  You don't need a row variable in the expression now, which is good because there's no way to iterate a row variable in a channel calculator expression.  The row iteration is implicit in the channel referencing Ch("[1]/new").
Brad Turpin
DIAdem Product Support Engineer
National Instruments

Similar Messages

  • Multivalue error when using the previous() function

    I am getting a multivalue error when using the previous() function on a dimension object in the report.  I thought that the previous function was supposed to look at the current report and then look at the previous record's contents.  How could this possibly give me a multivalue error when the value is clearly output in the previous row?  Anyone have any ideas?
    By the way, this is a valuable function for the types of reports that I design.  The next() function would be even more valuable.
    Thanks for your help.

    Hi Michael,
    Could you please test the following solutions it might help you to resolve the issue.
    Solution1:
    Use slice and dice to reset all the tables that have #multivalue in it. The only problem with this workaround is they have to do the formatting manually.
    Solution2:
    Also, test the issue by changing the object to dimension if it is a measure or to measure if it is a dimension.
    Regards,
    Sarbhjeet Kaur

  • Display only data different from the previous row

    Hello,
    I will use a simple example to explain what I would like to do with a query.
    I have a table 'test' with 4 columns (col1, col2, col3, col4).
    The table 'test' contains the following data:
    A  B  C  D
    A  E  C  D
    A  F  G  D
    K  F  G  HI would like to create a query ordered on the first column with the following result:
    A  B  C  D
       E
       F  G
    K        HOnly data that are different from the previous row have to be displayed.
    Do you have ideas on how to do this.
    Thanks for your help

    SQL> l
      1  select
      2  decode(a,lag(a) over (order by a),null,a) a,
      3  decode(b,lag(b) over (order by a),null,b) b,
      4  decode(c,lag(c) over (order by a),null,c) c,
      5  decode(d,lag(d) over (order by a),null,d) d
      6  from
      7  (
      8  select 'A' a,'B' b,'C' c , 'D' d from dual
      9  union
    10  select 'A' a,'E' b,'C' c , 'D' d from dual
    11  union
    12  select 'A' a,'F' b,'G' c , 'D' d from dual
    13  union
    14  select 'K' a,'F' b,'G' c , 'H' d from dual
    15* )
    SQL> /
    A B C D
    A B C D
      E
      F G
    K     H

  • Setting the Previous row with New row value

    Dear All,
    I have a af:showDetailItem in which i have a af:table where i can add the Warranty details of Products in which i have:
    eg:
    Product | WEF | ValidUntil
    ================================================
    Prod1 | 01-05-11 | 01-06-11
    Prod2 | 02-06-11 |
    Here i want to enter the "Valid Until" only when i create an entry for new Warrenty details and enter the WEF.ie Valid Until will be WEF-1 of the next row.
    so any idea of how to solve this problem.?
    Regards,
    Soya.

    Hi,
    Aren't effective-dated entities used to create a new column based on some existing column in the same row.
    But my need is to set the value of the previous row when the new row is inserted.
    Product | WEF | ValidUntil
    ================================================
    Prod1 | 01-05-11 | *01-06-11*
    Prod2 | *02-06-11* |
    rgds
    Soya

  • 10.2 crashes when I try to convert old libraries for use in the new software. Is there a workaround for this? Or will i have to continue using the previous version to complete older projects?

    Final Cut Pro X 10.2 crashes when I try to convert old libraries for use in the new software. Is there a workaround for this? Or will I have to continue using the previous version to complete older projects? the only foreseeable solution is to begin any new projects on 10.2 or importing footage on 10.2 and starting form scratch--which is something i definitely don't want to do or have time to do. ANY advice, thoughts, or opinions would be greatly appreciated! Thank you!
    Running 10.10.3 // MacBook Pro (Retina, 15-inch, Early 2013) // 2.4 GHz Intel Core i7 // 8 GB 1600 MHz DDR3

    Exactly the same problem with me.
    Some other threads advice to remove fonts, clean the caches, remove add ins but nothing works consistenty, for some it looks like it works, for me it failed.
    What I did not try yet, was to move the Render files out of the malicious library to trash.

  • I have a document made up of separate PDF files which reside in a folder and are linked to each other via hyperlinks. Each pdf file is set to open with bookmarks displayed, however if I link from one PDF file to another and use the "Previous View" button

    I have a document made up of separate PDF files which reside in a folder and are linked to each other via hyperlinks. Each pdf file is set to open with bookmarks displayed, however if I link from one PDF file to another and use the "Previous View" button to navigate back to my starting point the bookmarks are replaced by "page thumbnails". Is there anyway to stop this from happening?

    Hi Pusman,
    While setting up the links, if you choose to open the file in a new window then you won't face this issue, then you can simply switch to the previous file and bookmark view will remain as it is.
    Does that helps with your query?
    Regards,
    Rahul

  • I wish to use the previous version not the one that has today been automatically installed. My settings were to let me know and I decide to install when I'm ready

    I wish to use the previous version not the one that has today been automatically installed. My settings were to let me know and I decide to install when I'm ready, how do I go back. This because one of the previous Plugins does not work with this version, and they have no fix for it yet!

    FOR ASSISTANCE WITH ORDERS - iTUNES STORE CUSTOMER SERVICE
    For assistance with billing questions or other order inquiries, please refer to our online support page by clicking here: http://www.apple.com/support/itunes/store/. If you cannot find the answers you are seeking in our robust knowledge base, you can contact us by visiting the following URL http://www.apple.com/support/itunes/store/, clicking on the appropriate Customer Service topic, then using the contact button or email form at the bottom of the page. Responses to emails will be provided as soon as possible.
    Phone: 800-275-2273 How to reach a live person: Press 0 four times
    Hours of Operation: Mon-Fri: 9am-5pm ET
    Email: [email protected]
    How to report an issue with Your iTunes Store purchase
    http://support.apple.com/kb/HT1933
    How to Get a Refund from the App Store
    http://gizmodo.com/5886683/how-to-get-a-refund-from-the-app-store
    Canceling a Digital Subscription
    http://gadgetwise.blogs.nytimes.com/2011/10/14/qa-canceling-a-digital-subscripti on/
     Cheers, Tom

  • We purchased Lion OS in April and uploaded to our iMac and now want to upgrade out MacPro.  We cannot figure out how to use the previous purchase (says you can use on 3 computers)....confused.  How do we begin the process using our previous purchase?

    We Purchased Lion OS in April and uploaded to our iMac.  We are now ready to upgrade our MacPro, but can't seem to find out how to upgrade using the previous purchase (said we could use the Lion OS purchase on up to 3 devices).  We have the receipt of purchase with the Order # and Purchase #, but I just can't figure out how to do the upgrade.  Where do I go?  What reference # do I enter?

    Go back to the App Store with the same Apple ID you used to purchase Lion. It should show up in your Purchases list ready to download. If it doesn't, log out, log back in, and hold down Option key while clicking on Purchases.
    A tip: Once the download is finished, dismiss the Installer. Go to your Applications folder and find it - copy it to another folder or hard drive to keep for emergency purposes. Then click on that installer and install (it is automatically removed/deleted after the installation is complete). That way you can avoid having to do another lengthy download.
    And, yes, just to confirm: you can install Lion on as many Macs you own and control. However, the license is not transferable; if you ever sell the machine, you need to erase Lion and reinstall the original OS.
    You don't go to iTunes - go to the Mac App Store (in your Applications folder). You do need 10.6.6 (or 10.6.8) to have the Mac app store.

  • I have just installed Digital Editions 4.3 but am having poblems downloading digital books as I get an error message stating 'Error! Check Activation'. I have Windows 7 and didn't have any problems using the previous version of Digital Editions. Can anyon

    I have just installed Digital Editions 4.3 but am having poblems downloading digital books as I get an error message stating 'Error! Check Activation'. I have Windows 7 and didn't have any problems using the previous version of Digital Editions. Can anyone advise?

    Hi Siobhan ,
    Please refer to the following link and see if that helps.
    https://helpx.adobe.com/digital-editions/kb/error-e_act_not_ready.html
    I would also like to know ,does that error message has any specific number ?
    Regards
    Sukrit Dhingra

  • I recently purchased a brand new Airport Time Capsule 2TB. I already am using the previous generation time capsule to back up all my computers data. May I ask how can I complement the usage with my new time capsule?

    I recently purchased a brand new Airport Time Capsule 2TB. I already am using the previous generation time capsule to back up all my computers data. May I ask how can I complement the usage with my new time capsule?

    By default your new Time Capsule will broadcast an unsecured wireless network with a network name of something like: Apple Network NNNNNN
    Most likely your iMacs will be connected to the wireless network created by the Virgin Media router. However, both should see the Apple Network under the AirPort icon's drop-down menu as another wireless network that they can connect to. Is this not the case?

  • How to get the previous row selected index of a table....

    Hi friends,
    I have a table. i have a action/event handler defined on its onLeadSelect event.
    In this event, if i use node_code->get_lead_selection_index( ) .. i m getting the newly clicked row index.
    ex: table has 3 rows.
    Row 1 is by default selected. Now if i select the row 3, in my event by using node_code->get_lead_selection_index( ). im getting index 3. which i sel
    But i want to get index 1. 
    kindly help me.. i dont have any other option as i m very new to this.
    hope i gave u correct inputs on my problem.
    thanks in advance,
    Niraja

    One way to achieve this is to maintain an attribute in the assistance class or a node element , called OldLeadSelection , at the Component controller level which stores the value of the lead selection index.
    On LeadSelect action handler method, in the first line, read the value of the attribute/element defined above. For the first time a row is lead selected, this value will be initial. After exexcuting the code in the LeadSelection event handler method, store the LeadSelection index value in the attribute defined above. The next time when the LeadSelection event method is called, when the value of this attribute is read in the initial line, it will house the value of the index of the previous LeadSelection.
    There could be other ways to achieve this. This is one of the methods.
    Best Regards,
    Rashmi.

  • JSP:I changed a class but WHY IT WANTS TO USE THE PREVIOUS ONE? HELP!!!!!!!

    I am using HTMLform+JSP+javabean for executing a query into the database end showing the retrieved values.
    For Building the query end Executing the query SQLQueryBean.class was used and it worked;
    For showing retrieved values SQLResultSetBean.class was used: but the error page displaied cannot instanciate sql.SQLResultSetBean
    After having tried many stuff I changed SQLResultSetBean with SQLQueryResultsBean.java that pratically works in a similar manner but I received error related with SQLResultSetBean.class ...WHY MY CHANGES HAVE NOT BEEN UPDATED?
    This Is the jsp file:
    <%@ page language="java"
    import="java.sql.*, java.io.*, java.util.*, java.lang.*"
    errorPage="errorpage.jsp"
    %>
    <jsp:useBean id="query" scope="page" class="sql.SQLQueryBean" />
    <jsp:setProperty name="query" property="*"/>
    </jsp:useBean>
    <%--I TRIED TO HIDE THIS CODE BUT IT WAS USELESS
    <jsp:useBean id="results" scope="page" class="sql.SQLQueryResultsBean" />
    <jsp:setProperty name="results" property="*"/>
    </jsp:useBean>
    --%>
    <jsp:useBean id="oneRow" scope="page" class="sql.SQLRow" />
    <jsp:setProperty name="oneRow" property="*"/>
    </jsp:useBean>
    <html>
    <body bgcolor="white">
    <%! Integer identifier;%>
    <%! String general; %>
    <%! String[] ingr; %>
    <%! Vector column = new Vector(); %>
    <%! Vector whereCols = new Vector(); %>
    <%! String myQuery = null; %>
    <%-- ***** ACTION 1: Searching pizza names by ingredients! **** --%>
    <%
    String action = request.getParameter("action1");
    if(action.equals("Search pizza")){
    %>
    <%-- ***** SETTING Database, table and columns for SELECT clause **** --%>
    <hr>
    <font size = 5 color ="red">
    <center>
    DEBUG:<br>
    </font>
    <font size = 2 color ="blue">
    database: <%query.setDatabase("testkatia");
    out.println(query.getDatabase());%>
    <br>
    table: <%query.setTable("relation1");
    out.println(query.getTable());
    query.selectColumns("pizza_id");
    query.isDistinct(true);
    column = query.getColumns();
    %>
    <br>
    selected column(s) is(are):
    <ul>
    <%
    if (!column.isEmpty()) {
         for (int i = 0; i < column.size(); i++) {
    %>
    <li>
    <%
              out.println (column.get(i));
         } else out.println ("none selected");
    %>
    </ul>
    </font>
    <hr>
    <%-- ***** SETTING columns value and oper. for the WHERE clause **** --%>
    <%
    ingr = request.getParameterValues("Checkbox1");
    if(ingr!= null){
    for(int i = 1; i <=ingr.length; i++){
    if(i>1 && i<=ingr.length)
    query.selectAnd_OrForWhere("or");
    for(int j=1; j<=24; j++){
    if(ingr[i-1].equals(("ing"+j))){
    general = String.valueOf(j);
    query.selectWhereParameters("pizzaing_id","=",general, "integer");
    %>
    <font size=5 color ="red">
    DEBUG:
    </font>
    <font size = 2 color ="blue">
    <%
    if(query.checkWhereParameters()){
    out.println("Where Clause is Ok");
    %>
    <br>
    <%
    whereCols=query.getColsForWhere();
    out.println("Cols for Where; "+ whereCols.toString());
    else {
    throw new Exception("parameters in the where clause are wrong!n whereClause = "+ query.getWhereClause());
    %>
    </font>
    <hr>
    <font size = 5 color ="red">
    <center>
    DEBUG:<br>
    </font>
    <font size =2 color= "blue">
    The built query is: <%myQuery = query.buildQuery();
    out.println(myQuery);
    %>
    <%--
    <%!Vector rows = new Vector();%>
    <%
    if(myQuery!=null){
    results = myQuery.queryExe(sqlQuery);
    if(results == null) out.print("<br>SQLQueryResultsBean obj is NULL!");
    out.println("<br>---retrieved row num. is--- "+results.getRowNumber());
    out.println("<br>---Number of columns is--- "+results.getColNumber());
    rows = results.getRetrievedRows();
    if(!rows.isEmpty()){
    out.print("col.: ");
    for(int k= 0; k<results.getColNumber(); k++)
         out.print((String)results.getColNames().get(k)+" ");
    out.println("<br>");
    for(int i=0; i < results.getRowNumber(); i++){
         oneRow = (sql.SQLRow)rows.get(i);
         out.print("<br>row"+(i+1)+": ");
         for(int j=0; j<oneRow.rowSize(); j++)
         out.print((String)oneRow.getRowValue(j)+" ");
         out.println("<br>");
    %>
    --%>
    </body>
    </html>
    The error that I got is:
    Error: 500
    Location: /goreme/jspFiles/searchPizzaOrIngr.jsp
    Internal Servlet Error:
    javax.servlet.ServletException: sql/SQLResultSetBean
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java)
    at org.apache.tomcat.core.Handler.service(Handler.java)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java)
    at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java)
    at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java)
    at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java)
    at java.lang.Thread.run(Thread.java:498)
    Root cause:
    java.lang.NoClassDefFoundError: sql/SQLResultSetBean
    at java.lang.Class.getMethods0(Native Method)
    at java.lang.Class.getDeclaredMethods(Class.java:1071)
    at java.beans.Introspector$1.run(Introspector.java:858)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:856)
    at java.beans.Introspector.getTargetEventInfo(Introspector.java:562)
    at java.beans.Introspector.getBeanInfo(Introspector.java:300)
    at java.beans.Introspector.getBeanInfo(Introspector.java:87)
    at org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java)
    at org.apache.jasper.runtime.JspRuntimeLibrary.introspect(JspRuntimeLibrary.java)
    at jspFiles._0002fjspFiles_0002fsearchPizzaOrIngr_0002ejspsearchPizzaOrIngr_jsp_70._jspService(_0002fjspFiles_0002fsearchPizzaOrIngr_0002ejspsearchPizzaOrIngr_jsp_70.java:111)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java)
    at org.apache.tomcat.core.Handler.service(Handler.java)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java)
    at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java)
    at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java)
    at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java)
    at java.lang.Thread.run(Thread.java:498)
    Does somebody know what happened and why it continues to search SQLResultSetBean.class?...I have also restarted tomcat!!!![b]
    Please drop me some helps! It would be really nice!
    katia

    THANKS A LOT!
    I am going on like a snail but maybe before die I will see this project works!
    Unfortunately now I have got the previous error: that said:
    "Error Page
    Received the exception:
    javax.servlet.ServletException: Cannot create bean of class sql.SQLQueryResultsBean"
    While If I remouve the usebean tag for sql.SQLQueryResultsBean it dislpaied:
    DEBUG:
    database: testkatia
    table: relation1
    selected column(s) is(are):pizza_id
    DEBUG: Where Clause is Ok
    Cols for Where; [pizzaing_id, pizzaing_id, pizzaing_id]
    DEBUG:
    The built query is: SELECT DISTINCT pizza_id FROM relation1 WHERE pizzaing_id = 1 or pizzaing_id = 2 or pizzaing_id = 3
    The built where clause is: WHERE pizzaing_id = 1 or pizzaing_id = 2 or pizzaing_id = 3
    So why Cannot create SQLQueryResultsBean ?
    JSP
    All the code is here:
    <%@ page language="java"
    import="java.sql.*, java.io.*, java.util.*, java.lang.*"
    errorPage="errorpage.jsp"
    %>
    <jsp:useBean id="query" scope="page" class="sql.SQLQueryBean" />
    <jsp:setProperty name="query" property="*"/>
    </jsp:useBean>
    <%--
    <jsp:useBean id="results" scope="page" class="sql.SQLQueryResultsBean" />
    <jsp:setProperty name="results" property="*"/>
    </jsp:useBean>
    --%>
    <jsp:useBean id="oneRow" scope="page" class="sql.SQLRow" />
    <jsp:setProperty name="oneRow" property="*"/>
    </jsp:useBean>
    <html>
    <body bgcolor="white">
    <%! Integer identifier;%>
    <%! String general; %>
    <%! String[] ingr; %>
    <%! Vector column = new Vector(); %>
    <%! Vector whereCols = new Vector(); %>
    <%! String myQuery = null; %>
    <%-- ***** ACTION 1: Searching pizza names by ingredients! **** --%>
    <%
    String action = request.getParameter("action1");
    if(action.equals("Search pizza")){
    %>
    <%-- ***** SETTING Database, table and columns for SELECT clause **** --%>
    <hr>
    <font size = 5 color ="red">
    <center>
    DEBUG:<br>
    </font>
    <font size = 2 color ="blue">
    database: <%query.setDatabase("testkatia");
    out.println(query.getDatabase());%>
    <br>
    table: <%query.setTable("relation1");
    out.println(query.getTable());
    query.selectColumns("pizza_id");
    query.isDistinct(true);
    column = query.getColumns();
    %>
    <br>
    selected column(s) is(are):
    <ul>
    <%
    if (!column.isEmpty()) {
         for (int i = 0; i < column.size(); i++) {
    %>
    <li>
    <%
              out.println (column.get(i));
         } else out.println ("none selected");
    %>
    </ul>
    </font>
    <hr>
    <%-- ***** SETTING columns value and oper. for the WHERE clause **** --%>
    <%
    ingr = request.getParameterValues("Checkbox1");
    if(ingr!= null){
    for(int i = 1; i <=ingr.length; i++){
    if(i>1 && i<=ingr.length)
    query.selectAnd_OrForWhere("or");
    for(int j=1; j<=24; j++){
    if(ingr[i-1].equals(("ing"+j))){
    general = String.valueOf(j);
    query.selectWhereParameters("pizzaing_id","=",general, "integer");
    %>
    <font size=5 color ="red">
    DEBUG:
    </font>
    <font size = 2 color ="blue">
    <%
    if(query.checkWhereParameters()){
    out.println("Where Clause is Ok");
    %>
    <br>
    <%
    whereCols=query.getColsForWhere();
    out.println("Cols for Where; "+ whereCols.toString());
    else {
    throw new Exception("parameters in the where clause are wrong!n whereClause = "+ query.getWhereClause());
    %>
    </font>
    <hr>
    <font size = 5 color ="red">
    <center>
    DEBUG:<br>
    </font>
    <font size =2 color= "blue">
    The built query is: <%myQuery = query.buildQuery();
    out.println(myQuery);
    %>
    <br>
    The built where clause is:
    <%
    out.println(query.getWhereClause());
    %>
    </font>
    </center>
    <hr>
    <%
    %>
    <%--
    <%!Vector rows = new Vector();%>
    <%
    if(myQuery!=null){
    results = myQuery.queryExe(sqlQuery);
    if(results == null) out.print("<br>SQLQueryResultsBean obj is NULL!");
    out.println("<br>---retrieved row num. is--- "+results.getRowNumber());
    out.println("<br>---Number of columns is--- "+results.getColNumber());
    rows = results.getRetrievedRows();
    if(!rows.isEmpty()){
    out.print("col.: ");
    for(int k= 0; k<results.getColNumber(); k++)
         out.print((String)results.getColNames().get(k)+" ");
    out.println("<br>");
    for(int i=0; i < results.getRowNumber(); i++){
         oneRow = (sql.SQLRow)rows.get(i);
         out.print("<br>row"+(i+1)+": ");
         for(int j=0; j<oneRow.rowSize(); j++)
         out.print((String)oneRow.getRowValue(j)+" ");
         out.println("<br>");
    %>
    --%>
    </body>
    </html>
    SQLQueryResultsBean
    package sql;
    import java.sql.*;
    import java.util.*;
    public class SQLQueryResultsBean {
    String _sqlQuery;
    ResultSet resultSet;
    int colNumber;
    int rowNumber;
    Vector colTypes = new Vector();
    Vector colNames = new Vector();
    Vector _retrievedRows = new Vector();   
    //Constructor IS IT THIS THE PROBLEM?
    public SQLQueryResultsBean(ResultSet rs){
         this.setResultSet(rs);
    //Methods for setting and retrieving the ResultSet object
    public void setResultSet(ResultSet rs){
         resultSet = rs;
    public ResultSet getResultSet(){
         return resultSet;
    //Methods for setting and retrieving the Number of the column
    public void setColNumber(int n){
         colNumber = n;
    public int getColNumber(){
         return colNumber;
    //Methods for setting and retrieving a vector containing all the names of the selected columns
    public void setColNames(Vector c){
         colNames = c;
    public Vector getColNames(){
         return colNames;
    //Methods for setting and retrieving a vector containing all the types of the selected columns
    public void setColTypes(Vector t){
         colTypes = t;
    public Vector getColTypes(){
         return colTypes;
    //Methods for setting and retrieving the number of the selected rows
    public void setRowNumber(int n){
         rowNumber = n;
    public int getRowNumber(){
         return rowNumber;
    //Methods for storing and retrieving the rows selected with the query;
    public void setRetrievedRows(Vector retrievedRows){
         _retrievedRows = retrievedRows;
    public Vector getRetrievedRows(){
         return _retrievedRows;
    //-----STORING THE RESULTS IN CLASS VARIABLES-----
    //-----TYPES, NAMES, NUMBERS OF THE COLUMNS OF A GENERIC ROW AND-----
    //-----FOR STORING THE NUMBER OF THE RETRIEVED ROWS-----
    //storing the results before to close the connection
    public void storeValues() throws SQLException {
    ResultSet rs = this.getResultSet();
    Vector rows = new Vector();
    String value;
    this.setRowNumber(this.countRowNumber());//set number of rows
    this.setParameters(); //set number, types and names of the columns
    //We Move the cursor to the given row number in this ResultSet object.
    for(int i = 0; i<this.getRowNumber(); i++){
         rs.absolute(i+1);
         SQLRow newRow = new SQLRow();
         //Then we retrieve values end collect them in a vector
         for (int j=0; j<this.getColNumber(); j++){
         value =rs.getString(j+1);
         newRow.buildRow(value);
         rows.add(newRow.getRow());
    this.setRetrievedRows(rows);
    //Methods for automatically setting this parameters:
    //columnNumber, colNames, coltypes.
    //It is not public but used inside storeValues();
    void setParameters(){
         try{
         ResultSetMetaData meta = this.getResultSet().getMetaData();
         int totColumns = meta.getColumnCount();
         this.setColNumber(totColumns);
         Vector names = new Vector();
         Vector types = new Vector();
         for (int i=1; i<=totColumns; i++){
         names.add(meta.getColumnName(i));
         types.add(meta.getColumnTypeName(i));
         this.setColNames(names);
         this.setColTypes(types);
         }catch(Exception e){e.printStackTrace();}
    //Methods for counting the number of the selected rows.
    //It is not public but used inside storeValue();
    int countRowNumber(){
         int count=0;
         try{
         ResultSet rs = this.getResultSet();
         // Moving the cursor to the front of this
         //ResultSet object, just before the first row.
         rs.beforeFirst();
         while(rs.next())
         count++;
         rs.beforeFirst(); //replacecing cursor before the first row
         }catch(Exception e){e.printStackTrace();}
         return count;
    If you (or someone on this forum) have any ideas for that I will be really grateful!
    katia

  • How to get cumulative decreasing values by substracting from the previous row.... in a dynamic added

    I have pdf table like this:-
    Header 1
    Header 2
    Header 3
    Header 4
    Header 5
    Header 6
    Header 7
    From
    To
    No. of Days
    Balance
    Date
    1
    2
    <ADD Button> / <Del Button>
    3
    4
    5
    This
    Row
    is
    730
    to
    be
    hidden
    DateFieldFrom
    DateFieldTo
    DateFieldTo-DateFieldFrom(Some No1.)
    Remaining1=uppervalue(730)-Some No1.
    Now when i click the <add  rows button>  rows are to be added and i have to get the valuesof Remaining2(Remaining1- Some No.2 )in the Added Balance Row
    how will i do this?

    Hi Luis,
    According to your description, you have a report with different dynamic columns. Now what you want is show your user percentage growth in your matrix report after your user select two of those columns (I think you may use parameter to achieve your “checkbox”
    function). Is my understanding correct?
    In Reporting Service, we can’t calculate dynamic columns with our build-in arrogation functions. So we need to add custom code into our report, and call those functions which defined in custom code in our expression. We have tested your scenario in our local
    environment. Here are steps and screenshots for your reference.
    Go to your Report Properties, add the custom code below into your report:
    Dim Shared Num1 As Double
    Dim shared Num2 As Double
    Public Function GetCalification(Calification as Double,Type as String,Type2 as String) 
    If Type = Type2 Then
       Num1=Calification
    Else
       Num2=Calification
    End If 
    Return Calification 
    End Function
    Public Function GetPec()
    Return (Num2-Num1)/Num1
    End function
    Create a matrix. Put PilarName into Row field, put Period into Column field. In Data field, put the expression below into the textbox:
    =Code.GetCalification(Fields!Calification.Value,Fields!Period.Value,Parameters!Period.Value(0))
    In our sample report, we created a parameter (named Period) for selecting two columns. You can replace “Parameters!Period.Value(0)” with your own parameter.
    Add an outside column at right (%Growth), put the expression below into the textbox:
    =Code.GetPec()
    Save and preview. The matrix and result looks like below:
    Reference:
    Custom Code and Assembly References in Expressions in Report Designer (SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • I bought my iphone second hand and when i tried to activate it it siad i had to use the previous account

    please help !!

    With iOS 7 activation lock, you need to know the previous owners AppleID password, or have them remove the device from their iCloud account.  Otherwise, you will never be able to use that device.
    So get in touch with the previous owner as otherwise, you now own a brick.

  • How to use the first row function value for the rest of records

    Hi all,
    I am having a select statement like this. We are calling function enabled for each row. So it is taking
    time. As per our bussiness logic, we can use what the function 'enabled' will give for the first row to
    other rows also. so that we can avoid calling the function 'enabled' next row onwars.
    Before
    SELECT
    decode(enabled(col1, col2, col3),'TRUE','xxx', col4),
    decode(enabled(col1, col2, col3),'TRUE','xxx', col5),
    decode(enabled(col1, col2, col3),'TRUE','xxx', col6),
    decode(enabled(col1, col2, col3),'TRUE','xxx', col7),
    decode(enabled(col1, col2, col3),'TRUE','xxx', col8),
    from
    table1 t1, table2 t2 where t1.col1 = t2.col1
    After
    SELECT
    decode(enabled(col1, col2, col3),'TRUE','xxx', col4),
    decode('true/false','TRUE','xxx', col5), --Here 'true/false' is the first row value after calling the function 'enabled'
    decode('true/false','TRUE','xxx', col6),
    decode('true/false','TRUE','xxx', col7),
    decode('true/false','TRUE','xxx', col8),
    from
    table1 t1, table2 t2 where t1.col1 = t2.col1
    Any thoughts on this, how to implement this logic
    Thanks,
    Pal

    It's not clear where col1, col2, col3... etc. come from, so I've assumed they're in table1.
    with table1_X as (select enabled(col1, col2, col3) as enbl
                            ,col1, col2, col3, col4, col5, col6, col7, col8
                      from   table1)
    SELECT decode(t1.enbl,'TRUE','xxx', col4)
          ,decode(t1.enbl,'TRUE','xxx', col5)
          ,decode(t1.enbl,'TRUE','xxx', col6),
          ,decode(t1.enbl,'TRUE','xxx', col7),
          ,decode(t1.enbl,'TRUE','xxx', col8),
    from   table1_x t1 join table2 t2 on (t1.col1 = t2.col1)p.s. you'd be better leaving out the enabled function altogether and incorporating the logic of the function directly in the SQL, and then you would be avoiding any context switching which will clearly impact performance on any large amount of data.
    Edited by: BluShadow on 14-May-2013 08:26

Maybe you are looking for

  • Stack icons

    I just got a new Mac Pro a couple weeks ago, switching from Windows. I like the stacks in the dock, but I didn't like the fact that the icon in the dock changes to the first file in the directory. This especially bothered me for stack I put in for th

  • Reg: HU2 System

    Hi All, Can i use HU2 system as a sand box to learn ABAP and functional like fico...? I think the system is for navigation, testing....etc Regards, Venu V

  • Unix command to require password to wake computer from sleep or screensaver

    Yo folks, Just as the subject says, is there a Unix command we can send that turns on the option to require password when the computer wakes from sleep or screensaver...which is the first option in System Preferences --> Security? I looked through th

  • Podcasts syncing in random order

    I just downloaded itunes 9 and 3.1.1 for my second gen ipod touch. Now my podcasts appear to be in random order on the touch. They are in order in itunes. Any idea on how to sort them so they play by date episode?

  • Calling Captivate HTML5 Output from an application

    I want to call Adobe HTML5 and Flash Captivate published output from an application.  There are several issues I'm currently experiencing duing this: 1) Iframe.  Using an Iframe works for the most part, except that we are hosting many Captivate prese