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

Similar Messages

  • 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

  • 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

  • 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.

  • Dynamic query in where clause while looping in an internal table.

    Hi,
    Had a small question : How can i make a dynamic query for the WHERE clause while looping at an internal table.
    i want to implement a dynamic where clause query for the below example.
    it_cfx_col is an internal table and wa_cfx_col is a work area for it_cfx_col
      DATA :
      i_cfx_col TYPE TABLE OF cfx_col,
      wa_cfx_col LIKE LINE OF i_cfx_col.
    DATA : count TYPE i VALUE 0.
    DATA : l_where_clause TYPE string,
             l_where_clause2 TYPE string,
             l_name type string.
    l_name = 'NANDANOM'.
    l_scenario = 'collaboration'.
    LOOP AT it_cfx_col INTO wa_cfx_col
    WHERE CREATED_BY = l_name
    AND SCENARIO = l_scenario.
    count = count + 1.
    some business logic implemented using the work area wa_cfx_col
    endloop.
    Now i want to write a dynamic query for the where clause.
    DATA : count TYPE i VALUE 0.
      DATA : l_where_clause TYPE string,
             l_where_clause2 TYPE string,
             l_name type string.
    l_name = 'NANDANOM'.
    l_scenario = 'collaboration'.
      l_where_clause = 'CREATED_BY = l_name'.
      l_where_clause2 = 'AND SCENARIO = l_scenario'.
    if l_scenario is not initial.
      CONCATENATE  l_where_clause l_where_clause2
      INTO l_where_clause SEPARATED BY space.
    endif.
    LOOP AT i_cfx_col INTO wa_cfx_col
    WHERE (l_where_clause).
    count = count + 1.
    some business logic implemented using the work area wa_cfx_col
    endloop.
    when i compile this i get an error message as { Statement concluding with "...(l_where_clause)" ended unexpectedly}
    Even i changed the initilization of the variable  l_where_clause2 to [ l_where_clause2 = 'AND SCENARIO = l_scenario.'. ]
    added the end of line demarkation ".", but still i got the same error message.
    Is it a limtation in ABAP that i cannot write a dynamic query for the where clause while looping at an internal table?
    Regards,
    om

    Hi savita,
    there in no such 1 limitaion in abap for dynamic query .. i think the  error meassge is only beacuse of your synatx delcartaion.
    >> LOOP AT i_cfx_col INTO wa_cfx_col
       WHERE (l_where_clause).
       count = count + 1.
    some business logic implemented using the work     area    wa_cfx_col
       endloop.
    afted delclarataion also , in the where statement you should specify both the field name and value bname
       LOOP AT i_cfx_col INTO wa_cfx_col
       WHERE l_where_clause = 'CREATED_BY = l_name' .
       count = count + 1.
    hope it helps.
    regads
    priya.

  • How can I update cluster items from inside a while loop that does not contain the cluster?

    I have a VI that contains front panel clusters and two while loops. The main cluster contains items such as a doubles "distance" and "stepsize" and boolean "step" (a whole buch of this type stuff). The first loop contains an event structure to detect front panel changes and the second contains code and sub VIs to perform operations based on detected events.
    The operator can enter data into either double or click the boolean. If distance is changed the second loop does what is required to process the change. The same happens with stepsize. If step is clicked the ±stepsize value is added to distance and the result is processed. In each case the front panel should track the result of the input and subsequent processing.
    Because the clusters are outside the while loop, they are not updated unless I click 'highlight execution' which seems to allow updating each time the execution highlight is updated. There are other issues if I move the clusters into one of the loops.
    I've tried referencing the clusters and using local variables and nothing works. It looks like overkill to use shared variables for this.
    Any ideas would be greatly appreciated.
    Thanks,
    Frank    

    Hi Ben,
    Thank you for the response. I followed the link and tried reading everything you posted on AEs but I'm afraid that I didn't understand it all. It seems that each AE example had a single input and a single output (e.g. a double). Is this the case? 
    What I have is a couple of front panel clusters containing (approximately) 18 control doubles, 8 indicator doubles, 5 boolean radio button constructs and 26 boolean control discretes. I clusterized it to make it readable. In addition I'll eventually have a cluster of task references for hardware handles.
    All I want to do is update the front panel values like I would do in a C, VB or any other language. I've tried referencing the cluster and using the reference from inside the loops. I've tied using local variables. Neither works. I'm experimenting with globals but it seems that I have to construct the front panel in the gloabal and then I wouldn't know how to repoduce that on the front panel of the main VI.  Sometimes it seems that more time is spent getting around Labview constructs than benefitting from them.
    I hope the 'Add Attachment' function actuals puts a copy of the VI here and not a link to it.
    Thanks again for the suggestion,
    Frank 
    Attachments:
    Front Panel Reference.vi ‏33 KB

  • 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.

  • 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.

  • How can I use the symbol "or" in a while loop

    I have an error in the attach Vi. Do you know how I can fix it? Thanks
    Attachments:
    while_ctrl.vi ‏33 KB

    No. When you compare two numbers, you get a number out. Look at and read the function help. Try this. The function I used is Elapsed Time. Somehow the label got mangled when I pasted it into paint.
    Message Edited by Dennis Knutson on 03-20-200602:35 PM
    Attachments:
    Elapsed Time.JPG ‏13 KB

  • 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.

Maybe you are looking for

  • Disappointment with Apple customer service's response to my iMac G5 issues

    The following is a copy of the letter that I will be sending to Apple in regards to my recent dealings with customer service. What do you guys think I should do? To whom it may concern: Let me begin by saying that I have been a loyal and avid fan of

  • Document in R3 Server

    Hello Can anybody gives input how to save document in R3 system itself, instaed of saving in other network/server can we save document in R3 in an indexed manner. So that data maintenance will be secured and DR ensured Regards Dinabandhu

  • HP X4000b Bluetooth Mouse (H3T50AA) stops working if not moved for a while, then computer crashes

    I will be very happy if someone answers this, 'cos from all the other related posts, my outlook is pretty bleak. At least give me the thumbs up for trying, or a little human contact. Proof this post existed. Alright, I (fairly) recently updated to wi

  • Blackberry pearl 8120

    I tried to download latest software for this phone using a usb lead from the laptop.  I had to unplug before it finished as it had taken nearly an hour , which should of only been 20 mins. The phone has never come back on, only a red light coming on

  • Ssrs 2008 r2 export to csv file problem

    In an SSRS 2008 R2 report, the users are going to export the data to: csv (comma delimited) and  excel. I am using the following to display if a column is visible or not: =IIF(Mid(Globals!RenderFormat.Name,1,5)="EXCEL" AND First(Len(Fields!CustomerNu