Displaying the last row value + 1

Hi, I am sure the answer is out there, I just can't find despite hunting around. So a point in the right direction would be great if possible:
I am trying to display the 'future' number from an auto update primary key in an access d/base. I am getting the current number with the code below which obviously means that I just need to add 1 to it; if only it would let me have the result as an integer, but I can't seem to achieve that (can only get a string) therefore tried to make the string an integer, update, change it back & then display in textField, but I can't achieve that either...please help?
  public void findCurrentRow()
    try
      query = "SELECT (customerID) from Professional";
      stmt = myConnection.createStatement();
      rs = stmt.executeQuery(query);
      int i = 1;
      while(rs.next())
        rowNumber = rs.getString(i);
      id.setText(rowNumber);
      id.setEditable(false);
      rs.close();
    catch (SQLException ex)
      fatalError(ex);
  }

I meant to ask why this did not work for you below ?
int rowNumber = rs.getInt(1);//returns an int type
the resultset method getInt() is not returning a integer?
I guessed that you were getting a non numerical return so you decided to return the value to a string getString() and see what was happening like the record value being returned was a float or other non-int type.
int rowNumber = Integer.parseInt(rs.getString(1));
A little off topic you could write your query to be
SELECT (WHATEVER) +1 FROM TABLE; //adds 1 to value
or if the DB has a nextVal func for sequences use that.
Ray

Similar Messages

  • How to Finding the Last Row Value in Datagrid?

    Hi Everyone,
    Thanks in Advance.
    I need your help, to find the last row data in Datagrid.
    Actually i am using Datagrid to display my Data in flex. In my data i stored the gender value of employees. So if the last row in my datagrid is "female" i need to be highlight that particular row. So please help me to solve this issue.
    Thanks,
    Charles. J

    datagrid.selectedIndex = datagrid.dataprovider.length;
    ^ something like this will select the last row in the datagrid.
    if you need to check it's value, you might need to cast an object here, based on the index value, and check it's gender value.
    datagrid.selectedIndex = datagrid.dataprovider.length;
    if (datagrid.selectedItem["gender"] == "female") {
    //handle here

  • How to display the last row in a table

    I have a table that is constantly updating, and I always want to see the last row. How can I get my table to auto scroll?

    Hi žabić,
    there is a property called "top left visible row". You can use it to scroll your table.
    edit:
    Maybe this is not the exact name, but you can see an example here
    Mike
    Message Edited by MikeS81 on 05-27-2010 03:57 PM

  • Using IBM SVC console with firefox 4 does not display the last row of data correctly, also see same the problem with HMC console as well.

    Using Firefox 4.0.1, the IBM SVC console and the IBM HMC console both have the last line of selectable items either cut off, or overlaying the prior row of displayed items. Junked version 4 and reverted back to 3.6.17.

    Seeing the same problem using the HMC with FF7 beta.

  • Formula to calculate the last active value in a row?

    When using a simpe table, what formula will display the last active value in the row? Some of the cells are blank. I want a column to show the most recent value, which in this case will be the rightmost, non-blank cell.

    B2 through J2 are your data
    B3 =IF(B2="","",COLUMN())
    Fill that to the rest of row 3
    A2 =INDEX(B2:J2,MATCH(MAX(B3:J3),B3:J3,1))
    If there are no values in the row, the answer will be an error triangle. You can put the IFERROR function around the formula and give it an answer when there is an error.

  • How to display the last value of a field in a group in the group header

    I need to display the last quiz score from a group of quiz scores as part of the header of a group of units (the quiz score values are in the detail record).  I can not use the group footer, which would be the natural place to find the last value.  It must be in the group header because there will be a subsequent group within the unit group.  In other words, the grouping is as follows:
    Unit Group Header (Display last quiz score in unit)
    SubUnit Group Header (Display other detail summaries)
    Detail Record (including quiz score)
    SubUnit Group Footer
    Unit Group Footer
    While there is a minimum/maximum summary function, there is not a first/last function.
    Fuskie
    Who is constantly amazed at the ability of users to request report features that are not easily implented through Crystal Reports...

    Hi Fuskie,
    One suggestion to display the last quiz score in the Group Header, other than what had already been suggested, will be to use a linked subreport in the Group Header. It is not an efficient way to display the information, but it could do the trick.
    Another suggestion will be to insert a subreport in the report header, then store the last quiz score in an array for each group, then share it with the main report and display the  values in the appropriate group. In this way it will only connect twice to the data source, one for the main report and once for the subreport, instead of multiple connection for each group.
    Finally, the most efficient way will be to have this value calculated on the database side using a command object or a stored procedure.
    Patrick

  • XCelsius list view selection does not show values of the last row/column

    Hallo,
    I have a list view selction in EXcelsius 2008 and there it shows the whole data as it sould and the correct line is marked as selected. When I embedd the swf-File in Crystal Reports 2008 the values of the last column and the last row are empty and the wrong line is marked as selected. What to do?
    Thanks in advance for your help.
    kind regards
    Monika Anna

    .. okay, the area definition in the data manager was incorrect. Now it works ....

  • Get rows where the last row finish off

    Hi, i have two tables AND would LIKE TO get data BY combining both.
    here IS my data
    WITH hist AS
      SELECT To_Date('4/23/2010','mm/dd/yyyy') dt, 999 alias, 'PROC' dom FROM dual UNION ALL
      SELECT To_Date('4/27/2010','mm/dd/yyyy') dt, 999 alias, 'LON' dom FROM dual UNION all
      SELECT To_Date('4/1/2010','mm/dd/yyyy') dt, 111 alias, 'SOC' dom FROM dual UNION all
      SELECT To_Date('4/10/2010','mm/dd/yyyy') dt, 111 alias, 'NAO' dom FROM dual UNION ALL
      SELECT To_Date('3/23/2010','mm/dd/yyyy') dt, 222 alias, 'PSE' dom FROM dual
    final AS
      SELECT To_Date('2/26/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
      SELECT To_Date('4/22/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION all
      SELECT To_Date('4/26/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
      SELECT To_Date('4/30/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
      SELECT To_Date('2/25/2010','mm/dd/yyyy') dt, 111 alias FROM dual UNION ALL
      SELECT To_Date('2/26/2010','mm/dd/yyyy') dt, 222 alias FROM dual UNION ALL
      SELECT To_Date('4/22/2010','mm/dd/yyyy') dt, 222 alias FROM dual UNION all
      SELECT To_Date('4/26/2010','mm/dd/yyyy') dt, 222 alias FROM dual
    the output should be as follow(without the extra blank line of course)
    DT           ALIAS   DOM
    2/26/2010     999     PROC
    4/22/2010     999     PROC
    4/26/2010     999     LON
    4/30/2010     999     LON
    4/27/2010     999     LON
    4/23/2010     999     PROC
    2/25/2010     111     SOC
    4/1/2010     222     SOC
    4/10/2010     222     NAO
    2/26/2010     222     PSE
    4/22/2010     222     PSE
    4/26/2010     222     PSEso what i am doing here is as follow, take one row in hist table (4/23) and join with final table and give me all rows in final table
    where dt <= to the row in hist table and include the row from hist table.
    this logic will give me rows 2/26/2010,4/22/10 4/23/2010
    then the second row in hist table (4/27/2010) wiill get all rows
    in final table that is <= to the current row and pick up the rows starting from the row > than the last row where the 4/23/2010 finished off
    in this case the output will be 4/26/10, 4/27/2010(we need to include row from hist)
    since there is no row in hist that is greater than 4/30/2010, this date will still be display and dom column value should be taking from the max date in hist
    which is 4/27/2010. see output above
    this sound a little confusing to explain but look at output of what to expect as output. the other ids should follow the same logic
    can someone help write a query for this? thanks

    Hi,
    Devx wrote:
    Frank, thanks again, i ran the query in oracle 11g and oracle 9i. 11g runs ok but 9i doesnt. it looks like the ignore null option is not supported in 9i. That's right: IGNORE NULLS was new in Oracle 10. You should always mention your Oracle version whenever you ask a quiestion, especially if it's as old as Oracle 9.
    i will be running this query in 9i. is there any alternative to re-write this query without using last value since ignore null is not supported and the output is not as i expected when i take that keyword out.
    i really appreciate your help. please let me know how would i re-write the query. thanksOne work-around is to use LEAD or LAG instead of LAST_VALUE. This means you have to know exactly where (how many rows away) the most recent non-NULL value is, which in turn requires other analytuic funtions, such as ROW_NUMBER, and more sub-queries:
    WITH     combined_tables        AS
         SELECT     dt, alias, NVL (dom, '_?_') AS dom     FROM hist
         UNION
         SELECT     dt, alias, NULL          AS dom      FROM final
    ,     got_r_num     AS
         SELECT     dt, alias, dom
         ,     ROW_NUMBER () OVER ( PARTITION BY  alias
                                   ORDER BY          dt
                           )               AS r_num
         ,     COUNT (*)     OVER ( PARTITION BY  alias
                           )               AS alias_cnt
         FROM    combined_tables
    ,     got_skip_cnts     AS
         SELECT     dt, alias, dom, r_num
         ,     r_num - MAX (CASE WHEN dom IS NOT NULL THEN r_num END)
                                 OVER ( PARTITION BY  alias
                               ORDER BY          r_num
                             )                    AS skip_before
         ,     MIN (CASE WHEN dom IS NOT NULL THEN r_num END)
                                 OVER ( PARTITION BY  alias
                               ORDER BY          r_num     DESC
                             ) - r_num               AS skip_after
         FROM    got_r_num
    ,     got_next_dom     AS
         SELECT     dt, alias, dom, r_num, skip_before
         ,     LEAD (dom, skip_after) OVER ( PARTITION BY  alias
                                                ORDER BY      r_num
                                 ) AS next_dom
         FROM    got_skip_cnts
    SELECT       dt
    ,       alias
    ,       NULLIF ( COALESCE ( next_dom
                            , LAG (dom, skip_before) OVER ( PARTITION BY  alias
                                                         ORDER BY         r_num
               )     AS dom
    FROM       got_next_dom
    ORDER BY  alias
    ,            dt
    ;You should be able to calculate bot LEAD and LAG in the same query, but there seems to be a bug that only calculates one of them correctly in this case. The sub-query got_next_dom gets around that, by doing the LEAD in a separate sub-query.

  • Display the last item in Content Query web part

    Edited my post
    I was trying to create a CQWP that will display 5 blog posts in the following format:
    Name of the blog                | Previous blog posts:    |
     Post 5                               |  Post 4                     
    |
     Description                        |  Post 3                     
    |
                                             |  Post
    2                      |
                                             |  Post
    1                      |
    --------------------------------------------------------- |
    This was my first time using CQWP and XSLT. So the guys in this forum helped me with the code that finds the last item and splits it from the rest of the posts.
    But when I try to create a format like the table above, is not possible, because <xsl:Template keeps repeating the layout. It seems that CQWP is not made for fanncy layouts. I think it functions in a top-to-bottom fashion.
    If anyone knows how to create the format above, I will be very greatful.
    First post in this threat:
    Can anyone tell me how can I display the last item added using CQWP and XSLT?
    The code below displays all titles. I don't know how can I get the last item. The xslt template below works like a repeater control.
    Any help will be very much appreciated.
         <xsl:template name="abc" match="Row[@Style='abc']" mode="itemstyle">
             <xsl:value-of select="@title"/>
         </xsl:template>
    thank you.

    Try this (you'll need to modify the widths according to your requirements, and sort you're list so that most recent items is returned first)
    <xsl:template name="TestCount" match="Row[@Style='TestCount']" mode="itemstyle">
    <xsl:variable name="DisplayTitle">
    <xsl:call-template name="OuterTemplate.GetTitle">
    <xsl:with-param name="Title" select="@Title"/>
    <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
    </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="ItemNumber">
    <xsl:number></xsl:number>
    </xsl:variable>
    <xsl:choose>
    <xsl:when test="$ItemNumber = '1'">
    <div style="float:left;width:100px;margin:5px;display:block;">First Item: <xsl:value-of select="$ItemNumber"/> (<xsl:value-of select="$DisplayTitle"/>)</div>
    </xsl:when>
    <xsl:when test="$ItemNumber = '2'">
    <div style="float:left;width:100px;margin:5px;display:block;">Last Item: <xsl:value-of select="$ItemNumber"/> (<xsl:value-of select="$DisplayTitle"/>)</div>
    </xsl:when>
    <xsl:when test="$ItemNumber = $ItemCount">
    <div style="clear:both;float:left;width:100px;margin:5px;left:105px;display:block;">Last Item: <xsl:value-of select="$ItemNumber"/> (<xsl:value-of select="$DisplayTitle"/>)</div>
    </xsl:when>
    <xsl:otherwise>
    <div style="clear:both;float:left;width:100px;margin:5px;left:105px;display:block;">Item Number: <xsl:value-of select="$ItemNumber"/> (<xsl:value-of select="$DisplayTitle"/>)</div>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    Regards, Matthew
    My Blog
    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

  • Display the 3rd hieghest value without using rowid

    HI All,
    Can any one help me how to display the 3rd hieghest valuer without using a ROWID..
    Thanks
    Basava

    Frank, using ROWNUM = 1 instead of DISTINCT could be a bit faster:
    SQL> SET LINESIZE 132
    SQL> EXPLAIN PLAN FOR
      2  WITH got_r_num AS (
      3                     SELECT  DISTINCT sal,
      4                                      DENSE_RANK() OVER(ORDER BY sal DESC NULLS LAST) AS r_num
      5                       FROM  scott.emp
      6                    )
      7  SELECT  sal
      8    FROM  got_r_num
      9    WHERE r_num = 3
    10  /
    Explained.
    SQL> @?\RDBMS\ADMIN\UTLXPLS
    PLAN_TABLE_OUTPUT
    Plan hash value: 436395657
    | Id  | Operation                 | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT          |      |     9 |   234 |     5  (40)| 00:00:01 |
    |*  1 |  VIEW                     |      |     9 |   234 |     5  (40)| 00:00:01 |
    |   2 |   HASH UNIQUE             |      |     9 |    36 |     5  (40)| 00:00:01 |
    |*  3 |    WINDOW SORT PUSHED RANK|      |     9 |    36 |     5  (40)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL     | EMP  |    14 |    56 |     3   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       1 - filter("R_NUM"=3)
       3 - filter(DENSE_RANK() OVER ( ORDER BY INTERNAL_FUNCTION("SAL") DESC
                  NULLS LAST)<=3)
    18 rows selected.
    SQL> EXPLAIN PLAN FOR
      2  WITH got_r_num AS (
      3                     SELECT  sal,
      4                             DENSE_RANK() OVER(ORDER BY sal DESC NULLS LAST) AS r_num
      5                       FROM  scott.emp
      6                    )
      7  SELECT  sal
      8    FROM  got_r_num
      9    WHERE r_num = 3
    10      AND ROWNUM = 1
    11  /
    Explained.
    SQL> @?\RDBMS\ADMIN\UTLXPLS
    PLAN_TABLE_OUTPUT
    Plan hash value: 21859616
    | Id  | Operation                 | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT          |      |     1 |    26 |     4  (25)| 00:00:01 |
    |*  1 |  COUNT STOPKEY            |      |       |       |            |          |
    |*  2 |   VIEW                    |      |    14 |   364 |     4  (25)| 00:00:01 |
    |*  3 |    WINDOW SORT PUSHED RANK|      |    14 |    56 |     4  (25)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL     | EMP  |    14 |    56 |     3   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM=1)
       2 - filter("R_NUM"=3)
       3 - filter(DENSE_RANK() OVER ( ORDER BY INTERNAL_FUNCTION("SAL") DESC
                  NULLS LAST)<=3)
    19 rows selected.
    SQL> SY.

  • Hiding bloc of Lines in a web template in the last row

    Hello,
    I want to hide a bloc of lines in a web query.
    Here I use the table interface with the method
    characteristic cell according to the "How to" - paper
    (How to hide a column).
    Normally , there is no problem to set the tag
    '<!--' in the first column ot the row to be suppressed and the tag
    '-->' in the first column of the row, I want to display again.
    But the problem is the last row. Here I must close the
    tag in the last column of the last row. The effect is
    something like a double line at the end of the output.
    (I think, I see here another time the first column of
    a row, because I cannot close the tag properly)
    As a result, I have problems with the print manager, we use to enhance the web printing.
    Can someone give me the information, how to close the tag
    in a proper way at the last row.
    Many thanks for your help.
    Regards
    Ralph

    Hi,
    I don't think this is possible. I would try to use c_cell_extend to extend the style of each <td>-Tag with style="visibility:hidden; display:none" This should have the same affect (for all cells which have to be hidden) (depending on your table styles there might be some padding or spacing effects; you have to try this out).
    Heike

  • Trying to get the last row from a resultset

    Hi,
    I'm trying to do a query to postgreSQL and have it return the last updated value, (last row).
    My prepared statement is returning the correct results, but i'm having a problem getting the latest value.
    I'm using a comboBox to drive a textfield, to load the last entered values in depending on which item in the comboBox is selected.
    I've tried a variety of things and most seem to return the first row, not showing the updated values.
    Or, if it does work, it takes to long to load, and i get an error.
    here is the working code;
    Object m = machCBX.getSelectedItem():
    try { PreparedStatment last = conn.prepareStatement("SELECT part, count FROM production WHERE machine = ?",
    ResultSet.TYPE_SCROLL_INSENSITIVE,  //tried both INSENSITIVE and SENSITIVE
    ResultSet.CONCUR_READ_ONLY);
    last.setString(1, String.valueOf(m));
    rs. = last.executeQuery();
    if(rs.isAfterLast) == false ) {
    rs.afterLast();
    while(rs.previous()) {
    String p = rs.getString("part");
    int c = rs.getInt("count");
    partJTX.setText(p);
    countJTX.setText(c);
    }this grabs values, but they are not the last entered values.
    Now if i try to use rs.last() it returns the value i'm looking for but takes to long, and i get:
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space I also know using ra.last() isn't the best way to go.
    I'm just wondering if there is another way other than getting into vectors and row count? or am i better off to go with the later?
    thanks
    -PD

    OK, you've got a major misunderstanding...
    The relational database model is built on the storage of sets - UNORDERED sets. In other words, when you hand a database a SELECT statement without an ORDER BY clause, the database is free to return the results in any order.
    Now it so happens that most databases will happen to return data retrieved by an unordered SELECT, at least for a while, in the same order that it was inserted, especially if no UPDATE or DELETE activity has occured, and no database maintenance has occured. However, eventually most tables have some operation that creates a "space" in the underlying storage, or causes a row to expand and have to be moved or extended, or something. Then the database will start returning unordered results in a different order. If you (or other people) never ever ever UPDATE or DELETE a table, then on some databases the data might well come out in insertion order for a very very long time; given human nature and the way projects tend to work, relying on that is a sucker's bet, IMHO.
    In other words, if you want the "most recent" something, you need to store a timestamp with your data. (With some databases, you might be able to take advantage of some non-standard feature to get "last updates" or "row change timestamps", but I know of no such for Postgres.
    While this won't solve your major problem, above, your issue with rs.last is probably occuring because Postgres by default will prefetch your entire ResultSet. Use Statement.setFetchSize() to change that (PreparedStatement inherits the method, of course).

  • To find out the last row that is updated in a View Object

    Hi OAF Gurus,
    I have requirement like,
    I have to find out the last row that is updated on a particular View Object and I have send a mail to the users about the change.
    JegSAMassMobVOImpl vo = getJegSAMassMobVO1();
    JegSAMassMobVO is the View Object Name and it displays certain rows that has already been added to the VO in the Page.
    Now the issue is when a user updates a particular row,I have to find which row gets updated and have to send a email to that particular employee about the change.
    Just want to know,how to find out the last updated row in a particular VO.
    Any Help would be appreciated as this a immediate requirement.
    Regards,
    Magesh.M.K.
    Edited by: user1393742 on May 4, 2011 1:06 AM

    Hi Magesh
    It shoud be a Advanced table ,so when user will update the row ,the specific row will fire the PPR and on that event u can capture the row using row reference ,this is the sample code below
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean); OAApplicationModule am =
    (OAApplicationModule)pageContext.getApplicationModule(webBean);
    String event = pageContext.getParameter("event");
    if ("<ItemPPREventName>").equals(event))
    // Get the identifier of the PPR event source row
    String rowReference =
    pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
    Serializable[] parameters = { rowReference };
    // Pass the rowReference to a "handler" method in the application module.
    262
    am.invokeMethod("<handleSomeEvent>", parameters);
    In your application module's "handler" method, add the following code to access the source row:
    OARow row = (OARow)findRowByRef(rowReference);
    if (row != null)
    Thanks
    Pratap

  • Using an index to access the last n values of a certain combination

    I have a large table of the following form:
    Name Typ
    ID NUMBER
    M_DATE DATE
    M_LOC NUMBER
    M_ARTICLE VARCHAR2(30)
    M_TYPE VARCHAR2(30)
    M_MEASURE VARCHAR2(50)
    VALUE NUMBER
    In this table there is only a small number of different locations, articles, types and maesures but a large number of m_date values.
    I want to access the last 10 values for a certain combination of locations, articles, types and measures.
    I have an index
    create index i_res_2 on results (m_loc, m_article, m_type, m_measure, m_date);
    In my opinion it should be possible to access the last 10 values directly by this index, but
    when I do my select in the following way it seems to me that first all datasets with the same
    locations, articles, types and maesures are selected, then sorted by date and then the last 10
    dates are selected. As those datasets are spread over the whole table it needs a higher number
    of physical reads. Is there a way to have an index on m_date and an other form of this query
    that selects the requested values with less phyical reads? (Database version is 10.2)
    SQL> select
    2 id,
    3 m_date,
    4 value
    5 from (
    6 select
    7 id,
    8 m_date,
    9 value,
    10 rank() over (order by m_date desc) r
    11 from results
    12 where m_loc = '14001'
    13 and m_article = '11211-00-00'
    14 and m_type = '0002'
    15 and m_measure = '032')
    16 where r <= 10
    17 order by m_date asc;
    ID M_DATE Value
    3931958 05.03.10 69.00
    3931960 05.03.10 69.00
    3905712 10.03.10 68.60
    3999535 10.03.10 69.70
    3985125 11.03.10 69.40
    3957851 11.03.10 69.60
    3949799 21.03.10 68.70
    4017369 21.03.10 69.00
    3951981 22.03.10 68.80
    3983554 22.03.10 68.80
    Abgelaufen: 00:00:03.00
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 48 | 6 (34)| 00:00:01 |
    | 1 | SORT ORDER BY | | 1 | 48 | 6 (34)| 00:00:01 |
    |* 2 | VIEW | | 1 | 48 | 5 (20)| 00:00:01 |
    |* 3 | WINDOW SORT PUSHED RANK | | 1 | 39 | 5 (20)| 00:00:01 |
    | 4 | TABLE ACCESS BY INDEX ROWID| RESULTS | 1 | 39 | 4 (0)| 00:00:01 |
    |* 5 | INDEX RANGE SCAN | I_RES_2 | 1 | | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter("R"<=10)
    3 - filter(RANK() OVER ( ORDER BY INTERNAL_FUNCTION("M_DATE") DESC )<=10)
    5 - access("M_LOC"=14001 AND "M_ARTICLE"='11211-00-00' AND "M_TYPE"='0002' AND
    "M_MEASURE"='032')
    Statistiken
    1 recursive calls
    0 db block gets
    547 consistent gets
    474 physical reads
    0 redo size
    766 bytes sent via SQL*Net to client
    380 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    2 sorts (memory)
    0 sorts (disk)
    10 rows processed

    I found a solution, which is much better in terms of physical reads and consistent gets even if the optimizer calculates higher costs. But I still think, that there should be an easier way to do this:
    SQL> select
    2 id, m_date, value from results
    3 where
    4 (m_loc, m_article, m_type, m_measure, m_date)
    5 in
    6 (select m_loc, m_article, m_type, m_measure, m_date
    7 from (
    8 select /*+ first_rows(10) */ m_loc, m_article, m_type, m_measure, m_date
    9 from results
    10 where m_loc = '14001'
    11 and m_article = '11370-00-00'
    12 and m_type = '0002'
    13 and m_measure = '032'
    14 order by m_loc,m_article,m_type,m_measure,m_date desc
    15 ) where rownum < 10);
    ID M_DATE VALUE
    2495995 01.02.09 70,4
    2457657 19.01.09 66,9
    2556262 13.02.09 67,4
    2496232 01.02.09 67,6
    2465051 20.01.09 67
    2454994 19.01.09 67,4
    2545951 13.02.09 67,4
    2502216 01.02.09 67,5
    2497533 01.02.09 67,2
    9 Zeilen ausgewählt.
    Ausführungsplan
    Plan hash value: 3924867000
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 122 | 8 (25)| 00:00:01 |
    | 1 | TABLE ACCESS BY INDEX ROWID| RESULTS | 1 | 39 | 3 (0)| 00:00:01 |
    | 2 | NESTED LOOPS | | 1 | 122 | 8 (25)| 00:00:01 |
    | 3 | VIEW | VW_NSO_1 | 1 | 83 | 4 (25)| 00:00:01 |
    | 4 | HASH UNIQUE | | 1 | 31 | | |
    |* 5 | COUNT STOPKEY | | | | | |
    | 6 | VIEW | | 1 | 31 | 4 (25)| 00:00:01 |
    |* 7 | SORT ORDER BY STOPKEY| | 1 | 31 | 4 (25)| 00:00:01 |
    |* 8 | INDEX RANGE SCAN | I_RES_2 | 1 | 31 | 3 (0)| 00:00:01 |
    |* 9 | INDEX RANGE SCAN | I_RES_2 | 1 | | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    5 - filter(ROWNUM<10)
    7 - filter(ROWNUM<10)
    8 - access("M_LOC"=14001 AND "M_ARTICLE"='11370-00-00' AND "M_TYPE"='0002'
    AND "M_MEASURE"='032')
    9 - access("M_LOC"="$nso_col_1" AND "M_ARTICLE"="$nso_col_2" AND
    "M_TYPE"="$nso_col_3" AND "M_MEASURE"="$nso_col_4" AND "M_DATE"="$nso_col_5")
    Statistiken
    1 recursive calls
    0 db block gets
    36 consistent gets
    14 physical reads
    0 redo size
    748 bytes sent via SQL*Net to client
    381 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    9 rows processed

  • Needs  help to retrive the last row in a  select query without using rownum

    Hi ,
    i need to retrive the last row from the select sub query without using rownum.
    is there any other way to retrive the last row other than the below query.
    is that the ROWNUM=1 will always retrive the 1 row of the select query ?
    select from*
    *(select ename from employee where dept_id=5 order by desc) where rownum=1;*
    Please advise.
    thanks for your help advance,
    regards,
    Senthur

    957595 wrote:
    Actually my problem is ithat while selecting the parents hiearchy of the child data using
    CONNECT BY PRIOIR query
    I need the immediate parent of my child data.
    For example my connect BY query returns
    AAA --- ROOT
    BBB --PARENT -2
    CCC --PARENT-1
    DDD IS my input child to the connect by query
    Immediate parent of my child data "DDD" ---> CCC(parent -1)
    i want the data "CCC" from the select query,for that i am taking the last row of the query with rownum.
    I got to hear that using ROWNUM to retrive the data will leads to some problem.It is a like a magic number.I am not sure what the problem will be.
    So confusing with using this rownum in my query.
    Please advice!!!It's not quite clear what you're wanting, but perhaps this may help?
    you can select the PRIOR values to get the parent details if you want...
    SQL> ed
    Wrote file afiedt.buf
      1  select empno, lpad(' ',(level-1)*2,' ')||ename as ename, prior empno as mgr
      2  from emp
      3  connect by mgr = prior empno
      4* start with mgr is null
    SQL> /
         EMPNO ENAME                                 MGR
          7839 KING
          7566   JONES                              7839
          7788     SCOTT                            7566
          7876       ADAMS                          7788
          7902     FORD                             7566
          7369       SMITH                          7902
          7698   BLAKE                              7839
          7499     ALLEN                            7698
          7521     WARD                             7698
          7654     MARTIN                           7698
          7844     TURNER                           7698
          7900     JAMES                            7698
          7782   CLARK                              7839
          7934     MILLER                           7782
    14 rows selected.(ok, not the best of examples as the mgr is already known for a row, but it demonstrates you can select prior data)

Maybe you are looking for

  • How to find out the right task in 2 tasks with same task title

    Hi there, I set 3 main tasks ,A/B/C, every main task have 3 sub-tasks, (code,test, deploye),  all test jobs assign to  1 person. while our staff open his 'my assignment' in tasks , he find 3 same tasks named 'Test'.  Is there any possible that show m

  • Using the TEA with java and C

    I am wondering if anyone knows how to encrypt and decrypt and string of any length using the TEA which only encrypts a two element array of longs. The conversion between strings and longs is not working for me regardless of the method I choose to con

  • Problem in creating custom ABMs

    Hi Everyone, Happy New year to all :) I have a query regarding Requester ABCS. I have created Provider and EBS services based on custom EBOs/ EBMs. I was able to deploy them successfully but I am facing problems in Requester ABCS. For Requester ABCS

  • HT204053 Have just got iPhone 4S but can not face time to iPad please help

    HAve just got iPhone 4S but can not face time to my iPad please help

  • JROCKIT for Solaris 8

    Where do we get Jrockit VM for Solaris 8 ? Thanks..sankar