How to fetch records with two recordset

i want fetch records from the table using two recordset like
ResultSet r1=stmt.executeQuery("select * from pf_data");
i want to take another recodeset
ResultSet r2=stmt.executeQuery("select * from finyr");
I am using Microsoft SQL server as my database.
I am also closing the recordset like r1.close();
then i cannot take two recordset at the same time.

Hi,
This is an example of a Top-N problem, and here's one way to do it:
WITH got_r_num AS
    SELECT  item_id, supp_id, rnk                         -- RANK is not a good column name
    ,       DENSE_RANK () OVER ( PARTITION BY  item_id    -- Just guessing
                                 ORDER BY      rnk
                               )  AS r_num
    FROM    table_x
    WHERE   item_id  = 2      -- If desired
SELECT    item_id, supp_id. rnk
FROM      got_r_num
WHERE     r_num    <= 2
RANK is the name of a built-in function in Oracle, so it will cause lots of trouble if you use it as a column name.  (The RANK function is closely related to DENSE_RANK, used above.)
I hope this answers your question.
If not, post  a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Point out where the query above is giving the wrong results, and explain, using specific examples, how you get the correct results from the given data in those places.  If you changed the query at all, post your code.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002

Similar Messages

  • How to fetch records between two seq uence numbers?

    We have thousands of records with seq uence numbers in the oracle database, we need to retrieve a number of records between two seq uence numbers, i.e. to retrieve records between 100 and 200 seq uence numbers. Could some one help me to find a query to fetch records.
    I'll be waiting for your response..
    Edited by: sumant on Jul 27, 2010 12:42 PM

    Is this is what you are looking for?
    SQL> create table tab1 (id number);
    Table created.
    SQL> insert into tab1 values (1);
    1 row created.
    SQL> insert into tab1 values (2);
    1 row created.
    SQL> insert into tab1 values (3);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from tab1;
            ID
             1
             2
             3
    SQL> select round(dbms_random.value(max(id)+1,max(id)+50)) random_number
      2  from tab1;
    RANDOM_NUMBER
               43
    SQL> select round(dbms_random.value(max(id)+1,max(id)+50)) random_number
      2  from tab1;
    RANDOM_NUMBER
               39
    SQL> select round(dbms_random.value(max(id)+1,max(id)+50)) random_number
      2  from tab1;
    RANDOM_NUMBER
               13 This will generate a random number that will be greater then the maximum value in the table and lower then the maxvalue + 50. Having the range starting from maxvalue in the table you will never get a number generated which already exists in the table.
    As you see in the above number genrated they are all between 4 and 53.
    If you want to increase the range from where the number are generated just increase the value 50 that I used in the query.

  • Working with two RecordSets

    Is it possible to work with two recordsets in one method?
    If so, I havnt been able to figure out how.
    Any Suggestions?
    Stef

    Sure. Why not? But your problem has nothing to with them being "in the same method". It's more likely to do with this quote from the API documentation for java.sql.Statement:
    "Only one ResultSet object per Statement object can be open at any point in time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All statement execute methods implicitly close a statment's current ResultSet object if an open one exists."

  • Hi my name Abukar I had an old apple ID and I had problem with signing it so I decided to make a new apple ID with a new email address, so how can I link with two apple IDs and how can I get back all my previous apps that I purchased before, I cloud stuff

    Hi my name Abukar I had an old apple ID and I had problem with signing it so I decided to make a new apple ID with a new email address, so how can I link with two apple IDs and how can I get back all my previous apps that I purchased before, I cloud stuff

    It is not possible to do that.
    Allan

  • How to show records with zero on dashboard

    hi expert,
    if I have a dimension table product,
    a fact table
    if in the db, there are records with zero values of product A.
    if the logical column for the fact is SUM(...).
    how to show records with zero values on dashboard.
    Use the outer join?
    or other method?
    I dont wanna use outer join because it makes the PRD be so complicated

    hi,
    Pull all the columns to criteria ,it will show NULL for a product
    To get zero,on the fact column use IFNULL(fact_col,0)
    which will look like this
    http://a.imageshack.us/img180/6616/ifnull.jpg
    thanks,
    saichand.v

  • How can I record with GarageBand 1.3 in the background using other app?

    How can I record with GarageBand 1.3 in the background using other app?
    I use iPad 2 with iOS 6 and GarageBand v1.3.
    I'd like to play an other app like Sunrizer synth while the GarageBand is recording in the background in a track.
    By now I can do it only using the build-in mic of iPad, but this is not the point.
    Can I record other apps in a GarageBand track?
    Thanks a lot for your time.

    I suspect you are probably correct about the reasoning, although there are already a myriad of ways to do that.
    Don't get me wrong - I never said I like this. But it is consistent with other Apple applications, that are similar restrictive; you cannot take a screenshot, when dvd-player is running for example.
    That are the moments, when I am glad that MacOS X is a unix system under the hood

  • Need to view all records with two variables in recordset

    Hi - My recordset has two variables used to sort products by popularity and type.  But I want a "View all" link that shows all records, in ascending order, regardless of popularity or type.  At the moment the .php page is set up to receive either the popularity (varPopular) variable or the product type variable (varGrouping).  If neither variable is provided, no products appear on screen.  How do I set up the recordset to allow for all records to be displayed?  Thanks for your help!
    [CODE]
    $varPopular_Recordset1 = "n";
    if (isset($_GET[popular])) {
      $varPopular_Recordset1 = $_GET[popular];
    $varGrouping_Recordset1 = "1";
    if (isset($_GET[grouping])) {
      $varGrouping_Recordset1 = $_GET[grouping];
    mysql_select_db($database_connGiavan, $connGiavan);
    $query_Recordset1 = sprintf("SELECT crystal_colors.cystalid, crystal_colors.displayname, crystal_colors.imagename, crystal_colors.popular, crystal_colors.`grouping` FROM crystal_colors WHERE crystal_colors.popular=%s OR crystal_colors.grouping=%s", GetSQLValueString($varPopular_Recordset1, "text"),GetSQLValueString($varGrouping_Recordset1, "int"));
    $Recordset1 = mysql_query($query_Recordset1, $connGiavan) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $varGrouping_Recordset1 = "$_GET[grouping]";
    if (isset($_GET[grouping])) {
      $varGrouping_Recordset1 = $_GET[grouping];
    $varPopular_Recordset1 = "$_GET[popular]";
    if (isset($_GET[popular])) {
      $varPopular_Recordset1 = $_GET[popular];
    mysql_select_db($database_connGiavan, $connGiavan);
    $query_Recordset1 = sprintf("SELECT crystal_colors.cystalid, crystal_colors.displayname, crystal_colors.imagename, crystal_colors.popular, crystal_colors.`grouping` FROM crystal_colors WHERE crystal_colors.popular=%s OR crystal_colors.grouping=%s", GetSQLValueString($varPopular_Recordset1, "text"),GetSQLValueString($varGrouping_Recordset1, "int"));
    $Recordset1 = mysql_query($query_Recordset1, $connGiavan) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    [Moved to Dreamweaver Application Development forum by moderator]

    To start with, you should be aware of the fact that you have the same recordset code twice in your page.
    You'll find an article that explains how to build a SQL query to do what you want here: http://cookbooks.adobe.com/post_Create_search_query_with_optional_fields-16245.html.

  • How to process reports with two different date fields

    Morning all,
    This question is somewhat similar to what I asked few days back. I created two different reports for two different departments (Credit Control and Free of Charge Control).
    These two reports pull data from two different date fields and has different status check ups.
    Few days back my director requested me if he can have both reports in one report. That is when I asked question from all of you regarding two reports.
    Anyhow, that was created by implementing two sub reports however, the director asked me to combine the two different reports into one in such a way that the output records should be added up with each other hence one single report with all combined data of Credit Control and Free of Charges (not two sub reports in one report).
    The problem here which I am getting is that, both reports uses two different date fields. I can live with two different statuses as that can be easily done within formula/RT however how to create a report with Report Selection Formula condition which looks in both date fields and produces results accordingly?
    I have tried this by not putting any condition in report selection formula and ran the report, it produced total results from past 6 years.
    Any ideas how to produce combined report which has two different date fields?
    Many thanks in advance
    Regards
    Jehanzeb
    What I

    Charliy,
    No the both dates are from two different databases, tables and fields. The Credit date field is from KLAB database under max table where as the FOC date field is from SAE database under maxmast table. Klab date is under credit2 table where as foc date is under order header table.
    So its more like this:
    Klab->Max-Credit2--->Credit_date
    Sae->Maxmast->Order_header---Date entered.
    two dates totally different tables, dbs
    however, I will try your idea too and see if that works.
    Regards
    Jehanzeb

  • How to upload records  in two different interface tables through WebADI.

    We have created custom integrator with two different interfaces to insert records in AP_INVOICES_INTERFACES and AP_INVOICE_LINES_INTERFACE. Also defined the custom layout in which we mention the header and lines column info to be displayed in the spreadsheet. When I tried to create document to upload the records into the interface tables, could find two different interface for header and lines , when we select the header and upload records into the AP_INVOICES_INTERFACES table it was successfull. But couldn't upload records inserted in Lines interfaces tables. How do we upload records in both the table do we have constraint with Web ADI can insert records to only one interface tables. Any recommendation highly appreciated.

    Raghu,
    Thanks for the reply,
    I have a concern, But if you are connecting a another database you have to create one more subreport and each time am creating connections across databases we have to create subreport and go for the design to show the record. Is it any way to have a common field or union records approach in crystal report 2008.
    For Example :
    Approach 1 :
    Emp name           Emp salary      (Common Header)
    Variable Field1    Variable field2   ( Iterations to be done here for records)
    Variable field 1 contains ---> emptbl(employee name), b.emptbl(employee name) (A database, b database, c database or any .db)
    Variable field2  contains --->  emptbl (salary info between databases)
    Approach 2:
    getting all the records and union all the records 
    Thanks
    Murali Sri

  • Common records from two recordset

    Hi All,
    I have a problem.Consider two recordsets A and B. I want
    common records that are present in both A and B . Is there any easy
    way to do this? Please help me out!!!!

    same principle:
    <cfquery name="myQoQ" DBTYPE="query">
    SELECT *
    FROM query1, query2, query3
    WHERE query1.somecolumn = query2.somecolumn
    AND query1.somecolumn = query3.somecolumn
    </cfquery>
    but... unless your different queries query different
    databases (as
    opposed to different tables in the same db), it is better to
    just use 1
    (one) query to select all your data.
    if you post you queries' code and how the tables are related
    (through
    which fields), we'll help you write one query that will pull
    just the
    data you need... unless you do use the queries individually
    in your code
    somewhere (i.e. you do need to use full recordset of all
    queries
    involved at some point in the page - if your queries are just
    for
    creating a QoQ, then you definitely better changing your 3
    queries into
    1 query!)
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

  • How do I record with presenter notes in view?

    I want to develop and rehearse a presentation by recording it.
    The ideal way to do that would be by having the presenter display visible while I record it. That would allow me to view my notes, next slide and timing as I record.
    However, the default seems to be the full slide display. Is there anyway to change this?
    Would having a secondary display make a difference?
    Also is there a way to rerecord only one slide at a time?
    Thanks.
    Paul

    Not sure you can do it with just one display. I tried and can't figure out a way. However, it's a snap with two displays.
    First go to your system preferences and open up displays and make sure to UNCHECK mirror displays.
    Then go to keynote preferences and under slide show check the box to present on primary or secondary display (depending on how you have arranged them in sys prefs) then under presenter display you can use the alternate display to view the presenter info.
    This is always the way I give presentations. I use the projector to show to audience and my laptop as the presenter display. I can always see my notes and what is coming next, the time, etc, but the audience only sees the current slide.
    As a side note by NOT mirroring your displays you can create a "clean wallpaper" on the projector and you audience can't see what you doing on your primary screen. This is great if you want to cue something up but don't want your audience to see it before you are ready.

  • How to enter invoice with two different tax codes in one line?

    Dear friends,
    I have this PO for which I enter the invoice.
    I recieve later a subsequent debit for this PO from the transporter. This subsequent invoice has got extra debits, one with 21% VAT and one with 19% VAT, which means two items with two different tax codes.
    I want to enter this subsequent debit for each item of the PO, and I want to enter both debits in every item of the PO.
    How can I enter in one row in MIRO a debit with two different tax codes.
    Thank you.

    I want in the same line item to enter two tax codes.
    Do you Know if there is any way to do this?
    It is a subsequent debit and it has two items with two different tax codes. I want to enter the subsequent debit for a PO with many items and enter the value of the whole subsequent invoice. So there is the need to enter one line item with two tax codes.
    How can this be done?
    Thank you?

  • How-To allow records with Overlapping Time from SAP R/3

    Hi guys,
    Made reference to SAP Note 336229.
    Maintained my Transfer Rules of <b>Data Source 0HR_PA_PA_1</b> to <b>Info Source 0HR_PA_PA_1</b> and all is green! Unfortunately, still <b>NO</b> data and error IDOC message is " <i>The data request was a full update. In this case, the corresponding table in the source system does not contain any data</i>."
    "<i>The extractor of the DataSource reads the master data tables of the Employee (0EMPLOYEE) and person (0PERSON) InfoObjects and makes changes to these time-dependent attributes available as headcount changes</i>"...<b>says SAP</b>
    Info Object person (0PERSON) works!!!, however Info Object(0EMPLOYEE) is giving me problem whereby <b>in SAP R/3</b> Data Source (Employee - Education and Training) 0EMPLOYEE_0022_ATTR <u>allows</u> time overlapping of records, <b>BUT BW</b> generates an error " The time interval ['99991231'/'19930104'] & (from/to) for the data records 46 and 47 overlaps in characteristic 0EMPLOYEE "
    For example, lets assume there is Employee X with the following entry in SAP R/3.
    Begin Date||| End Date ||| SubType
    01.09.2003||| 01.09.2004||| Professional Cert.
    01.09.2003||| 01.09.2006||| Degree
    SAP R/3 allows this overlapping of time records however, BW does NOT. How can I tackle this overlapping issue in SAP BW?
    With much appreciation!

    Hi guys,
      Please assist to resolve this.
      I attempted to assigned 0DATETO and 0DATEFROM to my attributes of 0EMPLOYEE, but it gives me the following error
    <b>  Characteristic 0EMPLOYEE: Attribute 0DATETO cannot be used w. time-dependent attribte</b>
    <b>  InfoObject 0DATETO cannot be used as an attribute if attibutes already exist that are time-dependent. Attribute 0ANSALARY is such an attribute. A field in the InfoObject 0DATETO is automatically generated in the master data table.</b>
      Once again, what I want is to be able to allow the Records with HighDate in R/3 into my BW Cubes.
      Please please assist !

  • How to fetch records from the database into a combo box?

    Hi:
    I&acute;m really new with ABLBPM and I&acute;m trying to fetch records from the database to display them into a combo box as valid values for a presentation but I&acute;m using a dynamic method with this code:
    <em>for each row in SELECT campo1, campo2 from TABLE</em>
    <em>do</em>
    <em>solicitudes[] = [row.campo1, row.campo2]</em>
    <em>end</em>
    <em>return solicitudes
    </em>And the debugger says that SQL instructions can be used only in fuctions and procedures that are executed on the server.
    Do you know another way to do it?
    P.D. Sorry for my terrible english
    Greetings

    Hi Steve,
    Thank you, your idea is perfect, but when I try to run the screenflow where the combo should be filled I get this error:
    fuego.lang.ComponentExecutionException: No se ha podido ejecutar correctamente la tarea.
    Motivo: 'java.lang.NullPointerException'.
         at fuego.web.execution.InteractiveExecution.setExecutionError(InteractiveExecution.java:307)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:166)
         at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
         at fuego.webdebugger.servlet.DebuggerServlet.redirect(DebuggerServlet.java:136)
         at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:85)
         at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
         at fuego.web.execution.servlet.ServletExternalContext.forwardInternal(ServletExternalContext.java:197)
         at fuego.web.execution.servlet.ServletExternalContext.processAction(ServletExternalContext.java:110)
         at fuego.webdebugger.servlet.DebuggerExecution.dispatchComponentExecution(DebuggerExecution.java:64)
         at fuego.web.execution.InteractiveExecution.invokePrepare(InteractiveExecution.java:351)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:192)
         at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:223)
         at fuego.webdebugger.servlet.DebuggerServlet.doDebug(DebuggerServlet.java:148)
         at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:82)
         at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    Any ideas??
    Thanks and greetings

  • How to display record with most recent date in sapui5?

    Hi
    I have a local json data with me, in which I have number of records.
    And in each record I have an "AENDATE" as a date property.
    Now I want to display the record with most recent date in the records.
    How I can I do it......????????
    Please help me with this.
    Thanks
    Sathish

    How about sorting your json model descending, and display only first (index:0) item?

Maybe you are looking for

  • IOS 7 and Ford sync

    iOS 7 problems with ford sync. Skip track button no longer works, i have a 2010 ford mustang gt with sync, everything worked fine with iOS 6....any idea what the problem is?

  • IPhoto 11 doesn't load my old photo library

    I have an old iphoto library and my new iphoto 11 allows me to locate and load the 1.5 GB file, but when it loads there ia nothing? No events or photos? The library doesn't upgrading, so how do I load my old photos? Thanks Ant.

  • EXCLAMATION POINTS in iPhoto 6?

    Hi there, I'm a long time Mac user, but this problem is something I have never seen. In iPhoto 6, all of my photo albums are present and all of the thumbnails are there. However, when I click on some thumbnails (the pic should now enlarge in the view

  • Affordable hardware for VHS - PowerMac

    I am working on digitizing a large collection of VHS and 8mm home videos. So far I've been running the video through a digital camcorder to get it onto my PowerMac. The resulting sizes of the files is larger than it needs to be, since the digital cam

  • Safari's "cryptic" web pages

    I have the latest version of Safari and some web-pages and all RSS pages are not appearing properly on my screen. Instead of letters or words they are displayed as symbols. How do I fix this this?