Can I execute a query against an already populated RowSet object?

Hi,
Is it possible to query an already retrieved RowSet object?
Something like "search within results" feature that many search engine posses .
Thank you in advance, Kostas

There is no ready-made way to execute SQL queries against a ResultSet. Anyway, you shouldn't keep ResultSets open, you should convert them to collections of objects and close them.
When you get the ResultSet, loop over it, create an object of a suitable class from each row, and store those objects in a LinkedList.
When you need to search within the results, loop over the LinkedList and pick the objects you need.
Alternatively, re-execute the SQL query with the additional WHERE clauses appended to the original query.

Similar Messages

  • JDBC- can u execute a query while processing results

    can you execute a query in the while loop of a different resultSet?
    e.g.,...
    line2= ("Select teamName, played, won, lost, draw, forfor, against, points from leaguetable where tourId = " + tourId);
    query4 = stmt.executeQuery(line2);
    while (query4.next())
    teamName = query4.getString(1);
    playedTemp = query4.getString(2);
    played = Integer.parseInt(playedTemp);
    wonTemp = query4.getString(3);
    won = Integer.parseInt(wonTemp);
    lostTemp = query4.getString(4);
    lost = Integer.parseInt(lostTemp);
    drawTemp = query4.getString(5);
    draw = Integer.parseInt(drawTemp);
    forforTemp = query4.getString(6);
    forfor = Integer.parseInt(forforTemp);
    againstTemp = query4.getString(7);
    against = Integer.parseInt(againstTemp);
    pointsTemp = query4.getString(8);
    points = Integer.parseInt(pointsTemp);
    for (int i=0; i<homeTeams.length; i++){
    if(teamName.equals(homeTeams)){
    homeTeamScoreInt = Integer.parseInt(homeTeamScore[i]);
    awayTeamScoreInt = Integer.parseInt(awayTeamScore[i]);
    if(homeTeamScoreInt > awayTeamScoreInt){
    played = played + 1;
    won = won + 1;
    forfor = forfor + homeTeamScoreInt;
    against = against + awayTeamScoreInt;
    points = points + 3;
    line3 = ("Update LEAGUETABLE set played = " + played + ", won = " + won + ", forfor = " + forfor + ", against = " + against +
    ", points = " + points + " where tourid = " + tourId + " AND teamName = '" + teamName+ "'");
    stmt.executeUpdate(line3);
    it only works once, it stops at the end of the while loop, i.e., it doesnt loop around the resultSet like it should.

    do you mean for this part...
    query4 = stmt.executeQuery(line2);
    while (query4.next())
    surely the data is stored in the resultSet ??
    or do you mean this part...
    stmt.executeUpdate(line3);

  • How can I execute a query from a BSP application?

    How can I execute a query from a BSP application?
    I´m trying to execute a Query from intranet. I´ve been looking for examples, but the templates I´ve found doesn´t help me.
    does anybody has an example?
    Thanks.

    Hi
    Have you designed the BSP application ?
    design it first with one page
    page will have layout and Event handlers
    Design the layout with the fields
    in the event handler there are events
    in the event On Initiailization or ON inputprocessing write the select query similar to what we write in routine ABAp and fetch the data into ITAB and that has to be passed to the Layout
    see the doc
    BSP
    To learn how to create Web applications with Business Server Pages, you can work through the simple tutorials that build on each other. You should be able to run through all of the steps described here in your own system.
    If you want to develop Web applications with BSPs, your system must meet the following requirements: Prerequisites for Creating Web Applications.
    The following tutorials are available:
    · First Tutorial: First Steps with Business Server Pages…
    · Second tutorial: A Small BSP Application and A Small BSP Application with HTMLB
    · Third tutorial: Our First Online Bookshop
    · Fourth tutorial: Further Developing the Bookshop
    · A small Tutorial is also available for your first steps with the Model View Controller design pattern.
    · For a more complex MVC tutorial based on the third tutorial, see: Our Little Online Bookshop Using MVC and HTMLB
    When creating BSP applications, note the browser dependencies described in Note 598860.
    steps:
    1) start the transaction RZ10.
    2) now u u have to select Profile name, so select the INSTANCE Profile from the list of options given with the Profile parameter list.U may find multiple instance profile in the list, so select the profile in which ur server name is given.
    3) u will also find three options in the same window.
    Administrator data, Basic Maintenance, and Extended Maintenance. So select the last one from that.
    4) Now click on change button.
    5) here u will find parameter icm/host_name_full, so now set it as FQDN.
    6) Now copy ur settings with new version number.
    7) Activate that version.
    8) And now please restart ur WAS.
    So this will set ur FQDN, and also don't forget to login using Admin User.
    Now u also check for following service are active in your ICF setting or not,( just start transaction code SICF)
    /default_host/sap/bc/bsp/sap
    /default_host/sap/bc/bsp/sap/system
    /default_host/sap/bc/bsp/sap/public/bc
    /def ault_host/sap/public/bc
    /default_host/sap/public/bc/ur
    /default_host/sap/public/bsp/sap/public
    /default_host/sap/public/bsp/sap/public/bc
    /defaul t_host/sap/public/bsp/sap/system
    /default_host/sap/public/bsp/sap/htmlb
    if not then activate all.
    check this link
    Read this weblog...
    /people/brian.mckellar/blog/2003/09/25/bsp-in-depth-fully-qualified-domain-names
    http://www.thespot4sap.com/articles/SAP_WAS_Creating_BSP_Apps.asp
    it consists of screen shots also
    Check it.
    http://help.sap.com/saphelp_nw04/helpdata/en/c8/101c3a1cf1c54be10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/e9/bb153aab4a0c0ee10000000a114084/frameset.htm
    Regards
    Anji

  • Can we execute a query in resultset while loop

    can we execute a query in resultset while loop
    for ex:
    rs=st.executeQuery("SQL");
    while(rs.next())
    rs1=st.executequery("SQL1");
    while(rs1.next())
    }

    If you do this, you lose "rs". Create a second
    Statement object for the other query.This is right. We have done it many times, It is not the issue as long as you use different statement with in the body of the loop

  • Can we execute a query in resultset of while loop

    can we execute a query in resultset while loop
    for ex:
    rs=st.executeQuery("SQL");
    while(rs.next())
    rs1=st.executequery("SQL1");
    while(rs1.next())
    }

    yup no problem..if it doesn work declare the second one as st1

  • While Rollup is goingon Can we execute the query

    Hello All
    We have a cube and aggregates built on this cube and daily in my Process chain we have step Rollup.
    Now while Rollup is goingon Can we execute the query which is builut on the same cube? Will the cube will be locked?
    Can we excute query while load is goingon to this cube?
    Regards
    Balji

    Hi Balaji,
    You can execute a query when the roll up is going on. The new data is available to the report only when the rollup is complete, but this will not create locks.
    Hope this helps...

  • How Can I Execute Sql Query in Managed bean?

    Hi,
    I want to execute sql query in managedbean and get the query result. How can I do?
    Best wishes!

    You can do this by having current Database connection your application is using like this
    public static synchronized DBTransaction getDBTransaction(){
    FacesContext ctx = FacesContext.getCurrentInstance();
    ValueBinding vb = ctx.getApplication().createValueBinding("#{data}");
    BindingContext bc = (BindingContext)vb.getValue(ctx.getCurrentInstance());
    DataControl dc = bc.findDataControl("AppModuleDataControl");
    ApplicationModuleImpl am = ((ApplicationModuleImpl)(ApplicationModule)dc.getDataProvider());
    return am.getDBTransaction();
    and then user DBTransaction object to create Statement and PreparedStatement you can find those in java doc.

  • How can I execute a query using RSCRMBW_REPORT?

    Hi everybody,
    I have read the document:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3ba5e590-0201-0010-59b1-cab51fd245b7
    and found it is very intersting for my requirement.
    I copied the report,and modified it regarding our case.But during the second call,I get runtime error.
    I debugged the code, and found the error results from method GET_CUBETYPE() of class CL_RSCRMBW_BAPI.In this method,it tries to create a object which is TYPE REF TO cl_rsd_dta.
    CREATE OBJECT lr_dta
         EXPORTING
           i_infoprov    = g_s_status-infocube
    But g_s_status-infcube is null.
    I am not able to find where this 'infocube' component  in this g_s_status struction is filled,even I found,I don't know how I can give this infocube parameter from report which 2 FM are called.
    My code is following:
    parameters: p_repuid TYPE RSCRMSTATUS-REPORTUID
    DEFAULT 'Z_IC_01/Z_COMP_Q003'.
    parameters: p_split type BAPI6110DIM-DIM_NAM.
    data:name_query TYPE CHAR50,
         result_table LIKE RSCRMSTATUS-TABNAME,
         it_return LIKE BAPIRET2 OCCURS 2 WITH HEADER LINE,
         infocube TYPE CHAR30,
         compid TYPE CHAR30.
    AT SELECTION-SCREEN  ON VALUE-REQUEST FOR p_repuid.
    CALL FUNCTION 'RSZ_COMPONENT_TREE_GET'
        EXPORTING
          i_title    = 'Query auswählen'(031)
        IMPORTING
          E_INFOCUBE = infocube
          E_COMPID   = compid
        EXCEPTIONS
          OTHERS     = 1.
      IF sy-subrc GT 0.
      ENDIF.
    concatenate infocube '/' compid into p_repuid.
    START-OF-SELECTION.
    CALL FUNCTION 'RSCRMBW_REPORT'
    EXPORTING
    i_mode = 'OPEN'
    i_reportuid = p_repuid
    I_PACKSIZE = 10000
    I_EXECMODE = 'TABLE'
    I_EXTRACT = 'ZBWTEST'
    I_SPLIT = p_split
    I_CLEAREXTRACT = 'X'
    TABLES
    E_T_RETURN = it_return.
    CALL FUNCTION 'RSCRMBW_REPORT'
    EXPORTING
    i_mode = 'START'
    i_reportuid = p_repuid
    I_PACKSIZE = 10000
    I_EXECMODE = 'TABLE'
    I_CLEAREXTRACT = 'X'
    TABLES
    E_T_RETURN = it_return.
    So far this creation of report is only the 2nd step.But I am not sure how step 3 to step 6 should be done so that the report can be execute exactly.
    What should I do? Pleas help me!
    Thanks in advance
    Regards,
    Liying
    Message was edited by: Liying Wang
    Message was edited by: Liying Wang
    Message was edited by: Liying Wang

    Liying
    Were you able to get a solution to this problem? I am facing the same issue too. The g_s_status-infocube is showing blank.
    Regards
    Dilip

  • ADF how can i execute a query with parameters when the page renders

    hi
    i am using ADF web 11g
    i need to execute a query with parameters when the page renders
    thanks

    hello,
    I'm a fan of Java code, I really am.
    But when you use ADF, you decided to move to a more declarative environment.
    So why not do it declarative, the adf way?
    In your pagedef insert a action binding.
    This can be anything, a call to the application module, a call on the iterator(Like executeWithparams, etc.)
    Create an invokeAction in your pagedef and set the condition.
    This example refreshes(Action 2 is execute query) the data.
    First the method binding:
        <action IterBinding="PersoonIterator" id="Execute" InstanceName="LSAppModuleDataControl.Persoon"
                DataControl="LSAppModuleDataControl" RequiresUpdateModel="true" Action="2"/>And the invoke action
        <invokeAction Binds="Execute" id="refreshData"/>This always refreshes the data on page entry, but anything is possible, you can set condictions for the invokeAction.
    -Anton
    PS Yes I know that pagedefs become backing beans in the end and yes that is Java code, but if you wanna play the ADF way, the goal is the reduction of Java code and the increased performance of declarative programming.

  • FRM-40737  How can I execute a query in a post block ?

    Hi,
    I have two blocks based on the same table. Then it is not a 'real' master detail case. The first block contains two fields who are the values in the where clause of the second block. In which trigger or where do I place the EXECUTE-QUERY ? I can't place it in the post-block because post-block don't accept EXECUTE-QUERY and I dont want to use a timer because it bring me some troubles.
    Than'k you !

    I have two blocks based on the same table. Then it is not a 'real' master detail case. You can easily create a master-detail here, if your data model allows it. A table can have a foreign key relation to itself. E.g. emp.manager_id if the fk to emp.empno.

  • Execute Sql Query

    Hello.
    How can I execute a Query and to store the result in a variable?
    Thanks for your help.
    Regards,
    Jose

    Hi Jose,
    i made a c# sample for you
    SAPbobsCOM.Recordset oRecordSet = null;
    oRecordSet = ((SAPbobsCOM.Recordset)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)));
    oRecordSet.DoQuery("SELECT CardCode FROM OCRD");
    string tmpResult = null;
    tmpResult = oRecordSet.Fields.Item(0).Value.ToString();
    lg David

  • Error message when I execute a query

    Hi,
    When i execute a query appears the message "Error specify a value for variable Z...". I can't execute the query.
    This situation exist from a new release of SAP-BW (7.0).
    Thanks and best regards.
    CV

    Hi Christiano,
    Try these SAP Notes...
    SAP Note Number: 955515
    SAP Note Number: 333208
    SAP Note Number: 1074801
    Also check this thread...
    error
    Hope these helps u...
    Regards,
    KK.

  • In ST03 , how can i see the Query name, user id,how many times executed the

    HI Experts,
    In ST03 , how can i see the Query name, user id,how many times executed the query.
    these details how do i get from the above transaction.
    EX:-if there is one report name X,I want to know how many users had executed X report today,weekly,monthly.
    ex:-query userid total number of execution
    sales order 0000555 5 times
    custmer 05855 2 times
    fast reply will be appreciated,

    Hi,
    Look here:
    http://help.sap.com/saphelp_nw04/helpdata/en/3b/54df4204892a78e10000000a155106/frameset.htm
    Also check these:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/2d/b8be3befaefc75e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/25/ece73a39e74d27e10000000a114084/frameset.htm
    Hope this helps..
    Bye
    Dinesh

  • Can execut a query in Oracle UCM to get View_Values instead of using GET_SC

    Dear All,
    i have a question that i had google it and didn't find anything helpful.
    i want to ask if i can execut a query in Oracle UCM to get View_Values instead of using GET_SCHEMA_VIEW_VLAUES service ?
    ie: asuume that we have a Table name called Employees (having empId, empName) and have a view named as Table name; Employees.
    instead of use the GET_SCHEMA_VIEW_VLAUES service to get the data of Employees, can i write a query, ex: select from Employees*_ to get the data.
    note: i have a connection parameter to connect to oracle UCM database
    any suggestions.
    Regards

    Yes, you can execute the query and store results into a result set (available also in iDocScript).
    There are two sample components that you could use as a starting point - see here http://www.oracle.com/technetwork/middleware/webcenter/content/howtocomponentsbundle-132171.zip or here for 11g http://bexhuff.com/2011/03/howto-component-samples-for-oracle-ucm-11g
    Take a look at DataAccess and DatabaseProvider from the sample stack.

  • How can i know which index will be used when executing the query ?

    1 ) I have query in which i have 3-4 tables but there multiple index on one column .
    so how can i know which index will be used when executing the query ?
    2) I have a query which ia taking too much time . how can i know which table is taking too much time ?
    3) Please Provide me some document of EXplain plan ?

    Hi Jimmy,
    Consider the below example
    /* Formatted on 2011/02/04 21:59 (Formatter Plus v4.8.8) */
    CREATE TABLE FIRST AS
    SELECT * FROM all_objects;
    UPDATE FIRST
    SET object_name = 'TEST'
    WHERE owner != 'SCOTT';
    CREATE INDEX idx_first ON FIRST(object_name);
    SELECT *
    FROM FIRST
    WHERE object_name = 'TEST';
    It has not used index
    Execution Plan
    Plan hash value: 2265626682
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 58678 | 7334K| 163 (4)| 00:00:02 |
    |* 1 | TABLE ACCESS FULL| FIRST | 58678 | 7334K| 163 (4)| 00:00:02 |
    /* Formatted on 2011/02/04 21:59 (Formatter Plus v4.8.8) */
    SELECT *
    FROM FIRST
    WHERE object_name = 'emp';
    This has used the index
    Execution Plan
    Plan hash value: 1184810458
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 128 | 1 (0)| 00:00:01 |
    | 1 | TABLE ACCESS BY INDEX ROWID| FIRST | 1 | 128 | 1 (0)| 00:00:01 |
    |* 2 | INDEX RANGE SCAN | IDX_FIRST | 1 | | 1 (0)| 00:00:01 |
    From this we can come to the conclusion that, whether to use one index or not by oracle
    would also depend on the data which is present in the table. This has to be this way as
    we see in the bind peeking, if oracle sticks to only one plan, say only use the full table
    scan, it would be a performance hit when it searches for the second query ie where object_name
    ='emp';
    2.
    If we have a query like below.
    select * from emp
    where upper(ename) = upper(:p_ename);
    Evenif we have the index on ename column, oracle wouldn't be able to use the index, as there is a function in the predicate column. If you need oracle to use the index, we need to create a function based index as below.
    Create index idx_ename on emp(upper(ename));
    Regards,
    Cool

Maybe you are looking for

  • Double figure for Elimination

    Hi all, This is my detail explaination regarding this issue. When I run balance carryforward for period 1/2008, figure for posting level 20 will carryforward.(RM27,441.0). This is IU figure from period 16/2007. But after I run task IU Elimination, th

  • Can I transfer a video I took on my iphone and downloaded on my computer back to my iphone?

    I want to retrieve a video from my desktop PC that I downloaded from my iPhone and deleted after downloading.   I want to have it back on my iphone.   Is this possible?

  • Cant sync iphone or ipod

    When i try to sync my iphone in itunes, it recognizes the device and starts the registration process. The the computer says new hardware in a small bubble in the lower right hand corner.  It indicates that is it a digital still camera and then reboot

  • HT2311 I want to be able to have iradio, but nothing is working. Help

    I want to be able to have iradio, but nothing is working. Help

  • POSERVICES in BAPI_PO_CHANGE

    Hi Experts, I have situation like this, I need to download(to flat file) the PO sevices details completely into the system and need to mofidy it(Add new lines at the end in Excel file) and need to Upload back the same file back to the SAP system. Now