How to fetch each row data

Hi,
I have written a CQL query with rows 3 records. In that query is it possible to fetch first record and last record specific field values.
for example,
Column: c1, c2, c3
record1: id1, 2.3, 3.5
record2: id2, 2.3, 3.6
record3: id21, 2.3, 3.7
record3: id25, 2.3, 3.9
I need to get moving average of three rows of c3 and get first record id and last record ids.
output1: id1, id1, avg(c3)=3.5
output2: id1, id2, avg(c3)=3.55
output3: id1, id21, avg(c3)=3.6
output4: id2, id25, avg(c3)=3.733
Please help on above.
Thanks,
Sri

I have one more question.
The average output is given as input to pattern match processor.
The double differentiation differentiation of first 2 average input data in CQL pattern match is written as:
<view id="FetchRows">
     <![CDATA[ istream(select * from mdepthChannel)
                 ]]>
</view>
<query id="ExampleQuery">
     <![CDATA[ select *      
                 from FetchRows 
                 MATCH_RECOGNIZE (
                 Measures
                         v1.wellUid as wellUid,
                         v1.arrivalTime as arrivalTime,
                      v1.wellboreUid as wellboreUid,
                      v1.mdepthAverage as mdepthAverage,
                      v1.wopAverage as wopAverage,
                      v2.mdepthAverage as v2mdepthAverage,
                      v2.wopAverage as v2wopAverage,
                      v3.mdepthAverage as v3mdepthAverage,
                      v3.wopAverage as v3wopAverage,
                      getCalculateDerivative(v2.mdepthAverage,getCalculateDerivative(v1.mdepthAverage,v1.wopAverage,v2.mdepthAverage,v2.wopAverage),v3.mdepthAverage,getCalculateDerivative(v2.mdepthAverage,v2.wopAverage,v3.mdepthAverage,v3.wopAverage)) as derValue
                 ALL MATCHES
                 PATTERN (v1 v2 v3)
                 DEFINE
                 v3 as (getCalculateDerivative(v2.mdepthAverage,getCalculateDerivative(v1.mdepthAverage,v1.wopAverage,v2.mdepthAverage,v2.wopAverage),v3.mdepthAverage,getCalculateDerivative(v2.mdepthAverage,v2.wopAverage,v3.mdepthAverage,v3.wopAverage)) <= 0.0)               
                    ) as T
                 ]]>           
</query>
Where "getCalculateDerivative" is the java function returns slope of straight line.
The output of this query returns correct data till 7th record after that it repeats 6nd record.
That 8th record is the same as 6th record data.
Why that 8th record is the 6nd record repeats.
The desired output is same as input record if pattern matches.
Please help on this.
Thanks,
Sri
Edited by: 897694 on Mar 27, 2012 2:15 AM

Similar Messages

  • How to fetch single row data into multiple columns

    Hi Have a cursor
    which will have SELECT Sun_hrs,Mon_hrs,Tue_hrs,Wed_hrs,Thu_hrs,Fri_hrs,Sat_hrs from OTMaster;
    now my cursor has one row of the above columns with this row data I want to insert into other tale as column wise
    ex:
    my row is like this: Sun_hrs,Mon_hrs,Tue_hrs,Wed_hrs,Thu_hrs,Fri_hrs,Sat_hrs
    01:00 01:00 01:00 01:00 01:00 01:00 01:00
    now I want to insert the above data into table with loop along with weekday
    weekday, OTHrs
    1 01:00
    2 01:00
    3 01:00
    4 01:00
    5 01:00
    6 01:00
    7 01:00
    which type of variable I need to fetch the records, rowtype or tabletype,
    plz help me

    thank you for information, and now I am using UNPIVOT below is my query
    SELECT * FROM OTCEILINGMASTER
    UNPIVOT(OTHOURS FOR WEEK_DAY IN (SUN_CEILING_HRS AS '1',MON_CEILING_HRS AS '2',TUE_CEILING_HRS AS '3',
    WED_CEILING_HRS AS '4',THU_CEILING_HRS AS '5',FRI_CEILING_HRS AS '6',SAT_CEILING_HRS AS '7'));
    when I am selecting all the columns (select * from OTCEILINGMASTER) then only the above query is executing I want only two columns from the table however my table has 10 columns.
    please looking into this

  • How to fetch indivdual rows from a dynamic query.

    Hi,
    I wish to fetch the individual rows returned from a dynamic query.
    if my dynamic query is:
    dyn_stmt := select col1, col2, col3
    from tab1;
    The query returns multiple rows.
    Then how to fetch individual rows of this query ?
    Please explain.

    declare
      cur_test sys_refcursor;
      c1 varchar2(30);
      c2 number;
      c3 date;
    begin
      dyn_stmt := select col1, col2, col3 from tab1;
      OPEN cur_test FOR dyn_stmt;
      LOOP
        FETCH cur_test INTO c1, c2, c3;
        IF cur_test%NOTFOUND THEN
          EXIT;
        END IF;
        -- Process this row
      END LOOP;
      CLOSE cur_test;
    END;

  • How to fetch year till date value for earning for current ,last and year

    hi,
    how to fetch year till date value for earning for current ,last and year before that from payroll result
    plz reply soon,
    pratyush

    Dear Pratyush,
    Pick this from CRT.
    Use LDB PNPCE & Fire event GET PAYROLL &
    then you can pick from CRT.
    Hope this helps.
    Kindly reward in case useful.
    Regards & Thanks,
    Darshan Mulmule

  • How to get current row data in table control

    Hi , expert ,
       I am professional in oracle ,  but  now I am a new guy in SAP ABAP .
    I  have a question in UI
    How to get current row data and click pushbutton  in table control  to open next screen ?
    I want to get the current data and open next screen to carry out detail detail .
    Thansk for all your suggestion .

    GET CURSOR LINE SY-CUROW .
      READ TABLE internal_table index SY-CUROW.

  • How to obtain the row data in the component datatable?

    if I want to edit a row data, and then know which row is edited in the component datatable, and how to do?
    How to obtain the row data in the component datatable, and update it to database, not simplely edit a simple table
    Any ideas? Thanks

    Thank you very much for your help Alexander !
    It's quite confusing when you leave Struts and try to adapt your projects for JSF for the first time...
    I wanted to click on a row with a "onMouseClick" on the TR tag like I used to do in Struts/JSTL. But it seems to be impossible in a dataTable.
    Ok then. I've added a column at the end of the row with an icon.
    But eventually I didn't need to declare link parameters.
    In my BackingBean I did like this :
    public String selectEventForUpdate() throws IllegalAccessException, InvocationTargetException {
            PortletAgenda event = (PortletAgenda) JSFUtils.getInRequestMap("event");
            BeanUtils.copyProperties(this, event);
            return null;
       }JSFUtils.getInRequestMap(...) is a method I wrote in a util object :
    public static Object getInRequestMap(String name) {
            Object res = null;
            Map requestMap=FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
            if (requestMap!=null) {
                res=requestMap.get(name);
            return res;
    }  " event " is the name of the item in my dataTable list.
    My backingBean has the same attributes as "event".
    So when the page is reloaded I have a backingBean full with the selected properties to edit/update.
    Thanks to your reply I realized that putting this form in the middle of the dataTable seems to be impossible.
    So I put this form in a floating DIV in front of the table with a shadow.
    It works :o) !
    But I'm a little bit disapointed to be honest...
    I used to build my web applications with Struts and JSTL and doing this kind of interface was really easy.
    I've decided 3 days ago to convert into JSF because the "GUI Layer" seemed to be improved.
    But now I realize that I cannot put a onMouseOver and onMouseClick on a row and I cannot display a different row in the middle of a table....
    I think it's a shame because there is a facet for header and footer.
    And it would be great if we could create our own personal facet that appears only if a condition is true.
    For exemple " if the current item id is the same as the request parameter id then display the following facet content ....... (with a panel group and a form inside to update the row) "
    It's easy to do that with JSTL thanks to c:forEach and c:if but it seems to be impossible to use JSTL tags like this during the dataTable iteration.
    And JSF tags seems to have no logical tags like " if " or loops that can be nested in dataTable.
    I really need to realize this interface (you click on a row then an edit form appears where you clicked).
    Do I have to write a component myself that extends dataTable?
    Do you know if writing such a component is hard to do for a beginner like me?
    (I've juste discovered JSF 3 days ago and I've used Struts/JSTL for 2 years til now)
    I'd be glad to have much advices from you about that.
    Regards

  • How to get each row between ranges

    Hi,
    How can i get the each row between range.
    e.g
    I have date range, 01012005 to 01012007.
    I want to get all month and year in internal table between this range.
    helpfull answers will be rewarded.
    Thanks,
    Message was edited by:
            Sal Khan

    data : begin of itab occurs 0,
             month(2),
             year(4),
            end of itab.
    data : lv_start type sy-datum,
             lv_end type sy-datum.
    lv_start = '20050101'.
    lv_end =  '20070101'.
    while lv_start le lv_end.
    itab-month = lv_start+4(2).
    itab-year = lv_start+0(4).
    append itab.
    lv_start4(2) = lv_start4(2) + 1.
    endwhile.

  • How to fetch a row with maximum rownum

    In my sql query, how can i fetch the row with max row count? the query has around 10 columns.
    Thank You
    KK

    Hi,
    It's not very clear what you want.
    It sounds like you want a Top=-N Query , perhaps like this:
    WITH     got_row_cnt     AS
         SELECT       job
         ,       COUNT (*)                         AS row_cnt
    --     ,       ...  -- other columns
         ,       RANK () OVER (ORDER BY  COUNT (*) DESC)     AS rnk
         FROM       scott.emp
         GROUP BY  job
    SELECT     *     -- or list all columns except rnk
    FROM     got_row_cnt
    WHERE     rnk     = 1
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • How to access each row value for a database item

    On my form I have a database datablock that represents a table in my database.
    5 rows are shown with a scroll bar that can be viewed to show the rest.
    The user is able to change some of the Database Item values represented in this datablock for any row shown in the datablock.
    I need to validate the correctness of the users change before allowing the database datablock to update the table in the database.
    But a database item in a datablock will represent a value for every row in the table. So how do I access each row value for a database item separately. What is the PL/SQL syntax?
    thanks,
    michelle

    In my situation it was better to use the loop instead
    of a when validate trigger because...Well it was clearly not better to use a loop that doesn't work. I don't understand what you're not clear on about the item and record validation triggers. If you have a specific validation rule for a single field (such as a date that cannot be in the future), that would go in a When-Validate-Item trigger on the date item. If the user enters a future date, your code would display an error message and raise a failure. Raising a failure prevents the item from being marked as valid. Invalid items prevent the record from being inserted/updated. Sometimes you have a validation rule that requires looking at more than one item at a time, such as two items that must either both be NULL or NOT NULL. In that case, you could not use a When-Validate-Item trigger because you can't clear or populate both at once. So then you would use a When-Validate-Record at the block level and if one field is NULL and the other isn't, you would display an error message and raise a failure. Forms is very civil in this respect; we don't throw exceptions around here, but then I digress.

  • How to compare each row in an internal table

    Hi,
    Say I have an internal table with 3 fields in each row, num1, num2, num3, each type of integer i, now I want to get the maximum of num1, num2, num3 and put this maximum number into num4, may I know how can I do that? Also, if say I need to pull out this num4 and play around with it, sould I just loop it into my workarea of internal table and assign a variable for whatever that is in the work area? Thanks a lot!
    Regards,
    Anyi

    Hi,
    Inside a loop of the table compare each field like this:
    loop at itab.
    l_num4 = itab-num1.
    if l_num4 < itab-num2. l_num4 = itab-num2. endif.
    if l_num4 < itab-num3. l_num4 = itab-num3. endif.
    Here you can play with the maximum number
    itab-num4 = l_num4.
    modify itab.
    endloop.
    You can also do the same using field-symbols (it's faster to assignations) :
    loop at itab assigning <a>.
    endloop.
    Regards.

  • How to get selected row data of an ADF table in HashMap?

    Hi,
    Can anyone please tell me how to selected row data of an ADF table in HashMap like :
    Object obj = pageTable.getSelectedRowData();
    JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)obj;
    Now in above code I want the convert rowData in HashMap.
    Can anyone please tell me how to do that? Its urgent.
    Thanks,
    Vik

    Vik,
    No need to ask the same question 3 times...
    In [url http://forums.oracle.com/forums/message.jspa?messageID=4590586]this post, Nick showed you how to get the Row.
    If it were so urgent, you could have done a little reading of the javadocs to come up with code like this (not tested, up to you to do that)
    HashMap m = new HashMap();
    Row r = get it like Nick showed you to;
    Object values[]=r.getAttributeValues();
    String names[]=r.getAttributeNames();
    for (int i=0; i<r.getAttributeCount(); i++)
    m.put(names, values[i]);

  • How to bind dynamic row data to submit it by HTTP submit (PHP) - addInstance and Data Binding

    Hi,
    i have got a problem with submit HTTP all data (variables) from PDF to submit.php.
    I have got table with dynamic add/remove Table Row button. When i add it their names are Table.Row[0] , Table.Row[1], Table.Row[2] etc. Only Table.Row is real, and every other row is create dynamically by addInstance script command.
    When i fill "Data Binding" box like this: "Use name(Row)" then after submiting it do PHP i will see only last Table.Row data. For example if last would be Table.Row[3] then i will see only this on my submit.php and the others will be replaced by this value. This is happen becouse of replacing value by value with the same name (data binding is seeing only one Table.Row without instance name:"[1]", "[2]", "[3]" etc.).
    I guess that if i would change something to get addInstance command with Row names like Row1, Row2, Row3 then all will be ok.
    Another way it`s to change something in the "Data Binding" box (Object > Binding Tab) to get relative name like Row[*] instead of "Use name(Row)".
    I don`t know how to solve it and i need your help

    Create a binding for your dataTable.
    In the binding create a UIData element with gettters and setters.
    You can manipulate rows and columns from it.

  • How to fetch last changed date for Header in me22n?

    Hi Experts,
    I need to create a report for PO, where I have created one screen tab in Header level(customer data), therefore I need to fetch last changed date for header , I must mention that I do not want last changed date for item level, only for header last changed date is required.
    Kindly assist me on this.
    Thanx
    Shireen

    Read table CDHDR (object "EINKBELEG") and CDPOS (look for table name EKKO), keep the last CDHDR record with "EKKO" data actually changed.
    Regards,
    Raymond

  • How to fetch n rows at a time?

    I know that I can use the rownum function to return n rows at a time, but the rownum function will be applied after all rows are returned by the query, which is bad for performance since my table has lot of rows. What I need is really to fetch n rows at a time from the DB.
    Regards

    I am not sure what you mean by "the rownum function will be applied after all rows are returned by the query", but that appears to be an incorrect statement. If you have a ROWNUM limit in a query, Oracle knows that it only has to fetch the first M rows.
    If you are looking for an ability to page through query results, there is an AskTom thread on pagination in SQL.
    This would only be appropriate, though, if you expect that users will only ever want the first few pages of results (i.e. users of Google aren't going to look through every page of results for generic search terms, they are going to look at page 1, maybe page 2 and page 3, and then stop). If the application is going to process all the rows that the query returns, you'd need some other construct and we would need some additional requirements. Your client application can probably fetch N rows at a time. If the client is PL/SQL, a BULK COLLECT with a LIMIT clause may also be appropriate.
    Justin

  • How to send multiple row data into an internal table??

    I have a view with table control.i want to select multiple row and send all the row data into an internal table.i am able to select multiple row but all the selected row data is not going to the internal table.....only a particular row data which is lead selected is going.
    Do anyone can help me regarding this issue?
    Thanks in advance,
    Subhasis.

    Hey,
    Some code example:
    declaring an internal table and work area to get all the elements from the node.
    data : lt_Elements type  WDR_CONTEXT_ELEMENT_SET,
             ls_Element type  WDR_CONTEXT_ELEMENT_SET,
    considering flights is my node.
             lt_data type sflight.
    Node_Flights is the ref of the node to which ur table is binded.
    Use Code Inspector to read the node.
    lt_Element = Node_Flights->GET_ELEMENTS
    loop at lt_elements into ls_Element.
    l_bollean =   ls_elements->is_selected ( returns abap true/false ).
        if l_bollean IS INITIAL.
           append ls_Element to lt_data.
       endif.
    Hope this would help.
    Cheers,
    Ashish

Maybe you are looking for