How to Display Number of Rows Deleted/Inserted etc... in PL/SQL

In Oracle 10g PL/SQL, I have a delete statement in a stored procedure. It is not in a cursor. I want to see the number of rows I've deleted. I can use the dbms_output.put_line package. I should know this, but I don't have time to perfect the syntax. How would I get the number of rows that get deleted and display it via dbms_output.put_lline?

No time to google either I guess.
http://www.google.co.uk/search?q=number+of+rows+deleted+oracle&rls=com.microsoft:en-gb&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1&rlz=&redir_esc=&ei=Qi5qToGyGYqw8QOGzf3nAg
SQL> create table dt_del_ex(id number);
Table created.
SQL> set serveroutput on
SQL> BEGIN
  2
  3      INSERT INTO dt_del_ex VALUES(1);
  4
  5      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows inserted');
  6
  7      INSERT INTO dt_del_ex select rownum from dual connect by level <=10;
  8
  9      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows inserted');
10
11      UPDATE dt_del_ex SET id = id + 3 WHERE id >= 9;
12
13      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows updated');
14
15      DELETE FROM dt_del_ex WHERE id <= 10;
16
17      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows deleted');
18
19  END;
20  /
1 rows inserted
10 rows inserted
2 rows updated
9 rows deleted
PL/SQL procedure successfully completed.

Similar Messages

  • How to display number of rows as columns in a select statement? This is on

    How to display number of rows as columns in a select statement? This is on 10g R2.
    Thanks,
    R

    For the current (ie. row 1 of 100)
    row_number over (order by -pick_a_column_set) as rnfor the total number of columns returned in your query
    count(*) over() as total_count

  • How to restrict number of rows display using ig:gridView

    Hi
    All
    How to restrict number of rows display using <ig:gridView datasource="{mybean.mylist}">
    i am getting 10 rows using data_row . i wanna show only first 5 rows .
    pageSize ="5" will be ok . but it displays remaining rows in next page. but i want to display only first 5 rows . is there any attribute to restrict number of rows.
    thanks
    rambhapuri

    I have no idea which component you're talking about. If want to discuss here about a non-Sun JSF component, then please mention about the name, version and build in detail. You can also consider posting this question at the website/forum/mailinglist of the component manfacturer rather than here. At least I can tell you that the Sun JSF h:dataTable has the 'rows' attribute for that. I can also suggest you to just take a look in the TLD documentation of the component in question. There should be all possible attributes listed with a detailed explanation about the behaviour.

  • How display number of row in select statement

    How can I display number of row in select statement?
    Table
    data1 data2
    xxx ccd
    wss qwe
    qws uij
    I need get from SELECT statement:
    1 xxx ccd
    2 wss qwe
    3 qws uij

    user13734495 wrote:
    Thank you from answer.
    Statement
    select rownum rn, data1, data2 from table
    is good.
    And what have I do went I use
    select rownum rn, data1, data2 from table order by data1
    and I get
    3 qws uij
    2 wss qwe
    1 xxx ccd
    I need
    1 qws uij
    2 wss qwe
    3 xxx ccdhence the importance of describing the complete problem.
    select
      rownum,
      data1,
      data2
    from(
      select
        data1,
        data2
      from
        table
      order by
        data1)

  • How to increase number of rows display in ESS

    Hi All,
    how to increase number of rows display in ESS applications especially in Time approval inbox from standard display of 5 rows to say like 20 rows? is there a quick way to do it?
    Thanks all
    Murty

    Kalpesh,
    it is actually in web dynpro view, I have seen this setting and it doesnt give option for increasing default number of rows in web dynpro application. Table is dynamically constructed in web dynpro implementation and I have the hard time finding out., Any help is appreciated in these lines,
    Thanks
    Murty

  • How to calculate number of rows for perticular characterstic in SAP BI Bex

    Hi experts,
    Please let me know how to calculate  ' number of rows  ' for perticular characterstic in Bex query. 
    Thanks & Regards,
    Babu..

    Hello,
    You can try this
    Create a CKF and assign the vale 1 to it. Open the query and select Character where you want to display ' number of rows ', go to properties windows, select 'display', in the results row drop down box, select  'always display'.
    Thanks.
    With regards,
    Anand Kumar

  • How to get number of rows return in SELECT query

    i'm very new in java, i have a question:
    - How to get number of rows return in SELECT query?
    (i use SQL Server 2000 Driver for JDBC and everything are done, i only want to know problems above)
    Thanks.

    make the result set scroll insensitve, do rs.last(), get the row num, and call rs.beforeFirst(), then you can process the result set like you currently do.
             String sql = "select * from testing";
             PreparedStatement ps =
              con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
             ResultSet rs = ps.executeQuery();
             rs.last();
             System.out.println("Row count = " + rs.getRow());
             rs.beforeFirst();~Tim
    NOTE: Ugly, but does the trick.

  • How to count number of rows in table

    can I get number of row in table except Count(*) in pl/sql
    is there any other way

    Also posted and answered here
    how to count number of rows in table
    count(*) will be the fastest way. It is only slow if the table has a vast number of rows, in which case why do you need to know the tables has 73552436467721 rows and not 73552436467737 rows. It doesn't seem to be much use. Either that or you are counting them a lot, which again seems rather pointless.

  • Adobe Captivate how to display number of attempts in Drag Drop Interaction slide

    Adobe Captivate how to display number of attempts in Drag Drop Interaction slide
    i have set attempts to 3
    on each failure i want to show on slide how many attempts used
    and how many correct answers

    Hi Sreekanth,
    You understanding is correct.  But,it is not even necessary to show the correct sources on correct targets along with the feedback... the correct option numbers in  incorrect feedback will do.
    reg point number 3, if I revisit the slide, the feedback are still displayed. For example, in this case, I added a correct feedback, but when I revisit the slide, the feedback was still appearing. So I added this action "On Enter"  to "Hide" this success caption. So that is why i told specifically that none of the feed backs should be there when i revisit the slide.
    Sorry Srikanth - I am not familiar with the advanced actions or variables. I have just used some from referring the examples from net. that's all

  • How to find number of files in a folder using pl/sql

    please someone guide as to how to find number of files in a folder using pl/sql
    Regards

    The Java option works well.
    -- results table that will contain a file list result
    create global temporary table directory_list
            directory       varchar2(1000),
            filename        varchar2(1000)
    on commit preserve rows
    -- allowing public access to this temp table
    grant select, update, insert, delete on directory_list to public;
    create or replace public synonym directory_list for directory_list;
    -- creating the java proc that does the file listing
    create or replace and compile java source named "ListFiles" as
    import java.io.*;
    import java.sql.*;
    public class ListFiles
            public static void getList(String directory, String filter)
            throws SQLException
                    File path = new File( directory );
                    final String ExpressionFilter =  filter;
                    FilenameFilter fileFilter = new FilenameFilter() {
                            public boolean accept(File dir, String name) {
                                    if(name.equalsIgnoreCase(ExpressionFilter))
                                            return true;
                                    if(name.matches("." + ExpressionFilter))
                                            return true;
                                    return false;
                    String[] list = path.list(fileFilter);
                    String element;
                    for(int i = 0; i < list.length; i++)
                            element = list;
    #sql {
    insert
    into directory_list
    ( directory, filename )
    values
    ( :directory, :element )
    -- creating the PL/SQL wrapper for the java proc
    create or replace procedure ListFiles( cDirectory in varchar2, cFilter in varchar2 )
    as language java
    name 'ListFiles.getList( java.lang.String, java.lang.String )';
    -- punching a hole in the Java VM that allows access to the server's file
    -- systems from inside the Oracle JVM (these also allows executing command
    -- line and external programs)
    -- NOTE: this hole MUST be secured using proper Oracle security (e.g. AUTHID
    -- DEFINER PL/SQL code that is trusted)
    declare
    SCHEMA varchar2(30) := USER;
    begin
    dbms_java.grant_permission(
    SCHEMA,
    'SYS:java.io.FilePermission',
    '<<ALL FILES>>',
    'execute, read, write, delete'
    dbms_java.grant_permission(
    SCHEMA,
    'SYS:java.lang.RuntimePermission',
    'writeFileDescriptor',
    dbms_java.grant_permission(
    SCHEMA,
    'SYS:java.lang.RuntimePermission',
    'readFileDescriptor',
    commit;
    end;
    To use:
    SQL> exec ListFiles('/tmp', '*.log' );
    PL/SQL procedure successfully completed.
    SQL> select * from directory_list;
    DIRECTORY FILENAME
    /tmp X11_newfonts.log
    /tmp ipv6agt.crashlog
    /tmp dtappint.log
    /tmp Core.sd-log
    /tmp core_intg.sd-log
    /tmp da.sd-log
    /tmp dhcpclient.log
    /tmp oracle8.sd-log
    /tmp cc.sd-log
    /tmp oms.log
    /tmp OmniBack.sd-log
    /tmp DPISInstall.sd-log
    12 rows selected.
    SQL>

  • ExecuteNonQuery doesnt return number of rows affected when used with PL/SQL

    ExecuteNonQuery doesn't return number of rows affected when used with PL/SQL but returns -1. The documentation says ExecuteNonQuery method of OracleCommand returns the number of raws affected but when used with PL/SQL, it returns -1 even the update statement successfully executes and affects multiple records with no exeptions thrown.
    However, if ExecuteNonQuery is used with update sql statement in the asp.net code it returns number of rows affected correctly. Does anybody know why ExecuteNonQuery behaves like this?
    I am using ODP.NET that comes with Oracle Client 11g. The version is 2.111.6.20 of ODP.NET, Oracle database server is 10g.
    Marat

    You can get the rowcount in the stored procedure via SQL%ROWCOUNT and then pass it out as a parameter.
    For example:
    SQL> create or replace procedure updatesal(v_deptno in number, v_rowsaff out number) as
      2  begin
      3  update emp set sal = sal * 5 where deptno = v_deptno;
      4  v_rowsaff := SQL%ROWCOUNT;
      5  end;
      6  /
    Procedure created.Cheers

  • How to display the result of  excutions(insert/update/delete rows)

    Hello.
    Does anyone know how to display the result of scenario executions just like a scenario executions tab of package (insert/update/delete rows) in other screen (in the intergated operating platform for operators using http)
    In additional, I also like to show the hierarchy of scenario in the same view.
    So, I need the query using the information of the ODI repository.
    If it is possible, I also like to have the decription of the tables in the ODI repository.
    Can anyone tell me how can I get the information of the counts of excution?
    Thanks in advance.

    Hi,
    You can get that information from the API getPrevStepLog. Does it work for you?
    Download the last API reference manual from:
    http://www.oracle.com/technology/products/oracle-data-integrator/10.1.3/htdocs/1013_support.html#docs

  • How to control number of rows displayed in a report  by user?

    Hi All!
    I have provided a select list called 'Number of rows' in my report page.User can choose any number in the list, and accordingly he should be able to see so many number of rows in that report page.
    For example: if user selects 50 from the list, he will be able to see 50 records at a time out of say 2000 records retrieved. I want to control number of rows displayed per page dynamically. And if he selects 25 in the select list, he should be able to see 25 records at a time out of 2000.
    How to do it? Please give me ideas.
    Thanking in advance.
    Regards,
    Deepika.

    Hi Deepika,
    If you have a Select List with Submit called, say "P1_ROWS", you just enter P1_ROWS into the Report Attribute's "Number of Rows (Item)" setting.
    Regards
    Andy

  • How to increase number of rows displayed in Essbase drill-through report?

    Hi
    By default, the maximum number of rows per Essbase drill-through report (via Integration Services) is set to 1000. Could anyone tell me how to change this limit please?
    Regards
    Chandra

    Is this for an EIS drill through report that drills through to get RDBMS data, using spreadsheet add-in for example? If so check and see if "Maximum rows per query" in EIS is currently set at 1000 and try to increase it. (I don't recall hitting a 1000 limit in the past, perhaps your report is set at that? or if this is through Web Analysis maybe WA is governing it)
    To set/change a query governor in EIS:
    1     In the Drill-Through Reports dialog box, select a report name.
    2     Click Edit to open the Report properties dialog box.
    3     In the Report properties dialog box, select the Governors tab.
    4     In the Maximum time per query (in seconds) text box, enter the maximum query time.
    For example, to stop a query that takes longer than 100 seconds, type 100.
    5     In the Maximum rows per query text box, enter the maximum number of rows to retrieve.
    For example, to stop a query that retrieves more than 200 rows, type 200.
    6     Click OK.

  • How to restrict number of rows returned in a query

    Hi frnds,
    I'd like to restrict number of rows returned by my query to some 10 rows. how to do that.When I try doing with the rownum<10 its giving results for a particular dept and that too some 6 rows only...btw I'm grouping my table and includes joins from many a table and am ordering the table results by a column.. How to do this..

    776317 wrote:
    Hi frnds,
    I'd like to restrict number of rows returned by my query to some 10 rows. how to do that.When I try doing with the rownum<10 its giving results for a particular dept and that too some 6 rows only...btw I'm grouping my table and includes joins from many a table and am ordering the table results by a column.. How to do this..
    TELL ME HOW MANY ROWS YOU HAVE IN TABLE?
    Because you have only *6 rows* in you column, if you less than 10 rows then it displays only containied/exist rows. nothing much
    select ename,empno from emp where rownum < 10;Thanks

Maybe you are looking for