to check the number of rows affected by an update query in a procedure

Hello
I want to check the number of rows affected by the update script that I used in a procedure and I shoud be able to use this count towards the end of the procedure.
How can I do?

for example:
create or replace procedure p1 is
Start
Update table1 set x = 'a', where y = 'b ';.
end p1;

Published by: christele CS on May 1, 2012 22:06

Hello

Try the below a...

create or replace procedure p1 is
Start
Update table1 set x = 'a', where y = 'b ';.
dbms_output.put_line (SQL % ROWCOUNT |) ("Lines updated ');
end p1;

Tags: Database

Similar Questions

  • See the number of rows affected the performance of sqlplus to a sql file

    Hello

    It's just we have a sql file that contains a bunch of select/update/insert statements.

    I have a unix script that calls sqlplus on this sql file. However, at the exit I don't get the number of rows affected.

    Without adding any code in the input sql file, how can I change the code of sqlplus shell script to print the number of rows affected for each statement in the sql file?

    ${ORACLE_HOME}/bin/sqlplus -L >> ${LOG_FILE} 2>&1  << EOF
      ${ORAID}/${ORAPASS}@${ORAINS}
      whenever sqlerror exit sql.sqlcode;
      set echo on;
      set feedback off;
      set serveroutput on;
      @${SQL_FILE};
      exit;
    EOF
    RC=$?
    

    The SQL_FILE of entry content is:

    select 12 "col1" from dual;
    select 'abcd' "col2" from dual;
    select;
    select 13 'col3' from dual;
    

    The result of the race of sqlplus is (LOG_FILE):

    SQL*Plus: Release 11.2.0.2.0 Production on Fri Jun 6 14:28:00 2014
    
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    
    Enter user-name: 
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
    Data Mining and Real Application Testing options
    
    SQL> SQL> SQL> SQL> SQL> SQL> select 12 "col1" from dual;
    
          col1
    ----------
            12
    SQL> select 'abcd' "col2" from dual;
    
    col2
    ----
    abcd
    SQL> select;
    select
         *
    ERROR at line 1:
    ORA-00936: missing expression
    
    
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
    Data Mining and Real Application Testing options
    

    Thank you

    Srinivas - y.

    1. echo setting
    2. Set feedback off;

    use

    Set of feedback on

  • get the number of rows affected by their table top

    Hello, I need to count the number of rows updated in table form. In the process of ApplyMRU, I can use the string substitution #MRU_COUNT # to show the lines updated in a success message, but I need to get this value and store it on a table. Any help would be much appreciated. Thank you.

    oscarjavier99 wrote:

    Hello, I need to count the number of rows updated in table form. In the process of ApplyMRU, I can use the string substitution #MRU_COUNT # to show the lines updated in a success message, but I need to get this value and store it on a table. Any help would be much appreciated. Thank you.

    For that you would benefit from the APEX$ ROW_STATUS integrated substitution string.

    1. create a page element display only (in my case P15_UPDATED_ROWS) Save Session State set to Yes and the Type of Condition is set to never.

    2. Add a calculation after the shows with a Type of static assignment and calculation value 0 to reset the counter whenever the page is sent.

    3. Add an On submit - after calculations and Validations process of PL/SQL page linked to your tabular presentation with a Status of Type PL/SQL Expression and Expression 1 :apex$row_status = 'U' and the code of the following process :

    :p15_updated_rows := :p15_updated_rows + 1;
    

    If you don't actually means "day" in the strict sense, and then change the status of process to include possible APEX$ ROW_STATUS 'C', 'U', and "D" values as needed. If you want to count all created, updated and deleted lines, do not add the condition to the process, but make sure the extended run is set to createand changed lines.

  • Get number of rows affected in SQLPLUS...

    Hello world
    I have a shell script where I am invoking sqlplus, running a query and save the result in a hold file in .csv format. This file now has a trailer container
    number of selected rows. So, I can not use SQL % ROWCOUNT and I don't know how to get this number.
    Someone gave me an idea of the number of lines of wc file and add it as a trailer, but I can't do it like in the conduct of the trailer I need to display a number that is an oracle
    sequence. The file format will be something like this-

    01, testing, 5667889, 9999999, AXCCRTR1
    000001, TESTSOURCE, 1--> it's the trailer (oracle_seq, constant varchar, not of selected lines)

    Is there a way I can get the number of rows affected by the last query in sqlplus. Any help will greatly be appricaited.
    I can go ahead and do it with Pl/sql, but I'm not leaving until I'm absolutely sure thery no way on this.

    Thank you
    ru

    Add a hidden column rownum to your query and save its last value:

    SQL>set feedback off
    SQL>column rownum new_value num_rows noprint
    SQL>select rownum, object_name, object_type from all_objects where rownum < 7;
    
    OBJECT_NAME                    OBJECT_TYPE
    ------------------------------ ------------------
    /1005bd30_LnkdConstant         JAVA CLASS
    /10076b23_OraCustomDatumClosur JAVA CLASS
    /10297c91_SAXAttrList          JAVA CLASS
    /103a2e73_DefaultEditorKitEndP JAVA CLASS
    /1048734f_DefaultFolder        JAVA CLASS
    /10501902_BasicFileChooserUINe JAVA CLASS
    SQL>prompt &num_rows
    6
    

    HTH, Urs

  • Text box layout problem - and the number of rows displayed

    Hello

    Wonder if you can help with my 2 problems

    1. when I create text boxes, the label is displayed to the left of the text box. How can I display label above the text box
    CGH

    Label
    TextBox

    Instead of

    Text box label

    2. when I ask report showing my data, that it shows that 15 records per page, for the next set of records, I need to click on the following icon at the bottom of the table to go to the next page.
    How can I view all on the same page?

    Thanks for help

    1. simply check this using the Horizontal / Vertical alignment of attribute in the section of the label of the element of the Page definition.

    2. in the report of the attributes, the value of the plan of paging None; and the number of rows and number of maximum lines to more than the number of rows that will be returned by the report query.

    (You should only ignore this last you really know that the number of lines make this a reasonable option.) Nobody is going to want to scroll through thousands of lines or wait 5 minutes for total information overload. You wouldn't be popular with your admins/ISP network due to the excessive bandwidth consumed either.)

  • How to determine the number of rows in the database and save the result to a local variable?

    Hello

    I'm a newbie in the use of TestStand, databases and SQL, and now I've met difficulties. I use TestStand 2014 (32 bit).

    I have a need to know the number of rows in a database and save that number in a local variable. I tried to practice using the database of the Types of step provided with TS. I tried to use the following in a SQL statement:

    Locals.NumberOfRows = ("SELECT COUNT (*) FROM TEST_TABLE")

    It returns an error: specified value is not the expected type. My goal is possible in this way, or I'm doing this completely wrong?

    -RautSa

    Thank you for your response, Norbert. I have a database of who wins new values at random, and sometimes I need the exact number of rows in this table.

    I managed to achieve my goal by using the SQL statement: "SELECT COUNT (*) as Rowcount OF TEST_TABLE", followed by a data GET operation, which records that number of lines in a local variable.

    -RautSa

  • How to check the number of items available in RT FIFO?

    Hello

    Is there a way to check the number of items in RT FIFO without using READ FIFO function? I'm looking for a function like the function of status get queue VI.

    Thank you very much!

    Kind regards

    Tom

    See this KB article

    http://digital.NI.com/public.nsf/allkb/42E85A333767918B862570D800667FD8?OpenDocument

  • Count the number of rows in a table (s)

    Hi all

    I have a TKT_PRIORITY_LK table that I want to count the number of rows returned by a priority level... say Low, Medium, High, critical. I want to be able to count how many of each created are they, instead returning ID instead, if making any sense... Can you please help with this.

    Example; Select count (*) in TKT_PRIORITY_LK

    PRIORITY group

    Kind regards

    Sandrine

    Try this

    Select a.PRIORITY, count (*) from TKT_PRIORITY_LK a, TKT_TICKET_MAIN b

    where a.id = b.PRIORITY_ID

    A.PRIORITY group

  • How to check the number of lines inserted since the week last in the table

    Hello

    Oracle version: 11g

    OS: Linux

    We need to know the number of rows inserted for a table of 7 days, please can anyone suggest is all views to find that answer

    BR

    PMP

    The function dbms_stats.diff_table_stats_in_history should give you what you need, assuming you analyze the table regularly.

  • How can I check the number of pixels in my image of the camera? [was: Pixels]

    How can I check the number of pixels in my image of the camera?

    Open a file

    Select > all

    Choose the histogram and click in the upper right

    Choose expanded view

    The number of pixels note

  • How can I get the number of rows in the table using Sunopsis API target in ODI 10 g?

    Hi guys,.

    In fact, I want to send an alert message as soon as the interface is run from a package. I've included alert OdiSendMail that sends an email once the interface is running.

    Could someone please tell how to get the number of rows inserted into the table the Sunopsis API target.

    I tried to use < % = odiRef.getNbRows () % >, but this has not worked for me. Since I am a beginner, could you please help out me

    This is my mail to send ODI format

    "The population of data managed to < % = odiRef.getSysDate () % >

    Total of lines in the target table is: < - need an API code-> "


    Kind regards

    Clinton

    Published by: LawrenceClinton on February 25, 2013 20:53

    Hello

    Create the project with details below variable

    Nom_de_variable: Total_Row_Count

    Type of variable: Variable discount

    Definition tab:
    Data type: digital
    Action: No persistent

    Refresh the tab:
    Schema: provide the schema of your repository to work and be

    SELECT log.nb_row
    THE journal of snp_step_log, snp_scen_step step
    WHERE log.nno = step.nno
    AND step.scen_no = (SELECT scen_no FROM snp_scen_step WHERE step_name='<%=odiRef.getPrevStepLog ('STEP_NAME") % > ')
    AND log.sess_no = '< % = odiRef.getSession ("SESS_NO") % >' code at low
    AND step.step_name = ' < % = odiRef.getPrevStepLog ("STEP_NAME") % > '

    Note: add this variable after the stage of interface in your package (after the interface anywhere you can place), you can add this variable before ODISendEmailNotification in your package

    call this varciable * #Total_Row_Count * in the Notification of ODISendEmail

    for example :

    Data has been fulfilled successfully in < % = odiRef.getSysDate () % >
    Total no of lines filled are: * #Total_Row_Count *

    it will work

    cordially,
    Phanikanth

    edited by: Phanikanth on February 28, 2013 01:13

    edited by: Phanikanth on February 28, 2013 01:14

  • Displays the number of rows in the table displaying a named criteria query data

    I created a test named for my View, called 'Criteria1' and Criteria1 to create a group of ADF with Table query. I want to display the number of rows in result when a search is performed. How can I do?

    Thanks in advance,
    Tom

    As mentioned, you can add outputText and you must give OutputText partialTriggers as query component your Id. Thus, when you give a search on the query component, it will refresh the outputText with the number of lines.


    ID = "ot1" partialTriggers = "id of the component of motion here" / > ""

  • Check the number of continuous Page in the Document

    Hi all

    It is possble to check the number of continuous page in the active document.

    Problem is due to the use of several "number and Sections options" in the control panel pages F12.

    No error: alert ("Pass")

    If an error in the sequence of folio: alert ("Fail")

    Could someone please help for my application.

    Currently replace all elements of the master page by using the following script

    main();
     function main() {
        var doc = app.activeDocument,
            i, l, page, j;
            
        for (i = 0; i<  doc.pages.length; ++) {
            page = doc.pages[i];
            if (page.appliedMaster !== null) {
                for (j = 0; j< page.appliedMaster.pageItems.length; j++) {
                    try {
                        page.appliedMaster.pageItems[j].override(page);
                    } catch(e) {}
                }
            }
            page.pageItems.everyItem().detach();    
        }
    }
    
    

    Thanks in advance

    Beginner_X

    Check the code below

    main();

    main() {} function

    var doc = app.activeDocument,

    i, l, page, j;

    pageNumber = 0;

    for (i = 0; i<  doc.pages.length;="" i++)="">

    page = doc.pages [i];

    pageNumber ++

    Alert (page.name)

    If {(page.name is pageNumber)

    Alert ('pass')

    }

    else {}

    page.name = pageNumber

    Alert ("fail")

    }

    }

    }

  • Get the number of rows in the oracle table

    Hi all
    I want to get the total number of rows in the sql to the appmodule table.
    After you apply the criteria to view some on the view object. If he try with getallrowsinrange the number of rows found within the viewobject was but I want a total number of rows in the sql table.

    How can I get that

    I use jdev 11.1.1.5

    Thanks in advance

    I threw something together, quick and dirty, don't hesitate to optimize.

    Assuming you want the County table, I put the code in a subclass of EntityDefImpl since it is representing a table in the middle tier.

    public class EmpDefImpl
          extends EntityDefImpl {
      /**
       * This is the default constructor (do not remove).
       */
      public EmpDefImpl( ) {}
    
      //~ Methods ****************************************************************************
    
      public long getTableRowCount( DBTransaction transaction ) {
        String query = getQuery( );
        String countQuery = String.format( "SELECT COUNT(*) FROM (%s)", query );
        long count = 0;
    
        ViewObject vo = transaction.createViewObjectFromQueryStmt( countQuery );
    
        try {
          vo.executeQuery( );
    
          Row row = vo.first( );
          Number number = (Number)row.getAttribute( 0 );
          count = number.longValue( );
        } finally {
          vo.remove( );
        }
    
        return count;
      }
    }
    

    Depending on your card type, you may not get an oracle.jbo.domain.Number, but something else, so the cast may need correction.

    Usage example:

    public class EmpEditViewImpl extends ViewObjectImpl {
      public EmpEditViewImpl() {
      }
    
      protected void executeQueryForCollection( Object object, Object[] object2, int i ) {
        super.executeQueryForCollection( object, object2, i );
    
        EmpDefImpl def = ( EmpDefImpl )getEntityDef( 0 );
        long tableRowCount = def.getTableRowCount( getDBTransaction() ) );
    
        // Do something with it
      }
    }
    

    As you can see, the code is fairly generic. Also, you might be able to put this in a base extension ADF class.

    Sascha

    Published by: Sascha Herrmann on June 7, 2012 14:39

  • Count the number of rows returned from each view in USER_VIEWS

    For each USER_VIEWS view, I would return the name, creation date, last modified dateand the number of rows returned by this view.

    Here's what I have so far:
    col object_name format a20
    select 
    object_name, 
    created, 
    last_ddl_time
    from user_objects
    where object_type = 'VIEW'
    Returns:
    OBJECT_NAME          CREATED   LAST_DDL_TIME
    -------------------- --------- -------------
    AISLE_AVG            11-FEB-12 11-FEB-12     
    COURSE_AVG           11-FEB-12 20-FEB-12     
    EXE_12_VIEW          11-FEB-12 21-FEB-12     
    L1_P2                17-FEB-12 17-FEB-12     
    L1_P3                17-FEB-12 17-FEB-12     
    L1_P4                17-FEB-12 17-FEB-12     
    L1_P5A               17-FEB-12 17-FEB-12     
    L1_P5B               17-FEB-12 17-FEB-12     
    LAB3_1A              12-FEB-12 20-FEB-12     
    LAB3_1B              12-FEB-12 20-FEB-12     
    LAB3_2A              12-FEB-12 20-FEB-12     
    LAB3_2B              12-FEB-12 20-FEB-12     
    LAB5_1               19-FEB-12 19-FEB-12     
    LAB5_2               19-FEB-12 19-FEB-12     
    LAB5_3               19-FEB-12 19-FEB-12     
    LAB5_4               19-FEB-12 19-FEB-12     
    LAB5_5               19-FEB-12 19-FEB-12     
    LAB5_TIMES           19-FEB-12 19-FEB-12     
    LAB6_1               19-FEB-12 19-FEB-12     
    LAB7_VIEW            20-FEB-12 20-FEB-12     
    PROGRAMS             11-FEB-12 21-FEB-12     
    STUDENT_GPA          11-FEB-12 21-FEB-12     
    
     22 rows selected 
    How can I add a last column that counts the number of rows returned by this view?

    EDIT - here is a dump of my paintings, and here are my views.

    Edit2 - this is possible by using the DECODE function, by chance?

    The function...

    CREATE OR REPLACE FUNCTION view_row_count (view_name VARCHAR2)
    RETURN NUMBER
    AS
    retval NUMBER;
    BEGIN
    EXECUTE IMMEDIATE
    'select count(*) from '||view_name INTO retval;
    RETURN retval;
    END view_row_count;
    /
    

    And now the query...

    select
    object_name,
    created,
    last_ddl_time,
    view_row_count(object_name) as view_row_count
    from user_objects
    where object_type = 'VIEW'
    

Maybe you are looking for

  • Automatically add delays to the ability to hide/show the bar

    I activated the option to hide/show the bar automatically. I would like it when I touch the upper part of the screen with the mouse, the menu bar will appear with some delays (2 seconds for example). First it is possible to configure the delay?

  • Two months since 4 k record, and no 4K enhanced Blu-Rays

    For more than two months since I recorded my 55 inch Sony XBR 4K and still not controlled for 4K Blu - Ray by mail. I received my $200 on coupoin for the media player from Sony but no Blu - Ray... Is there a number to call?

  • Is there a way to see what's on my CF card before formatting when an SD card is also loaded into my 5dm 3

    I save raw to my large Jpeg on SD card and CF card.  If the SD card will stay in longer while I change maps CF.   I want to see my CF card to review before formatting.  This time, I eject the SD card to see what's on the map see  Is this possible? Th

  • Desktop folder

    I created a folder on the desktop from the desktop. Now I can't delete it. How can I get rid of this folder? (I delete 30 times a day and he comes back)

  • AHCI RAID mode change

    Hello I installed windows server 2008 R2 in PowerEdge r.620 with PERC H710, 2x300GB HARD drive in AHCI mode. If I change the AHCI RAID mode mode, the data will be lost or NOT? In fact, I need to run the system in RAID 1. Thank you PC