Automating the validation based on the number of rows updated

Hello

Is it possible that I can, in a SQL script, restore or commit a transaction according to the number of lines have been updated?

We often receive requests for corrections of data in DBs and then must post manually, but only if the number of lines is what the developer has specified.

1 tab1 update
2. If the number of rows updated = 50, validation
3 if not, roll back

Thank you
Andreas

Try this

update of tab1 set col1 = 80;
If rowcount sql = 50% then
commit;
on the other
rolback;
end if;
....

Tags: Database

Similar Questions

  • Find the number of rows updated

    Hello

    Select count (col1) in tab1 where instr (col1, 'A'). = 0 ;
    = > 4 ranks

    If I do:
    update of tab1 set col1 = replace(col1,'A','B');
    = > 1500000 lines updates

    1500000 is the total number of the table tab1

    What's wrong?

    Thanks in advance
    11.2.0.2

    Hello 12045475,

    Oracle will count every line that corresponds to the place where your update statement clause. If you have not, each line is affected.
    This means a line that updated account, even if no data is changed, even more: If you have a trigger on the update for each row, this trigger fires even when the line is unchanged.

    Concerning
    Marcus

  • 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.

  • Determine the number of rows returned by a cursor

    I have a problem when I need to use slightly different logic based on whether or not a cursor returns a single line or multiple lines. I know you can use % ROWCOUNT to determine the number of rows returned far+, but it's not really help me because I need to know this information before I start to do any treatment.


    In other words. How can I know the number of rows returned by a cursor without actually iterate through the entire thing.

    I'm looking for something like this:
       Cursor ReqCursor(pi_cert_id IN Varchar2) Is
          SELECT course_id cid, grade g
            FROM requirements
           WHERE cert_id = pi_cert_id;
       c_ReqCursor ReqCursor%Rowtype;
    
    Open CertCursor(p_cert_num);
        Loop
            Fetch CertCursor
              INTO c_CertCursor;
            Exit When CertCursor%Notfound;
            
            If c_CertCursor%NumOfRows > 1 THEN
                Case A;
            Else
                Case B;
            End If 
       End Loop
    Close CertCursor;

    For your business add

     SELECT course_id cid, grade g, count(*) over() Tot_Rows
            FROM requirements
           WHERE cert_id = pi_cert_id;
    --"Fetch 1st row and you will know if the cursor has more than 1 row"
    

    HTH
    SS

  • 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

  • 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

  • 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

  • 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" / > ""

  • 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

  • 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;

  • 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'
    
  • How do to display the number of rows Inserted/deleted etc. in PL/SQL

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

    For example:

    set serveroutput on
    
    begin
    
       delete  dept;
    
       dbms_output.put_line(sql%rowcount);
    
    end;
    /  
    

    Miguel

  • Limit the number of rows retrieved

    We have the need to limit the number of rows retrieved in a table for some users.

    We tried to put this by adding a policy that limits the number of rows. Here is the code:


    create or replace function
    usu01_access_policy
    (obj_schema varchar2, obj_name varchar2) return varchar2
    is
    d_predicate varchar2 (2000);
    Start
    If the user = "PEPE01" then
    d_predicate: =.
    "rownum < 11';
    on the other
    d_predicate: =.
    ' 1 = 1' ;
    end if;
    Return d_predicate;
    end;

    This code works well when you query the table like this:

    Select * from usu01;

    the number of rows retrieved is 10.

    But when we define a clause 'where' the query does clause 10 recovered lines before, getting only the lines of the first 10 with the condition 'where' = true.

    Is there a way to limit the number of retrieved rows from a table, but by first applying the 'where' clause to the whole table and later the ' rownum < limit ' condition?

    Thank you

    Why do you limit the number of lines of output? It is a customer number, not a database problem, I would say.
    Which should be resolved within the query itself. Using rownum without orderly subquery also return different results on each run.
    Take a look here for top - N query: http://www.oracle.com/technetwork/issue-archive/2007/07-jan/o17asktom-093877.html

    Nicolas.

  • How to limit the number of rows returned in a query

    Hi friends,
    I want to limit the number of rows returned by my request to some 10 lines. How to do this. When I try to make some 6 rows with the rownum < 10 its giving results for a particular Department and that too only... btw I'm bundling my table and includes much a table joins and will order the results of the table by a column... How to do this...

    Run it:

    select * from (your query goes here) where rownum < 10
    

    Nicolas.

Maybe you are looking for

  • Not able to see the "calls cell phones iPhone" on the iPhone 4S

    Hello I have iPhone 4 (running OS 9.1) s and MacbookPro (running OS Yosemite 10.10.5). Im trying to make calls from my Mac, but while doing this, he throws me error that your devices are on the same network. IM guaranteed that they are in the same ne

  • Family sharing - child accounts are adults

    We have four adults Apple ID all related to the same family sharing.  I created the ID Apple before family sharing the existence when I created two accounts for my children so I did the adult accounts (if I remember correctly, when I tried specifying

  • How to install Visual Studio 6.0 on Windows Server 2012

    I have a build server that is located on Windows Server 2012.  I need to install Visual Studio 6.0 to build some of our VB and C++ components.  Whenever I run the Setup fails.  Can someone please tell me know how to install VS 6.0 on Windows Server 2

  • Microsoft send me an email telling me I have a virus and need to provide personal information?

    I received an email telling me I have a virus in my files and I need to give them my username, password, date of birth, etc. to put the safety on my account.  The page contains all the usual microsoft logos, etc.  Is it really of Microaoft?

  • m252dw: postscript print file

    How to print a postscript or pdf directly from windows file. I can copy the files on a USB and put it in the printer, and it works. The printer is connected by wifi. I could use "copy file.ps to \\server\share", if I knew the names \\server\share. I