How to count the number of Rows to be Updated before Update takes place..

Hi all,
I have a requirement, where i have to count the number of rows to be updated before updating it. SQL%ROWCOUNT gives the no. of rows updated ( after update takes place). How do i get to know the count of no. of rows to be updated/inserted/ deleted. I was looking for a simple solution, as above SQL%Rowcount. But i couldn't find any. I can use a Function and Return the value which will give me number of rows to be updated, But is there any Simple Logic other than this.. or any count function. Your Help is Appreciated. Thanks!

If you really want to do this (I have no clue why you would need it), then you can piggy back on any existing pessimistic locking you may already have in place.
However, it would require two loops through the records of which you want to know the count before you update, and a second pass to update them.
I would really re-think the need for this, though.
SQL> create table t0304(c number);
Table created.
SQL> insert into t0304 select rownum from all_objects where rownum <= 10;
10 rows created.
SQL> commit;
Commit complete.
SQL> select * from t0304;
         C
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
10 rows selected.
SQL> declare
  2    cursor mycursor is select * from t0304 where mod(c,2) = 0 for update;
  3    i number := 0;
  4  begin
  5    for r in mycursor loop
  6      i := i + 1;
  7    end loop;
  8    dbms_output.put_line(i);
  9    for r in mycursor loop
10      update t0304 set c = c + 20 where current of mycursor;
11    end loop;
12  end;
13  /
5
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
SQL> select * from t0304;
         C
         1
        22
         3
        24
         5
        26
         7
        28
         9
        30
10 rows selected.
SQL>Edited by: Steve Howard on Mar 4, 2011 5:57 PM

Similar Messages

  • How to count the number of rows in a resultser object?

    hi there
    how to count the number of rows in a resultser object which may contains millions of rows? besides using a while loop? thanks

    You don't, you execute a query whose result is the record count of those records that match the search and then you execute the actual query to create your record set. Typically you do
    select count(id) from YourTable where [filter]
    from the resulting ResultSet do
    int res.getInt(1);
    which gives you the count and then
    select id from YourTable where [filter]
    to produce the actual result set.
    in the second query the id part can be substituted with the actual fields you want.

  • How to count the number of rows in a cube!!??

    Experts,
    I can somebody tell me how do I count the number of rows in my cube when i am using listcube???..
    Thanks
    Ashwin

    Hi,
    have a look ath this theard too
    Number of Records in Cube
    regards

  • How to count the number or rows in file

    Hi Experts,
    I am file as source and Oracle as target. My file containing the some data which is going to load to the target.
    My requirement is that I want to count the number of rows which my file contains. Please help me how to count the total number of rows in file.
    Thx,
    Sahadeva.

    Hi,
    You won't give a name DEST_USER_NAME:ODI will get these information.
    it is important  Command on source and Command on Source side .
    -Pls write jython code on Command on Source side
    -And Command On Target side Choose technology as Oracle and set logical schema to HR_logical
    Sorry my mistake.İt is related jython syntax.Here is code:
    import java.lang as lang
    import java.sql as sql
    import java.lang.String
    import os
    lang.Class.forName("<%=snpRef.getInfo("DEST_JAVA_DRIVER")%>")
    cons=sql.DriverManager.getConnection("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")
    dblinks= cons.createStatement()
    file1=open('EMP.txt','r')
    count=0
    line=file1.readline()
    while line !='':
         count+=1
         line=file1.readline()
    file1.close()
    sqlQuery = "insert into HR.ETL_FILE_LOG (FILE_COUNT) values (count)"
    rqQuery= dblinks.execute(sqlDBLink)
    cons.close()
    Regards

  • How to count the number of rows............

    Hi,
    For the different log on dates for user , I want to calculate the number of times user has logged on i.e. count for (0calmonth) in the report .
    Is this possible ?
    Please let me know.
    Thanks & Regards,
    Jeetu

    HI Jeetu,
            Check this doc................
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/009819ab-c96e-2910-bbb2-c85f7bdec04a
    Regards,
    Vijay.

  • How to count the number of deleted rows processed

    Sybase ASE version: 15.7-SP52
    Hi all,
    I have a delete statement that will potentially delete millions of rows
    DELETE from TAB_A where COL_A='Y'
    The delete is long, at some point I'd like to know how many rows were deleted.
    If I do SELECT COUNT(*) from TAB_A where COL_A='Y', the query should be locked because of the exclusive-lock held by the DELETE in progress.
    If this is the case, how can I actually count the number of rows deleted so far?
    Thanks all
    Simon

    Simon
    For  deleting significant number of rows best practice is to delete rows in small batches of known size (e.g. 10 K) inside a while loop. 
    This keeps transaction log from filling up as well.
    Also between two iterations of delete you can give some wait to make sure that you do not monopolize the server. Sleep could be for a fixed number of seconds (e.g. 5) or for randomized number say from 1 to whatever makes sense.
    Typically "set rowcount " is used to set up the batch size and "waitfor delay" to sleep between iterations.
    Global variable @@rowcount gives yo actual rows deleted. For the last batch this may be lower than the batch size you set up.
    HTH
    Avinash

  • How to determine the number of rows of data in a datatable?

    I have a datatable that I fill from an SQL query.  I do not know exactly how many rows of data it will return (due to my selection criteria) but will be somewhere between 100 and 300 rows.  I send this data into a report but need to determine the length of the report (panel height data member) programatically based on how much data the query has returned.  So, I need a way to count how many rows are filled in the data table.
    I tried doing a nested "if" statement checking the value of each cell but when I tested the expression at 59 "if" statements (will need 300+) I got a parser error in lookout when I tried to accept the connection.  I also tried a type of loop by assigning cursor.2 either to its own value (circular) or to its own value plus one depending on the value of the cell at cursor.2.  It was close but overshot by one row or more (much more sometimes).
    Any clever ideas?  Perhaps I have just been looking at this problem too long.  Thanks, in advance, for your help.

    Since the datatable gets the data from the SQL query, you can also use the SQL statement to count the number of rows in the query result.  
    For example, in datatable you do "select localtime, trace1 from intdata where xxx". You can get the count by "select count(trace1) from intdata where xxx". Use the same condition in order to get the same number of rows.
    Maybe another SQLExec object is needed to do the count.
    Whenever the datatable executes the SQL, the SQLExec executes and return the count.
    Ryan Shi
    National Instruments

  • How to increase the number of rows in Status Oveview iView in MSS?

    Hi
    We have implemented MSS and have a question regarding Status overview iview.
    The standard status overview iview of the team workset has 5 rows and we have to scroll using the arrow buttons to select/view a request.
    Now can anyone explain me how to increase the number of rows in this iview? Is this somthing that has to be accoplished through web dynpro customization?
    I checked the options in iView property and do not see any option to increase the number of rows.
    please help
    Thanks
    -Michael

    Hi Micheal,
    Well, I am not really sure, if you could accomplish this using customizing, but I am sure that you can accomplish this using the JDI. Well, you can extract the application's source code using JDI and then change the required display rows property and republish it.
    Am not really sure if this is suggestable method for this requirement,but it can be achieved using this JDI stuff.
    Regards
    <b>Raja Sekhar</b><i></i>

  • How to increase the number of rows to be displayed in BEx Web Analyzer

    hi,
    I am viewing reports using BEx Web analyzer option. It is displaying only 24 rows  of data at a time. How to increase the number of rows? do i need to any kind of settings?
    pls reply.

    Hi,
    I think the standard template in 2004s is named 0ANALYSIS_PATTERN. You can find it in Web Application Designer, open, and search for the technical name. If you want to change the number of rows or columns, you can find this setting near the bottom of the XHTML view of the template:
    <bi:BLOCK_COLUMNS_SIZE value="4" />
    <bi:BLOCK_ROWS_SIZE value="17" />
    Then just save, and ignore the error messages.
    Message was edited by:
            vind Reinsberg

  • How to limit the number of rows in a smart form , sap script.

    Can anyone tell me how to limit the number of rows in the output of a sap script/smart form. I have tried "protect/endprotect" in sap script but have no idea of how to do in smart form. In sap script the only way it has happened is by reducing the size of the main window.

    Hi,
    In Smartform also, why dont you try reducing the size of the window if you want to limit the rows in it. Also if you are printing Line Items in a LOOP, you can write
    LOOP AT T_ITAB FROM 1 TO N in the LOOP Node if you know how many records exactly you want to display in 1 Page processing.
    regards,
    Mahesh

  • Count the Number of Rows in Data form

    Hi,
    I want to count the number of rows in a data form.In my form there is a large number of rows.Is there any way to count it.
    Thanks.

    If you are on 11.1.2.x then you could look at adding a formula and using the CountA function - http://download.oracle.com/docs/cd/E17236_01/epm.1112/hp_admin/apcs03s06.html
    Otherwise it would be possible using custom javascript which you would have to had some experience in using.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Count the number of rows in a workbook.

    Hi Experts , I have a requirement to count the number of rows in a WorkBook.Will it be possible to do this by creating a KeyFigure?Or are there any options in BEx to count and display the number of Rows.Many thanks for all your help.

    Hi
    In the query create a calculated key figure called 'Count' and put a formula as =1, then use this count where ever applicable..you can very well count the no. of rec.
    with this.
    Hope this helps..
    assign points if useful..
    Cheers,
    Pattan.

  • How to count the number of lines dynamically,

    In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
    after displaying one category contents am displaying a line
    which also counts to a line in the internal table.
    My question is how to count the number of lines(ULINE) displayed dynamically.
    FORM GET_LINES .
      DATA: LV_LINES TYPE I,
            LV_TIMES TYPE I,
            LV_TABIX TYPE SY-TABIX.
      DESCRIBE TABLE IT_REC LINES LV_LINES.
      DO LV_LINES TIMES.
        LV_TIMES = SY-INDEX .
        READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
        IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
          LV_TABIX =  LV_TIMES.
          READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
          IF SY-SUBRC EQ 0.
            APPEND GWA_UPDATE TO GT_UPDATE.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    " GET_LINES

    In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
    after displaying one category contents am displaying a line
    which also counts to a line in the internal table.
    My question is how to count the number of lines(ULINE) displayed dynamically.
    FORM GET_LINES .
      DATA: LV_LINES TYPE I,
            LV_TIMES TYPE I,
            LV_TABIX TYPE SY-TABIX.
      DESCRIBE TABLE IT_REC LINES LV_LINES.
      DO LV_LINES TIMES.
        LV_TIMES = SY-INDEX .
        READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
        IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
          LV_TABIX =  LV_TIMES.
          READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
          IF SY-SUBRC EQ 0.
            APPEND GWA_UPDATE TO GT_UPDATE.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    " GET_LINES
    The display function is:
    FORM DISPLAY_DATA .
      ULINE.
      WRITE :  /1 SY-VLINE, 'check',
                10 SY-VLINE, 'Plant',
               20 SY-VLINE, 'Material number',
               50 SY-VLINE, 'Follow up material',
               70 SY-VLINE, 'Safety stock',
              100 SY-VLINE, 'Partc'.
      ULINE.
      LOOP AT IT_MARC.
        MOVE: IT_MARC-WERKS TO IT_REC-WERKS,
              IT_MARC-MATNR TO IT_REC-MATNR,
              IT_MARC-NFMAT TO IT_REC-NFMAT,
              IT_MARC-EISBE TO IT_REC-EISBE,
              IT_MARC-PARTC TO IT_REC-PARTC .
        APPEND IT_REC.
        CLEAR IT_MARC.
      ENDLOOP.
      DATA: GV_TABIX TYPE SY-TABIX.
      LOOP AT IT_REC.
        GV_TABIX = SY-TABIX.
        READ TABLE GT_TOTAL WITH KEY WERKS = IT_REC-WERKS
                                     NFMAT = IT_REC-NFMAT.
        IF SY-SUBRC EQ 0.
          IT_REC-PARTC = GT_TOTAL-PARTC.
          MODIFY IT_REC INDEX GV_TABIX TRANSPORTING PARTC.
        ENDIF.
      ENDLOOP.
      LOOP AT IT_REC.
        WRITE : /1 SY-VLINE, IT_REC-CHECK AS CHECKBOX,
                10 SY-VLINE, IT_REC-WERKS,
                20 SY-VLINE, IT_REC-MATNR,
                50 SY-VLINE, IT_REC-NFMAT,
                70 SY-VLINE, IT_REC-EISBE,
               100 SY-VLINE, IT_REC-PARTC.
        AT END OF NFMAT.
          ULINE.
        ENDAT.
      ENDLOOP.
      ULINE.
    ENDFORM.                    " DISPLAY_DATA
    Solved

  • Want to count the number of rows of analysis item in WAD Template

    HI all,
    Detail Description:
    In my WAD report, i have a Export to Excel Option. But I want when I click on this button, one pop up will come only if no of rows of the Analysis Item is Greater than 10,000 ask for Do you want to proceed or not.
    Means 1st i want to count the no of rows in the Analysis Item, after that it will check, if the no of rows is greater that 10,000. then the pop up will come.
    Question:
    Does anyone know, "how to count the no of rows of the analysis Item ?" . It will be better if you know you to implement this with the help of java script.
    Means there must be some varible, which counts the no of rows. If you know then please help me

    Hi,
    Please find the below link which helps you to get solution of your question.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0bbb20f-2d7e-2e10-258f-8655daa41fab?QuickLink=index&overridelayout=true
    It is mainly used to automate queries, web templates, and reports in different output formats like PDF, Excel,
    XML, XHTML, and HTML
    How to see WAD reports on browser:
    The BEx Web Application Designer is a desktop application for creating Web applications with BW-specific contents. Using the BEx Web Application Designer, you can create an HTML page that contains contents such as various tables, charts or maps. This HTML page (Web application) provides the basis for not only Web applications with complex interaction, but also for Web cockpits and iViews.
    http://help.sap.com/saphelp_nw04/helpdata/en/1a/456a3badc1b315e10000000a114084/content.htm
    Web Application Designer for Beginners
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/749a4622-0a01-0010-36bf-b6b30a2a3a22
    Web Application Solutions: A Designer's Guide
    http://www.lukew.com/resources/webapplicationsolutions.pdf
    http://sap.ittoolbox.com/groups/technical-functional/sap-solution-manager/bw-web-application-designer-1955944
    Feautures of WAD in 7.0
    http://help.sap.com/saphelp_nw70/helpdata/en/88/4d354277dcb26be10000000a155106/frameset.htm
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5c46376d-0601-0010-83bf-c4f5f140e3d6
    Regards
    Sudheer

  • Count the number of rows resulting from a select statement

    Hi,
    Is there any way of counting the number of rows resulting from a select statement. i.e I have a select distinct statement and I then want to perform an IF statement on the number of rows resulting from the select statement.
    Any help appreciated
    Thanks
    Gary

    Declare
    var1 number;
    Begin
    select count(distinct column_name) into
    var1 from table_name;
    If var1 > x Then
    End IF;
    End;
    Hope I understood the problem correctly
    null

Maybe you are looking for

  • Genius not updating - stuck on 'Delivering your Genius results...'

    iTunes has stopped updating my Genius results on my PC, both automatically and manually, for the last few weeks now. This has never been a problem in the past. Not sure if it coincides with the latest iTunes update (12.0.1) or my new router from my n

  • Black border around my mouse pointer

    Since a few days, I have a thick black border around my mouse pointer, always following the movement of the pointer. How can I bring this away? Thanks for help Ueli

  • ITunes12 won't recognize iPhone 5s nor iPad 1

    OSX 10.7.5 on an old Mac Pro (late 2006) iTunes 12.01.26 iPhone 5s running iOS 7.1.2 iPad 1 running iOS 5 iTunes will not recognize the iPhone nor iPad; neither shows up as a device.  There is no "device" button in the iTunes window and the pull down

  • What GOOD or NEW things have you noticed after the update?

    What good things have you noticed since the update that were not mentioned in the update video? One or two of these may have been already there, I might just be taking a closer look. Faster screen switching in Phone mode Ability to specify ports in e

  • My apple tv will not sign onto my apple account.

    My apple tv will not log into my apple account. It says that my apple account doesn't exist or my password was incorrect. I have tried to reset the apple Tv and replugged it into the tv but it still didn't work...I reset my password to my apple accou