How get Required Number of Records

I have to Tables stk_tble and pur_tble
stk_tble containts current stock balance and pur_tble contains purchase detail
select item_code,net_qty from  stk_tble
where item_code='BS-1034W'
ITEM_CODE              NET_QTY
BS-1034W                     1
select item_code,doc_no,txn_dt,qty from  pur_tble
where item_code='BS-1034W' order by txn_dt desc
ITEM_CODE            DOC_NO               TXN_DT          QTY
BS-1034W             14217                23-APR-12         3
BS-1034W             13696                16-MAY-10        30I want to develop a query or a cursor or a loop.That will exit when sum(purchase_qty)>=Stock qty
Suppose in the above example BALANCE Is 1 so
the Query will show me
ITEM_CODE            DOC_NO               TXN_DT          QTY
BS-1034W             14217                23-APR-12         3If BALANCE is suppose 10 then it will show me
ITEM_CODE            DOC_NO               TXN_DT          QTY
BS-1034W             14217                23-APR-12         3
BS-1034W             13696                16-MAY-10        30As balance of both of Transaction >=10 i.e. our balance qty

You didn't mention your forms-version.
Option 1:
Loop over the records in a cursor-loop and exit the loop when the quantity is reached.
Option 2:
Use the analytical option SUM() OVER (ORDER BY ..) to do it in one query.

Similar Messages

  • How to get the number of records of a streaming result set

    Hi guys.
    So if it wasn't a streaming result set, I would have done this:
    {noformat}myResultSet<code class="jive-code jive-java">.last();
    {color:navy}*int*{color} numResults = </code>myResultSet<code class="jive-code jive-java">.getRow();
    </code>myResultSet<code class="jive-code jive-java">.beforeFirst();
    </code>{noformat}
    but being a streaming result set, beforeFirst() throws an exception...
    So how do you get the number of records in that result set? I wanna avoid an extra count(*) query, so I would appreciate other solutions than that.

    JoachimSauer wrote:
    vanwil wrote:
    you see, for now I just use a count(*) query to get the number of records, but that's adding a lot of extra waiting time...Iterating over the result twice will surely be slower then doing the count(*).great! so what I got now is actually the fastest way there is... awesome...
    If you get an exception, then you surely have a stack trace. That should tell you what happens, or at least where.com.mysql.jdbc.MysqlIO.checkForOutstandingStreamingData(MysqlIO.java:2066)
    Why do you need to know the number of elements beforehand, anyway?I need to know the number of elements because the incoming data goes into a table. Now of course, I could use ArrayList<String[]> or something, but wouldn't that require more memory resources than Object[][] ?
    No one can tell you that, at least not without more information (say, the stack trace for example).Here's the exception message:
    java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@10c0ef2 is still active. Only one streaming result set may be open and in use per-connection. Ensure that you have called .close() on  any active result sets before attempting more queries.

  • How to determine number of records in recordset returned by stored procedure?

    In TestStand 3.0 I am calling an SQL stored procedure where the stored
    procedure returns a recordset. Everything appears to work (I can
    iterate through the recordset and see that the data is valid).
    However, I can not figure out how to easilly determine how many
    records are actually in the recordset. Unlike the 'Open SQL
    Statement' step, in the 'Data Operation' step that actually invokes
    the stored procedure, there is no 'Number of Records Selected' option
    to specify a TestStand variable to accept this value. I know I could
    iterate through the returned recordset incrementing a counter until a
    Fetch fails, but for larger recordsets, traversing the table multiple
    times would be quite time consuming
    . I am hoping to avoid this if
    possible. Is there an easier way to get the number of records in a
    recordset returned from a stored procedure call?
    Bob

    Bob -
    The cursor type of the ADO Recordset object affects whether the number of records can be determined. The Recordset.RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source.
    Because ADO does not let me set the cursor type for command objects which is what a stored procedure requires, it is up to the data source to determine the type of cursor and the support for record count.
    Scott Richardson (NI)
    Scott Richardson
    National Instruments

  • Any table or program to get the number of records in P, A and F tables

    HI all
    any table for program to get the number of records in P, A and F tables. I want to create SQ01 queries to get the status of number of records. We are gng for a production cutover next week. Want to capture all the data before and after Upgrade cutover.
    Also suggest me how to create sq01 queries.
    Thanks in advance
    regards
    Janardhan KUmar K.

    Use Transaction LISTSCHEMA to see all the tables assosciated with ur cube
    Total number would be what you find in both the E & F fact tables. If there is no compression in the cube then E table will be empty.
    Alternatively u can use se16 transaction and enter E table and F table manually
    E table - /BIC/E(Cube name) and Ftable -  /BIC/F(Cube name)
    Or else u can go to the manage of the cube and without selecting any field for O/P and ticking the option output number of hits execute. The total of Row Count will give u the total no of records in the cube.

  • How to find number of records in a cube and ODS....

    Hi,
    How do we find total number of records in a cube and ODS?
    Is there any Tcode for this ?
    From the content it is difficult to get the number of records, if it is more in number.
    Thanks,
    Jeetu

    Hello ,
              Please check the following thread,
    Number of records in a infocube
    hope it helps,
    assign points if helpful.

  • Forms: how to use COUNT_RECORD to get the number of record retrieved?

    After GO_BLOCK(BlockName)EXECUTE_QUERY, there must a way to obtain the number of records retrieved.
    I like to use this number to display to number of records on the form.
    Clearly, a not so good way is:
    SELECT COUNT(*) INTO :NUM_RECORD FROM Table_Name;
    It queries table one more time.
    Could any one give a clue?
    Thank you.

    Dear Kiran,
    Fom tables EINE (inforec no, plant) and EINA (inforec no, material, vendor), you can get the desired information.
    Regards,
    Prasanth

  • FORMS 9i issue: Is there a [b]SYSTEM build-in to get the number of records?

    In master-detail data blocks, a query generally return multiple records from the detail table. I'd like to know how to get the number of the records:
    1. I use NEXT_RECORD to navigate these records
    2. use SYSTEM.CURSOR_RECORD to know the current record
    3. use SYSTEM.LAST_RECORD to know when the last record is reached.
    What is missing is the total number of the records.
    Thank you in advance for helping

    My tip would also be the summary item

  • To get  the number of record from cmp

    how can i get the specific number of record (25 records) from cmp using weblogic8?
    anybody know pls tell.

    http://java.sun.com/j2se/1.4.1/docs/api/java/io/File.html

  • How to count number  of records for a field based on condition?

    Hi guys,
    I want to know how to find count of records coming from the database for a particular field based on some condition.
    I need to use this count to suppress some headers. Because of this i am not able to use running totals. Is there any other way?
    Ex scenario:
    I have account number and currency fields, those are coming from database. And i need to count the number of accounts whose currency is not Euro.
    Thanks in advance,
    Vijay.

    A simple formula can do that:
    //Formula begin
    if {your account field}<>"Euro" then 1
    //Formula end
    This formula can be summarized. (by group or report)
    Bryan Tsou@Taiwan

  • Hi Gurus! how to count number of records in any column of ALV Grid report

    Hi Guys!
    I want to know how can we count the number of records in any column selected by the user. Like for oe customer there might be 20 sale order that means for 10 customer there will be 200 Sale order. So if i select cutomer number column ti should give 10 out put and whern select sale order it should give 200 as output.
    -Anurag Jain

    Hi,
    Either you can use the hotspot_click event or double_click to show the Pop-up info of the Sales Order count or customer Count depending on the selection.
    In the hotspot_click event  method you have E_ROW_ID E_COLUMN_ID..using these you can find the Sales Ordert or customer Number.. Loop the internal table and find the Count.
    In the double_click event  method you have E_ROW E_COLUMN..using these you can find the Sales Ordert or customer Number.. Loop the internal table and find the Count.

  • How to find number of records roughly?

    Without SELECTing the table, how can we estimate the rows in a table or the size of the table . please help?
    Thanks,
    Ravikanth.

    Without SELECTing the table, how can we estimate the rows in a table or the size of the table .To answer the original question. Without using SELECT there is no way of getting the number of rows in the table. Estimate or otherwise.
    You could get the size of the table (in terms of how much space it takes up in the database) by using DBA_SEGMENTS. But without some metric for estimating the average row length that information is pretty useless. And of course you don't know how much of that allocation is free.
    Why do you want this information roughly, without accuracy?
    Cheers, APC

  • How to control number of records in batch insert by eclipselink

    Hi,
    We are using eclipselink(2.2) to persist objects and we use following configuration -
    <property name="eclipselink.jdbc.batch-writing" value="Oracle-JDBC" />
    <property name="eclipselink.jdbc.batch-writing.size" value="5" />
    however the number of records inserted is much more than 5( I have seen 5000 records being inserted ). How can we control the number of records inserted once?
    Thanks.

    Binding can be configured using the "eclipselink.jdbc.bind-parameters" property, and is on by default - it should be on for jdbc batch writing.
    Batch writing defaults to 100 statements, so I am not sure why it would include all statements in one batch unless it is not batching at all. If you set the logs to finest or all it should print of the values it is using for each property, and also show the SQL and statments it is executing. Can you turn on logging and post portions of the logs, particularly the part showing the transaction in question (though maybe only 6 lines of consecutive inserts).
    Logging is controlled through the "eclipselink.logging.level" properties.
    Best Regards,
    Chris

  • How to find number of records retrieved

    hi everyone,
    suppose you made tap canvas and 2 tab page one for dept table and one for emp table and you make non database text item in the emp tab page. i need when i press in row on dept page navigate to emp page and display the number of records retrieved in this text item
    any help i greatly appreciated
    thanks

    Hello,
    What happens if you create one text item (non database) with numeric datatype in the emp block and set the property No. of display records to 1.
    Then set the Calculation Mode to Summary.
    Then Set the Summary Function to Count.
    Then Choose the Summarized Block from list as EMP block and choose any column from the Summarized Items list.
    The run the form.
    -Ammad

  • Get row number of record in Interactive Report

    I am using an interactive report and want to be able to modify a field and if the value already exists in the database change it back to what it was originally. I am selecting data using the select statement below and I'm calling the javascript CheckExists function when the value changes. All this is working but I need to figure out how to get the row number so I can change the value back to what is in f03 in the same row. Does anyone know how to access the row number or know how I can do this?
    select apex_item.checkbox(1, RESOURCE_TYPE_ID, 'onchange="CheckUsed(this, this.value);"', ':') "Delete",
    apex_item.text(2, RESOURCE_TYPE, 20, 100, 'onchange="CheckExists(this, this.value);"' ) "RESOURCE_TYPE",
    RESOURCE_TYPE_ID,
    apex_item.text(3, RESOURCE_TYPE, 20, 100) "orig_resource_type"
    from resource_types
    order by RESOURCE_TYPE

    Scott,
    I was not able to find anything like using #ROWNUM# that would give me the current row number but I was able to get it if I looped through all the records until I found the record I was currently on. It is not really what I wanted to do but it works. I have included the code below.
    Thanks a lot for your help I appreciate it.
    Steve
    *** Interactive Report Select statement ***
    select apex_item.checkbox(1, RESOURCE_TYPE_ID, 'onchange="CheckUsed(this);"', ':') "Delete",
    apex_item.text(2, RESOURCE_TYPE, 20, 100, 'onchange="CheckExists(this);"' ) RESOURCE_TYPE,
    RESOURCE_TYPE_ID,
    apex_item.text(3, RESOURCE_TYPE, 20, 100) ORIG_RESOURCE_TYPE
    from resource_types
    order by RESOURCE_TYPE
    *** Javascript ***
    function CheckUsed (pResourceType)
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=ResourcesResourceTypeExists',0);
    get.add('TEMPORARY_ITEM', pResourceType.value);
    gReturn = get.get();
    if (gReturn > 0)
    alert('Resource records exist using the Resource Type; Unable to delete.');
    pResourceType.checked=false;
    function CheckExists (pResourceType)
    // Get the current row number.
    var lResourceTypeId = document.getElementsByName("f01");
    var lResourceType = document.getElementsByName("f02");
    var lOrigResourceType = document.getElementsByName("f03");
    var j;
    for (j = 0; j < lResourceType.length; j++)
    if (lResourceType[j].value == pResourceType.value)
    if (lResourceType[j].value != lOrigResourceType[j].value)
    break;
    } // if (lResourceType[j].value != lOrigResourceType[j].value)
    } // if (lResourceType[j].value == pResourceType.value)
    } // for (j = 0; j < lResourceType.length; j++)
    // Check if the Resource Type already exists.
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=ResourceTypeExists',0);
    get.add('TEMPORARY_ITEM', pResourceType.value);
    gReturn = get.get();
    if (gReturn > 0)
    // Reset the Resource Type to the original Resource Type.
    get.add('lResourceType[j]', lOrigResourceType[j].value);
    doSubmit('SUBMIT');
    else
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=UpdateResourceType',0);
    get.add('TEMPORARY_ITEM', pResourceType.value);
    get.add('TEMPORARY_ITEM_2', lResourceTypeId[j].value);
    gReturn = get.get();
    alert(gReturn );
    }

  • How to change number of records displayed in Web service: Query_view_data

    Hi experts
    I´m using webservice Query_view_data to fill a Xcelsius model with data.
    The Bex Query contains appr. 300 records but the webservice returns only 50 records. When I test it it says "displaying 50 of 312 records".
    When I tried ABAP FM RRW3_GET_QUERY_VIEW_DATA it gave all 312 records.
    Does anyone know how I can change this setting so that all 312 records are displayed in the webservice?
    Best Regards
    Kenneth

    Mani,
    I have changed the properties of the chart as you said and gave 4 decimal places. If my actual data value is 0.787989, i would expect it to result 0.7879 but the outcome is 0.7800. It is replacing the other two decimal places with 0's rather than the actual number. Is this a bug in OBIEE or am i doing anything wrong?? Is there any other way to do this. Please let e know...
    Thanks,
    vnk
    Edited by: user8708843 on Aug 18, 2010 8:03 AM

Maybe you are looking for

  • Dual boot with WinXp and Arch-Solved

    Hi friends, I was using windows boot loader to boot into arch instead of grub. I used this: dd if=/dev/hda7 of=arch.lnx bs=512 count=1 to get the first 512 bytes of the partition in which I installed arch and then added a line directing towards arch.

  • How do you alter the spell check on an iPad?

    I type my name or email and it always suggests something else. I want to add the new word so that it doesn't "correct" it again!

  • Bug in V. 2

    I moved the brightness to the right, then I deleted the history and the brightness still stayed to the right.

  • EPOS Java Number Rounding Problem

    I am developing a java EPOS system and am having a strange issue with number accuracy that doesnt make any sense to me. On a till system you have a user display of the form 0000000.00 When you type into this for example the number 7 then the number 8

  • Regarding Output in Two pages

    hi all,     I developed Check Printing Form. Output is coming but that is coming in second page. First Page is contain only one line. I was not defined next page also. But data is coming in next page. What will be the problem. Please suggest. Regards