Report Control and Multiple Datasets/Result Sets

I have four results sets, Plan, Forecast, Actual and SPLY per eight different product lines.  I want to add conditional formatting of background color if actual is above or below Plan and/or Forecast.  The report needs to export properly to Excel.
 Is there a way I can use one control rather than multiple text boxes to display the data, allow for conditional formatting and export to Excel.?  Thanks!
Environment:
SSRS 2010
SQL Server 2012

Hi blairv,
If I understand correctly, you have a dataset in the report which include four fields: Plan, Forecast, Actual and SPLY. Each filed contains eight values.
In SQL Server Reporting Services (SSRS), we can use table, matrix or list display report data in cells. The cells typically contain text data such as text, dates, and numbers but they can also contain gauges, charts, or report items such as images.
Reference: http://technet.microsoft.com/en-us/library/dd220592.aspx
In your case, we can use expression to configure these items background color. Please refer to the following steps:
Click a specific text box in the report. Click BackgroundColor prompt in the Properties dialog box.
Click Expression prompt. And fill with expression below:
=IIF(Fields! Actual.Value>Fields! Plan.Valeu Or Fields! Actual.Value>Fields! Forecast.Valeu,”Red”,”Blue”)
Reference: http://msdn.microsoft.com/en-us/library/ms157328.aspx
If there are any miunderstanding, please feel free to let me know.
Regards,
Alisa Tang
If you have any feedback on our support, please click
here.
Alisa Tang
TechNet Community Support

Similar Messages

  • Minus and passing the result set

    I have a query in a procedure....let us say "test.prc":
    select A.VALUE from TABLE A
    where A.VALUE_ID = get_rec.VALUE_ID minus
    select B.VALUE from TABLE B
    In the above query, I am passing the "get_rec.VALUE_ID" from a cursor above the query.
    Now is there a way to capture the result set of the above minus operation and pass the result set to the calling sql program (called "call_test.sql")?
    Thanks,
    Chiru
    Message was edited by:
    Megastar_Chiru

    I got what I was trying to do...
    I have 1 more question though....I am printing out my output using dbms package from sql*plus...using the following command
    dbms_output.put_line(nvl('Flex Value set Id : '||get_rec.flex_value_set_id,0)||' values that have no corresponding alias : ' || nvl(v_flex_val,0));
    "get_rec.flex_value_set_id" gets passed in from my cursor above the dbms statement.
    and it looks like below:
    Flex Value set Id : 20118 values that have no corresponding alias : 00
    Flex Value set Id : 20118 values that have no corresponding alias : 10
    Flex Value set Id : 20118 values that have no corresponding alias : 11
    Flex Value set Id : 20118 values that have no corresponding alias : 20
    Flex Value set Id : 20118 values that have no corresponding alias : 30
    Flex Value set Id : 20124 values that have no corresponding alias : Standard
    Is there some way to neatly break when the value set id changes? ...ie., make it print output something like below:
    Flex Value set Id : 20118
    values that have no corresponding alias : 00
    values that have no corresponding alias : 10
    values that have no corresponding alias : 11
    values that have no corresponding alias : 20
    values that have no corresponding alias : 30
    Flex Value set Id : 20124
    values that have no corresponding alias : Standard
    Thanks,
    Chiru

  • Multiple Active Result Sets (MARS)

    What's the meaning of Multiple Active Result Sets (MARS)?
    Michael

    MARS means not being limited to a single open DataReader per connection. MARS is an enhancement for the Sql Server client in .NET 2.0. Oracle never had this limitation to begin with.
    David

  • JSP Servlet and convert the result set of an SQL Query To XML file

    Hi all
    I have a problem to export my SQL query is resulty into an XML file I had fixed my servlet and JSP so that i can display all the records into my database and that the goal .Now I want to get the result set into JSP so that i can create an XML file from that result set from the jsp code.
    thisis my servlet which will call the jsp page and the jsp just behind it.
    //this is the servlet
    import java.io.*;
    import java.lang.reflect.Array;
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.naming.*;
    import javax.sql.*;
    public *class *Campaign *extends *HttpServlet
    *private* *final* *static* Logger +log+ = Logger.+getLogger+(Campaign.*class*.getName());
    *private* *final* *static* String +DATASOURCE_NAME+ = "jdbc/SampleDB";
    *private* DataSource _dataSource;
    *public* *void* setDataSource(DataSource dataSource)
    _dataSource = dataSource;
    *public* DataSource getDataSource()
    *return* _dataSource;
    *public* *void* init()
    *throws* ServletException
    *if* (_dataSource == *null*) {
    *try* {
    Context env = (Context) *new* InitialContext().lookup("java:comp/env");
    _dataSource = (DataSource) env.lookup(+DATASOURCE_NAME+);
    *if* (_dataSource == *null*)
    *throw* *new* ServletException("`" + +DATASOURCE_NAME+ + "' is an unknown DataSource");
    } *catch* (NamingException e) {
    *throw* *new* ServletException(e);
    protected *void *doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    Connection conn = *null*;
    *try* {
    conn = getDataSource().getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select post_id,comments,postname from app.posts");
    // out.println("Le r&eacute;sultat :<br>");
    ArrayList <String> Lescomments= *new* ArrayList<String>();
    ArrayList <String> Lesidentifiant = *new* ArrayList<String>();
    ArrayList <String> Lesnoms = *new* ArrayList <String>();
    *while* (rs.next()) {
    Lescomments.add(rs.getString("comments"));
    request.setAttribute("comments",Lescomments);
    Lesidentifiant.add(rs.getString("post_id"));
    request.setAttribute("id",Lesidentifiant);
    Lesnoms.add(rs.getString("postname"));
    request.setAttribute("nom",Lesnoms);
    rs.close();
    stmt.close();
    *catch* (SQLException e) {
    *finally* {
    *try* {
    *if* (conn != *null*)
    conn.close();
    *catch* (SQLException e) {
    // les param&egrave;tres sont corrects - on envoie la page r&eacute;ponse
    getServletContext().getRequestDispatcher("/Campaign.jsp").forward(request,response);
    }///end of servlet
    }///this is the jsp page called
    <%@ page import="java.util.ArrayList" %>
    <%
    // on r&eacute;cup&egrave;re les donn&eacute;es
    ArrayList nom=(ArrayList)request.getAttribute("nom");
    ArrayList id=(ArrayList)request.getAttribute("id");
    ArrayList comments=(ArrayList) request.getAttribute("comments");
    %>
    <html>
    <head>
    <title></title>
    </head>
    <body>
    Liste des campagnes here i will create the xml file the problem is to display all rows
    <hr>
    <table>
    <tr>
    </tr>
    <tr>
    <td>Comment</td>
    <td>
    <%
    for( int i=0;i<comments.size();i++){
    out.print("<li>" + (String) comments.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>nom</td>
    <td>
    <%
    for( int i=0;i<nom.size();i++){
    out.print("<li>" + (String) nom.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>id</td>
    <td>
    <%
    for( int i=0;i<id.size();i++){
    out.print("<li>" + (String) id.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    </table>
    </body>
    </html>
    This is how i used to create an XML file in a JSP page only without JSP/SERVLET concept:
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%
    // Identify a carriage return character for each output line
    int iLf = 10;
    char cLf = (*char*)iLf;
    // Create a new empty binary file, which will content XML output
    File outputFile = *new* File("C:\\Users\\user\\workspace1\\demo\\WebContent\\YourFileName.xml");
    //outputFile.createNewFile();
    FileWriter outfile = *new* FileWriter(outputFile);
    // the header for XML file
    outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>"+cLf);
    try {
    // Define connection string and make a connection to database
    Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/SAMPLE","app","app");
    Statement stat = conn.createStatement();
    // Create a recordset
    ResultSet rset = stat.executeQuery("Select * From posts");
    // Expecting at least one record
    *if*( !rset.next() ) {
    *throw* *new* IllegalArgumentException("No data found for the posts table");
    outfile.write("<Table>"+cLf);
    // Parse our recordset
    // Parse our recordset
    *while*(rset.next()) {
    outfile.write("<posts>"+cLf);
    outfile.write("<postname>" + rset.getString("postname") +"</postname>"+cLf);
    outfile.write("<comments>" + rset.getString("comments") +"</comments>"+cLf);
    outfile.write("</posts>"+cLf);
    outfile.write("</Table>"+cLf);
    // Everything must be closed
    rset.close();
    stat.close();
    conn.close();
    outfile.close();
    catch( Exception er ) {
    %>

    Please state your problem that you are having more clearly so we can help.
    I looked at your code I here are a few things you might consider:
    It looks like you are putting freely typed-in comments from end-users into an xml document.
    The problem with this is that the user may enter characters in his text that have special meaning
    to xml and will have to be escaped correctly. Some of these characters are less than character, greater than character and ampersand character.
    You may also have a similiar problem displaying them on your JSP page since there may be special characters that JSP has.
    You will have to read up on how to deal with these special characters (I dont remember what the rules are). I seem to recall
    if you use CDATA in your xml, you dont have to deal with those characters (I may be wrong).
    When you finish writing your code, test it by entering all keyboard characters to make sure they are processed, stored in the database,
    and re-displayed correctly.
    Also, it looks like you are putting business logic in your JSP page (creating an xml file).
    The JSP page is for displaying data ONLY and submitting back to a servlet. Put all your business logic in the servlet. Putting business logic in JSP is considered bad coding and will cause you many hours of headache trying to debug it. Also note: java scriptlets in a JSP page are only run when the JSP page is compiled into a servlet by java. It does not run after its compiled and therefore you cant call java functions after the JSP page is displayed to the client.

  • Flatten and Partition a Result Set

    I have data I would like to transform into a desired result set, but I can't quite figure out how to do it.  I've played around with PARTITION BY, OVER, ROW_NUMBER(), and PIVOT enough to realize that I just don't quite understand them well enough.
    Here is a sample of the data I want to transform:
    ApptCount VisitDate TimeFrame PtType ApptLength
    13 2013-12-02 00:00:00 AM ESTAB LONG
    9 2013-12-02 00:00:00 AM ESTAB SHORT
    8 2013-12-02 00:00:00 PM NEW LONG
    5 2013-12-02 00:00:00 PM ESTAB SHORT
    11 2013-12-02 00:00:00 PM ESTAB LONG
    1 2013-12-02 00:00:00 AM NEW SHORT
    10 2013-12-03 00:00:00 PM ESTAB LONG
    3 2013-12-03 00:00:00 PM ESTAB SHORT
    3 2013-12-03 00:00:00 PM NEW LONG
    8 2013-12-04 00:00:00 PM NEW LONG
    4 2013-12-04 00:00:00 PM ESTAB SHORT
    6 2013-12-04 00:00:00 PM ESTAB LONG
    11 2013-12-04 00:00:00 AM ESTAB SHORT
    9 2013-12-04 00:00:00 AM ESTAB LONG
    1 2013-12-05 00:00:00 AM ESTAB LONG
    3 2013-12-05 00:00:00 AM ESTAB SHORT
    17 2013-12-06 00:00:00 AM ESTAB SHORT
    1 2013-12-06 00:00:00 AM NEW LONG
    14 2013-12-06 00:00:00 AM ESTAB LONG
    13 2013-12-06 00:00:00 PM ESTAB LONG
    7 2013-12-06 00:00:00 PM ESTAB SHORT
    3 2013-12-06 00:00:00 PM NEW LONG
    The desired format I would like in my result set is as follows:
    VISITDATE   APPT_LENGTH    AM_ESTAB   AM_NEW   PM_ESTAB   PM_NEW
    2013-12-02      Long                    13            NULL            
    11              8
                           Short                     9            
    1                   5           NULL
    2013-12-03      Long                  NULL          NULL            
    10              3
                           Short                 NULL         
    NULL               3           NULL
    I would greatly appreciate any help in how to design the query to do this transformation.  Thank you!
    Blankfiend

    Thank YOU!
    I added an Order By VisitDate and got exactly what I was looking for
    VisitDate Apptlength AM_ESTAB AM_NEW PM_ESTAB PM_NEW
    2013-12-02 00:00:00 LONG 13 NULL 11 8
    2013-12-02 00:00:00 SHORT 9 1 5 NULL
    2013-12-03 00:00:00 LONG NULL NULL 10 3
    2013-12-03 00:00:00 SHORT NULL NULL 3 NULL
    2013-12-04 00:00:00 LONG 9 NULL 6 8
    2013-12-04 00:00:00 SHORT 11 NULL 4 NULL
    2013-12-05 00:00:00 LONG 1 NULL NULL NULL
    2013-12-05 00:00:00 SHORT 3 NULL NULL NULL
    2013-12-06 00:00:00 LONG 14 1 13 3
    2013-12-06 00:00:00 SHORT 17 NULL 7 NULL
    2013-12-09 00:00:00 LONG 9 4 15 4
    2013-12-09 00:00:00 SHORT 8 NULL 4 1
    2013-12-10 00:00:00 LONG 1 NULL 2 1
    2013-12-10 00:00:00 SHORT 1 NULL 1 NULL
    2013-12-11 00:00:00 LONG 10 2 12 5
    2013-12-11 00:00:00 SHORT 12 NULL 6 1
    2013-12-12 00:00:00 LONG 10 1 9 4
    2013-12-12 00:00:00 SHORT 10 NULL 7 1
    2013-12-16 00:00:00 LONG 10 3 13 5
    2013-12-16 00:00:00 SHORT 8 1 4 NULL
    2013-12-17 00:00:00 LONG 9 1 7 4
    2013-12-17 00:00:00 SHORT 8 NULL 5 NULL
    2013-12-18 00:00:00 LONG 9 NULL 13 3
    2013-12-18 00:00:00 SHORT 8 NULL 3 NULL
    2013-12-19 00:00:00 LONG 2 NULL NULL NULL
    2013-12-20 00:00:00 LONG 9 3 11 1
    2013-12-20 00:00:00 SHORT 9 NULL 7 1
    2013-12-23 00:00:00 LONG 6 4 10 6
    2013-12-23 00:00:00 SHORT 8 NULL 4 NULL
    2013-12-24 00:00:00 SHORT 1 NULL NULL NULL
    2013-12-27 00:00:00 LONG 1 NULL NULL NULL
    2013-12-30 00:00:00 LONG 9 4 9 6
    2013-12-30 00:00:00 SHORT 10 NULL 5 1
    Blankfiend

  • Attempting to report using multiple subqueries and filtering on result set

    I have an Oracle view which shows historic logs of changed data, effectively an audit view. The view is over two tables, a header and a detail table. I guess for the purpose of the question that is not too relevant but the structure of the view is. This is the view:
    SQL> desc ifsinfo.history_log_join
    Name Null? Type
    *LOG_ID                                    NOT NULL VARCHAR2(10)
    *MODULE                                    NOT NULL VARCHAR2(6)
    *LU_NAME                                   NOT NULL VARCHAR2(30)
    *TABLE_NAME                                NOT NULL VARCHAR2(30)
    *TIME_STAMP                                NOT NULL DATE
    *USERNAME                                  NOT NULL VARCHAR2(30)
    *KEYS                                      NOT NULL VARCHAR2(600)
    *HISTORY_TYPE                                       VARCHAR2(200)
    *HISTORY_TYPE_DB                           NOT NULL VARCHAR2(20)
    COLUMN_NAME NOT NULL VARCHAR2(30)
    OLD_VALUE VARCHAR2(2000)
    NEW_VALUE VARCHAR2(2000)
    I have indicated header information with *.
    The detail shows every column that was changed for a table (in header) and the old and new values, quite straight forward.
    The table I am interested in the audit of is:
    SQL> desc customer_order_reservation_tab
    Name Null? Type
    * ORDER_NO NOT NULL VARCHAR2(12)
    * LINE_NO NOT NULL VARCHAR2(4)
    * REL_NO NOT NULL VARCHAR2(4)
    * LINE_ITEM_NO NOT NULL NUMBER
    * CONTRACT NOT NULL VARCHAR2(5)
    * PART_NO NOT NULL VARCHAR2(25)
    CONFIGURATION_ID NOT NULL VARCHAR2(50)
    * LOCATION_NO NOT NULL VARCHAR2(35)
    * LOT_BATCH_NO NOT NULL VARCHAR2(20)
    * SERIAL_NO NOT NULL VARCHAR2(15)
    WAIV_DEV_REJ_NO NOT NULL VARCHAR2(15)
    ENG_CHG_LEVEL NOT NULL VARCHAR2(2)
    * PICK_LIST_NO NOT NULL VARCHAR2(15)
    PALLET_ID NOT NULL VARCHAR2(10)
    * LAST_ACTIVITY_DATE DATE
    SOURCE VARCHAR2(25)
    QTY_ASSIGNED NOT NULL NUMBER
    QTY_PICKED NOT NULL NUMBER
    QTY_SHIPPED NOT NULL NUMBER
    DELIV_NO NUMBER
    ROWVERSION DATE
    I have indicated columns that I am interested in (either as a key field or as changed data) by *
    Okay - so that's the background, what am I attempting to report.
    I want to return a single row per log id (for certain criteria) which shows:
    Log_Id
    History_Type
    Time_Stamp
    Username
    Order_No
    Pick_List_No
    Rel_No
    Line_No
    Part_No
    Loc_No
    Lot_Batch_No
    Serial_No
    The SQL I have currently is:
    select grp.*
    from
    (select h1.log_id, h1.history_type, time_stamp, username,
    (select h2.old_value||h2.new_value from ifsinfo.history_log_join h2 where h1.log_id=h2.log_id and h2.column_name ='ORDER_NO') Order_No,
    (select h2.old_value||h2.new_value from ifsinfo.history_log_join h2 where h1.log_id=h2.log_id and h2.column_name ='PICK_LIST_NO') Pick_List_No,
    (select h2.old_value||h2.new_value from ifsinfo.history_log_join h2 where h1.log_id=h2.log_id and h2.column_name ='REL_NO') Rel_No,
    (select h2.old_value||h2.new_value from ifsinfo.history_log_join h2 where h1.log_id=h2.log_id and h2.column_name ='LINE_NO') Line_No,
    (select h2.old_value||h2.new_value from ifsinfo.history_log_join h2 where h1.log_id=h2.log_id and h2.column_name ='PART_NO') Part_No,
    (select h2.old_value||h2.new_value from ifsinfo.history_log_join h2 where h1.log_id=h2.log_id and h2.column_name ='LOCATION_NO') Loc_No,
    (select h2.old_value||h2.new_value from ifsinfo.history_log_join h2 where h1.log_id=h2.log_id and h2.column_name ='LOT_BATCH_NO') Lot_Batch_No,
    (select h2.old_value||h2.new_value from ifsinfo.history_log_join h2 where h1.log_id=h2.log_id and h2.column_name ='SERIAL_NO') Serial_No
    from ifsinfo.history_log_join h1
    where
    table_name = 'CUSTOMER_ORDER_RESERVATION_TAB'
    and
    keys like upper('CONFIGURATION_ID=*^CONTRACT=&company%')
    and
    history_type in ('Delete','Insert')
    and
    column_name ='PICK_LIST_NO'
    and
    username != 'IFSAPP'
    and
    h1.old_value || h1.new_value != '*'
    and
    trunc(h1.time_stamp) > trunc(sysdate-1-&days_ago)
    order by 5, 6, 8, 7,9,10,2, 1) grp
    This is OK but..
    I only want to include rows where the same picklist / rel_no / line_no / part_no combination exist more than once (because there is always an insert and delete for the analysis I am doing).
    AND
    where for that combination, the lot_batch_no OR serial_no are different.
    Effectively the system does an insert / delete rather than an update, so that is why.
    Thanks

    Hi sanny007,
    As your issue is related to Reports, I'm moving your post to a more appropriate forum for better supports, thanks for your undrstanding.
    https://social.msdn.microsoft.com/Forums/en-US/home?forum=vsreportcontrols
    Best regards,
    Youjun Tang
    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.

  • Report Viewer and Multiple Data Sources

    I know that it is possible to create a report in Crystal Reports using multiple data sources.  But is it possible to use just the Free  Report Viewer to view a report with Multiple Data Sources?
    Our company uses Crystal Reports XI.  I do not use the program myself, I am in the IT Department.  I have limited knowledge of Crystal and do not do any of the report writing.
    If this is possible, and if someone could help me out with what would need to be done, or point me in the right direction of a Knowledge Base or Help Topic that explains this, that would be great.
    Thanks.

    I believe it can but both data sources need to be set up. Ask a report designer to help you use the Designer to test this and see what is required.

  • Remote Call to Blazeds and displaying the result set in grid

    Hi,
    I want to call a remote method using Flex application from Blazeds and display the values in DataGrid. Can anyone help in this ?
    -- I am using AMFChannel
    -- The method to be called is PolicyApnVO.getPoliciesApn()
    -- Please advice any correction if required
    Here is the mxml code :
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    creationComplete="initApp()" viewSourceURL="srcview/index.html">
        <!--
        Simple client to demonstrate runtime configuration of destinations.
        The "runtime-employee" destination is configured in
        EmployeeRuntimeRemotingDestination.java.
        -->
        <mx:Script>
            <![CDATA[
                import mx.messaging.ChannelSet;
                import mx.messaging.channels.AMFChannel;
                import mx.rpc.remoting.mxml.RemoteObject;
                [Bindable]
                public var srv:RemoteObject;
                public function initApp():void
                    var channel:AMFChannel = new AMFChannel("my-amf", "http://192.168.102.208:8400/policyAnalytics/messagebroker/amf");
                    var channelSet:ChannelSet = new ChannelSet();
                    channelSet.addChannel(channel);
                    srv = new RemoteObject();
                    srv.destination="runtime-policy";   
                    srv.channelSet = channelSet;
                    srv.PolicyApnVO.getPoliciesApn();
            ]]>
        </mx:Script>
        <mx:Panel title="Policy Details" width="100%" height="100%">
            <mx:DataGrid width="100%" height="100%" dataProvider="{srv.PolicyApnVO.getPoliciesApn.lastResult.data.result}"
                         showDataTips="true">
                <mx:columns>
                    <mx:DataGridColumn headerText="APN Id" dataField="apnId"/>
                    <mx:DataGridColumn headerText="APN Name" dataField="apnName"/>
                    <mx:DataGridColumn headerText="Policy ID" dataField="policyId"/>
                    <mx:DataGridColumn headerText="Policy Name" dataField="policyName"/>
                </mx:columns>
            </mx:DataGrid>
        </mx:Panel>
    </mx:Application>

    There may be other ways to do this but here's what I would do:
    1) add a results method to the remote object:
    src.result="onResult(event.result)";
    2) add the callback method: private function onResult(event : * = null)
    :void{
                                                         if(event is
    ArrayCollection)
                                                                myData =
    ArrayCollection(event);
    3) add the variable: private var myData:ArrayCollection;
    4) make the dataProvider for the grid use the my data :
    dataProvider=""
    You can probably avoid all this by adjusting your dataProvider. I am just
    not sure what it would be without experimenting. But definitely not what
    you have. Maybe just {svc.result}.

  • OracleDataAdapter and multiple datasets

    Hello
    I'd like to ask, does each dataset need its own data adapter? I'm implementing application which has a lot of datagridviews, and I wonder how to use adapter. Is it possible to have two datasets and use following scenario: fill first dataset, bind it to datagridview, then using the same adapter fill second dataset and bind it to datagridview, and after then call adapter.update for first dataset and then for second dataset - all using only one adapter. Is it possible or not?
    Thanks for advice.

    does each dataset need its own data adapter?no
    Is it possible to have two datasets and use following scenario:
    fill first dataset, bind it to datagridview, then using the same adapter
    fill second dataset and bind it to datagridview, and after then call
    adapter.update for first dataset and then for second dataset -
    all using only one adapter. Is it possible or not?yes
    Cheers,
    NH

  • Query  for getting records  max  reported  timestamp and 2nd max report

    query for getting records in between
    max reported timestamp and 2nd max reported timestamp
    HERE IS ALL RESULT SET
    TIME DOMAIN
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    PD_REPORTED_TIMESTAM PD_USER
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:08:45 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:04 TOMCAT
    30:jun:2006:20:07:24 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:07:45 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    30:jun:2006:20:08:05 TOMCAT
    PD_REPORTED_TIMESTAM PD_USER
    30:jun:2006:20:08:25 TOMCAT
    30:jun:2006:20:08:25 TOMCAT
    QUERY RESULT TO COME
    TIME DOMAIN
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    Message was edited by:
    user517983

    Hi,
    can we write query like this.
    1 select pd_user,PD_REPORTED_TIMESTAMP
    2 from sp_process_detail_current spdc
    3 where host_id='DSCP02469'and pd_user='TOMCAT'
    4 and exists(
    5 select PD_REPORTED_TIMESTAMP from sp_process_detail_current
    6* having max(PD_REPORTED_TIMESTAMP)-spdc.PD_REPORTED_TIMESTAMP=0)
    SQL> /
    PD_USER PD_REPORTED_TIMESTAM
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45
    TOMCAT 30:jun:2006:20:08:45

  • Can we pass temporary result set to the  procedure?

    Hi,
    The result set is stored in a temporary storage. Can we pass that resultset to the procedure?
    Thanks and regards
    Gowtham Sen.

    I'm still unclear just what this result set is... Is is a table or a cursor or something else?
    If you imply the physical result set of a SQL query, there is no such thing in Oracle. Oracle does not create and store a result set in memory containing the rows of the SQL SELECT. Creating such sets in memory does not scale. A single SELECT on such a database can kill the performance of the entire database by exhasuting all memory with a single large physical result set.
    Oracle "results" live in the database cache (residing in the SGA). Rows (as data blocks) are paged into and out of this case as demand dictates. When PL/SQL code, for example, fetches a row, the SQL engine grabs the row from the db cache (SGA) and copies it to the PGA (the private memory area of the PL/SQL process). The row also may not yet exist in the db cache - in which case it needs a physical read from disk to get the data block containing that row into the db cache (after which it is copied to the PGA).
    A PL/SQL process can do a bulk fetch - e.g. fetch a 100 rows from the SQL query/cursor at a time. In that case, a 100 rows are copied from the SGA db cache to the PGA.
    At no time is there are single large unique and dedicated memory struct in the SGA that contains the complete "result set" of a SQL query.
    Once you have fetched that row, that is it. Deal is done. You cannot reverse the cursor and fetch the row again. After you have fetched the last row in that cursor, you cannot pass that cursor to another process - the cursor is now empty. That other process cannot rewind the cursor and start fetching from the 1st row again. You will need to pass the SQL to that process in order for it to create its own cursor - also keeping in mind that in between the rows can have changed and that this other process could now see different results with its cursor.
    If you want to create such a physical temporary result set that is consistent and re-usable, you can use a temporary table - and insert the results of the SELECT into this temp table for further processing. This temp table is session specific and is auto destroyed when the session terminates.
    A comment though - it sounds like you're approaching the date warehouse processing (scrubbing, transformation and loading of data) as a row-by-row process.
    That is a flawed approach. Row-by-row processing does not scale. One should deal with data sets. Especially when the volumes are large. One should also attempt to perform minimal passes through a data set. Processing a bunch of rows, then passing that rows to another process to do some processing on the same rows.. this means multiple passes through the same data. That is very inefficient performance and resource wise.

  • Displaying large result sets in Table View u0096 request for patterns

    When providing a table of results from a large data set from SAP, care needs to be taken in order to not tax the R/3 database or the R/3 and WAS application servers.  Additionally, in terms of performance, results need to be displayed quickly in order to provide sub-second response times to users.
    This post is my thoughts on how to do this based on my findings that the Table UI element cannot send an event to retrieve more data when paging down through data in the table (hopefully a future feature of the Table UI Element).
    Approach:
    For data retrieval, we need to have an RFC with search parameters that retrieves a maximum number of records (say 200) and a flag whether 200 results were returned. 
    In terms of display, we use a table UI Element, and bind the result set to the table.
    For sorting, when they sort by a column, if we have less than the maximum search results, we sort the result set we already have (no need to go to SAP), but otherwise the RFC also needs to have sort information as parameters so that sorting can take place during the database retrieval.  We sort it during the SQL select so that we stop as soon as we hit 200 records.
    For filtering, again, if less than 200 results, we just filter the results internally, otherwise, we need to go to SAP, and the RFC needs to have this parameterized also.
    If the requirement is that the user must look at more than 200 results, we need to have a button on the screen to fetch the next 200 results.  This implies that the RFC will also need to have a start point to return results from.  Similarly, a previous 200 results button would need to be enabled once they move beyond the initial result set.
    Limitations of this are:
    1.     We need to use custom RFC function as BAPI’s don’t generally provide this type of sorting and limiting of data.
    2.     Functions need to directly access tables in order to do sorting at the database level (to reduce memory consumption).
    3.     It’s not a great interface to add buttons to “Get next/previous set of 200”.
    4.     Obviously, based on where you are getting the data from, it may be better to load the data completely into an internal table in SAP, and do sorting and filtering on this, rather than use the database to do it.
    Does anyone have a proven pattern for doing this or any improvements to the above design?  I’m sure SAP-CRM must have to do this, or did they just go with a BSP view when searching for customers?
    Note – I noticed there is a pattern for search results in some documentation, but it does not exist in the sneak preview edition of developer studio.  Has anyone had in exposure to this?
    Update - I'm currently investigating whether we can create a new value node and use a supply function to fill the data.  It may be that when we bind this to the table UI element, that it will call this incrementally as it requires more data and hence could be a better solution.

    Hi Matt,
    i'm afraid, the supplyFunction will not help you to get out of this, because it's only called, if the node is invalid or gets invalidated again. The number of elements a node contains defines the number of elements the table uses for the determination of the overall number of table rows. Something quite similar to what you want does already exist in the WD runtime for internal usage. As you've surely noticed, only "visibleRowCount" elements are initially transferred to the client. If you scroll down one or multiple lines, the following rows are internally transferred on demand. But this doesn't help you really, since:
    1. You don't get this event at all and
    2. Even if you would get the event, since the number of node elements determines the table's overall rows number, the event would never request to load elements with an index greater than number of node elements - 1.
    You can mimic the desired behaviour by hiding the table footer and creating your own buttons for pagination and scrolling.
    Assume you have 10 displayed rows and 200 overall rows, What you need to be able to implement the desired behaviour is:
    1. A context attribute "maxNumberOfExpectedRows" type int, which you would set to 200.
    2. A context attribute "visibleRowCount" type int, which you would set to 10 and bind to table's visibleRowCount property.
    3. A context attribute "firstVisibleRow" type int, which you would set to 0 and bind to table's firstVisibleRow property.
    4. The actions PageUp, PageDown, RowUp, RowDown, FirstRow and LastRow, which are used for scrolling and the corresponding buttons.
    The action handlers do the following:
    PageUp: firstVisibleRow -= visibleRowCount (must be >=0 of course)
    PageDown: firstVisibleRow += visibleRowCount (first + visible must be < maxNumberOfExpectedRows)
    RowDown/Up: firstVisibleRow++/-- with the same restrictions as in page "mode"
    FirstRow/LastRow is easy, isn't it?
    Since you know, which sections of elements has already been "loaded" into the dataSource-node, you can fill the necessary sections on demand, when the corresponding action is triggered.
    For example, if you initially display elements 0..9 and goto last row, you load from maxNumberOfExpected (200) - visibleRows (10) entries, so you would request entries 190 to 199 from the backend.
    A drawback is, that the BAPIs/RFCs still have to be capable to process such "section selecting".
    Best regards,
    Stefan
    PS: And this is meant as a workaround and does not really replace your pattern request.

  • Problem opening 2 result sets

    Hi we are having problems with leaking database connections. We are using the jdbc debug features of oc4j (9.0.2).
    Basically we connect to database 1, do a query and open a result set, then create a connection to database 2 and try to execute a query on it. The problem is that if the first's resultset is open, the debugging complains that there are multiple open result sets. This is leading to database connections not getting release when they should be.
    Here's an example of the code we are using (which is in a stateless session bean):
    public void test(){
    try {
    Connection connection;
    DataSource dataSource;
    Context context = new InitialContext();
    dataSource = (DataSource) context.lookup(Constants.NHHDC_DATABASE);
    connection = dataSource.getConnection();
    PreparedStatement statement = null;
    ResultSet resultSet = null;
    statement = connection.prepareStatement(" SELECT 'X' FROM DUAL");
    resultSet = statement.executeQuery();
    resultSet.next();
    DataSource reamsDataSource;
    Context reamsContext = new InitialContext();
    reamsDataSource = (DataSource) reamsContext.lookup(Constants.REAMS_DATABASE);
    Connection reamsConnection = reamsDataSource.getConnection();
    PreparedStatement reamsStatement = null;
    ResultSet reamsResultSet = null;
    reamsStatement = reamsConnection.prepareStatement("SELECT 'X' FROM DUAL");
    System.out.println("LAST STATEMENT");
    reamsResultSet = reamsStatement.executeQuery();
    System.out.println("FINISHED");
    reamsResultSet.close();
    reamsStatement.close();
    reamsConnection.close();
    resultSet.close();
    statement.close();
    connection.close();
    } catch (NamingException e) {
    System.out.println("naming error " + e.getMessage());
    } catch (SQLException e) {
    System.out.println("sql error " + e.getMessage());
    The error coming from the debug is:
    *********** OPEN SETS: ************
    java.lang.Exception: com.evermind.sql.DebugPreparedResultSet@5e9f1
    Is it not possible to have 1 resultset open on one database and a separate one on a different database? I know the example above could be written to close the result set first, but this is a simplified example of something we are doing just to hightlight the problem.
    Any ideas appricated on why this complains.
    Thanks
    Andrew Moore

    hi Andrew,
    Just a hint: we are using more than 1 database connections at the same time. but in this case all datasources have to be non-emulated.
    check this, maybe its the prob @ yours.
    4 non-emulated datasources check the server guide of oc4j ..
    http://technet.oracle.com/tech/java/oc4j/doc_library/902/servicesjun02/ds3.htm#1005742
    cu
    ed

  • Loading the different result sets in the same sequence for the target table

    Dear all,
    I have 5 tables say A,B,C,D as my source and i made 3 joins P,Q,R .the result sets of these 3 joins are loading into a target table X but with 3 different targets with same table name.
    I created one sequence say Y as my target table has primary key and mapped to three different targets for the same target table which i need to load.
    But after deployed and executed successfully ,i am able to load the data from three join result sets with differeent sequence numbers.
    I am looking to load data like this.
    If First Result set P has 10 Records,SEcond Result Set Q Has 20 and the third result set has 30 records then while loading data into first target it creates the seq for the 10 records from 1..10 and while loading the data for second result set ,it creates the sequence from 11 ...20 and while loading the third target with the third result set it creates the sequence from 21 ----30.
    But i am looking to load the three result sets in the sequence 1to 10 but not like creating fresh sequence for each result set.
    how can we achieve this in owb?
    any solution for this will be appreciated.
    thank you
    kumar

    My design is like following
    SRC1
    ---->Join1--------------------------->Target1( Table X)<-----Seq1
    SRC2
    SRC3
    ----> Join2----------->Target2(Table X)<----Seq1
    SRC4
    -----> Join3 -------> Target3(Table X)<-----Seq1
    SRC5
    Here the three 3 targets are for the same Table X as well sequence is same i.e seq1
    If the First Join has 10 rows ,Seq1 generates sequence in 1 to 10 while loading target1
    But while loading second target,Same Seq1 is generating new sequence from 11 but i am looking to load target2 and target 3 starting from sequence 1 but not from 11 or so.
    As per your comments :
    you want to load 3 sources to one target with same sequence numbers?
    yes
    Are you doing match from the other two sources on first source by id provided by sequence (since this is the primary key of the table)?
    No
    can you please tell me how to approach for this?
    Thank You
    Kumar

  • Button panel replaced by JTable result set

    Hi guys. Here's the problem. Below is my current working code.
    When run - a JOption pane opens, into which I type the database location (using /'s instead of \'s as it is a String input).
    The main UI opens. That indicates that the connection was successful. The UI consists of a JPanel (north) containg a number of buttons. Below that is a space for a JTable. Each button represents a diiferent query to the database and a different result set is displayed in the JTable beneath the buttons depending on which button is clicked.
    This all works fine.
    However I would like to now modify the code so that when the program runs the user is faced with the JPanel containing the Buttons only. And when a button is clicked the current panel is replaced with a full JTable containing the result set.
    So basically I want a JPanel with a number of buttons. Once clicked the result set JTable is displayed fully in the JFrame possibly with another button to bring the user back to the initial button panel.
    import java.io.*;
    import java.sql.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.table.*;
    public class Test12 extends JFrame {
    // java.sql types needed for database processing
    private Connection connection;
    private Statement statement;
    private ResultSet resultSet;
    private ResultSetMetaData rsMetaData;
    // javax.swing types needed for GUI
    private JTable table;
    private JTextArea inputQuery;
    public Test12()
    super( "Johnny Project" );
    // The URL specifying the Books database to which
    // this program connects using JDBC to connect to a
    // Microsoft ODBC database.
    // Load the driver to allow connection to the database
    try {
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         String myFilename = JOptionPane.showInputDialog("Enter Database Location");
                   String myDatabase = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
                   myDatabase+= myFilename.trim() + ";DriverID=22;READONLY=true}";
                   connection = DriverManager.getConnection(myDatabase,"","");
    catch ( ClassNotFoundException cnfex ) {
    System.err.println(
    "Failed to load JDBC/ODBC driver." );
    cnfex.printStackTrace();
    System.exit( 1 ); // terminate program
    catch ( SQLException sqlex ) {
    System.err.println( "Unable to connect" );
    sqlex.printStackTrace();
    System.exit( 1 ); // terminate program
              //If connection succeeds - build GUI
              buildMenu();
              buildGUI();
              setSize(800, 800);
              show();
    private void getTable(String recievedQuery)
    try {
    String query = recievedQuery;
    statement = connection.createStatement();
    resultSet = statement.executeQuery(query);
    displayResultSet(resultSet);
    catch (SQLException sqlex) {
    sqlex.printStackTrace();
    private void displayResultSet(ResultSet rs)
    throws SQLException
    // position to first record
    boolean moreRecords = rs.next();
    // If there are no records, display a message
    if (! moreRecords) {
    JOptionPane.showMessageDialog( this,
    "ResultSet contained no records" );
    setTitle( "No records to display" );
    return;
    Vector columnHeads = new Vector();
    Vector rows = new Vector();
    try {
    // get column heads
    ResultSetMetaData rsmd = rs.getMetaData();
    for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
    columnHeads.addElement( rsmd.getColumnName( i ) );
    // get row data
    do {
    rows.addElement( getNextRow( rs, rsmd ) );
    } while ( rs.next() );
    // display table with ResultSet contents
    table = new JTable( rows, columnHeads );
    JScrollPane scroller = new JScrollPane( table );
    Container c = getContentPane();
    c.remove( 1 );
    c.add( scroller, BorderLayout.CENTER );
    c.validate();
    catch ( SQLException sqlex ) {
    sqlex.printStackTrace();
    private Vector getNextRow( ResultSet rs, ResultSetMetaData rsmd )
    throws SQLException
    Vector currentRow = new Vector();
    for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
    switch( rsmd.getColumnType( i ) ) {
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    currentRow.addElement( rs.getString( i ) );
    break;
    case Types.INTEGER:
    currentRow.addElement(
    new Long( rs.getLong( i ) ) );
    break;
    default:
    System.out.println( "Type was: " +
    rsmd.getColumnTypeName( i ) );
    return currentRow;
    public void shutDown()
    try {
    connection.close();
    catch ( SQLException sqlex ) {
    System.err.println( "Unable to disconnect" );
    sqlex.printStackTrace();
    private void buildGUI()
              inputQuery = new JTextArea(4, 30);
              Icon people = new ImageIcon("people.gif");
              JButton searchAll = new JButton("All", people);
              searchAll.setToolTipText("Search All People");
              searchAll.setBorder(null);
              searchAll.addActionListener(
         new ActionListener() {
    public void actionPerformed(ActionEvent e)
              String searchAllString = new String("Select * from 0001_per_year");
         getTable(searchAllString);
              JButton searchPathway = new JButton("Pathway", people);
              searchPathway.setToolTipText("Search Students by Pathway");     
              searchPathway.setBorder(null);
              searchPathway.addActionListener(
         new ActionListener() {
    public void actionPerformed(ActionEvent e)
              String searchPathwayString = new String("Select Student_Number, Pathway from 0001_per_year");
         getTable(searchPathwayString);
              JButton searchPeriod = new JButton("Study", people);
              searchPeriod.setToolTipText("Search Students by Period");     
              searchPeriod.setBorder(null);
              searchPeriod.addActionListener(
         new ActionListener() {
    public void actionPerformed(ActionEvent e)
              String searchPeriodString = new String("Select Student_Number, Period_of_Study from 0001_per_year");
         getTable(searchPeriodString);
              JButton searchAttendance = new JButton("Attendance", people);
              searchAttendance.setToolTipText("Search Students by Attendance");     
              searchAttendance.setBorder(null);
              searchAttendance.addActionListener(
         new ActionListener() {
    public void actionPerformed(ActionEvent e)
              String searchAttendanceString = new String("Select Student_Number, Attendance_Status from 0001_per_year");
         getTable(searchAttendanceString);
              JLabel j1 = new JLabel ();     
              JLabel j2 = new JLabel ();
              JLabel j3 = new JLabel ();
              JLabel j4 = new JLabel ();
              JLabel j5 = new JLabel ();
              JLabel j6 = new JLabel ();
              JLabel j7 = new JLabel ();
              JLabel j8 = new JLabel ();
              JLabel j9 = new JLabel ();
              JLabel j10 = new JLabel ();
              JLabel j11 =new JLabel ();
              JLabel j12 = new JLabel ();
              GridLayout grid;
              grid = new GridLayout(4,4);
                   JPanel topPanel = new JPanel();
              topPanel.setLayout(grid);
              topPanel.add(j1);
              topPanel.add(j2);
              topPanel.add(j3);
              topPanel.add(j4);
              topPanel.add(j5);
              topPanel.add(searchAll);
              topPanel.add(searchPathway);
              topPanel.add(j6);
              topPanel.add(j7);
                   topPanel.add(searchPeriod);
                   topPanel.add(searchAttendance);
                   topPanel.add(j8);
                   topPanel.add(j9);
                   topPanel.add(j10);
                   topPanel.add(j11);
                   topPanel.add(j12);
                   table = new JTable();
              Container c = getContentPane();
              c.setLayout( new BorderLayout() );
              c.add( topPanel, BorderLayout.NORTH );
              c.add( table, BorderLayout.CENTER );
              show();
    private void buildMenu()
    JMenuBar myMenuBar = new JMenuBar();
    JMenu myFileMenu = new JMenu("File");
    JMenuItem myExitItem = new JMenuItem("Exit");
    //Exit item closes the application
    myExitItem.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    System.exit(0);
    myFileMenu.add(myExitItem);
    myMenuBar.add(myFileMenu);
    setJMenuBar(myMenuBar);
    public static void main( String args[] )
    final Test12 app = new Test12();
    app.addWindowListener(
    new WindowAdapter() {
    public void windowClosing( WindowEvent e )
    app.shutDown();
    System.exit( 0 );

    Your welcome. I don't really compete for Duke's, but I'm glad the issue is resolved.
    - Saish
    "My karma ran over your dogma." - Anon

Maybe you are looking for