Mod function

hi,
i am trying to commit for every 1000 records.
how to use mod function in following script?
DECLARE
v NUMBER;
counter NUMBER;
CURSOR r1 IS SELECT * FROM TAB1;
BEGIN
FOR c1 IN r1 LOOP
v:=c1.ssn_id;
counter := counter + 1;
IF MOD(counter,1000 ) = 0 THEN
dbms_output.put_line(v);
commit;
dbms_output.put_line(counter);
counter := 0;
END IF;
END LOOP;
END;
could anyone help me for commiting every 1000th record.
thanks in Advance.

The only problem I see, is you did not initialize COUNTER.
if you have counter := counter + 1; without initializing COUNTER, it is like adding NULL + 1 and this will always result in NULL
declare
cursor c1 is select ssn from TAB ;
v_cnt number:=0;  -- NOTE YOU MUST INITIALIZE TO SOME NUMBER
begin
  for c_rec in c1 loop
     v_cnt := v_cnt + 1;
     if mod(v_cnt,1000) = 0 then
        dbms_output.put_line('SSN: '||C_REC.SSN) ;
        dbms_output.put_line('v_cnt: '||v_cnt||' time to commit');
     end if;
  end loop;
end;
/

Similar Messages

  • Subpartition with MOD Function in Oracle 11g

    Hi All,
    Can we create Subpartition based on MOD Function in Oracle 11g ?

    Hi!
    What are you refering with "MTS"? Anybody knows a term like this (except MultiThreaded Server).

  • Mod function in LabView's Configure Formula

    Hello, all.  Today is my first shot at using the Configure Formula feature in LabVIEW (7.1), and I'm not doing well at it.
    The kicker seems to be my (mis)understanding of the mod function.
    Here's the formula I have to work with:
    J=1+(((((C/100)%4)*5)+G)%7), where

    duplicate post, see: http://forums.ni.com/ni/board/message?board.id=170&message.id=161086
    LabVIEW Champion . Do more with less code and in less time .

  • Using the Safe Mode function on your PlayStation 3?

    i followed the steps it works fine then when i sign in within a afew seconds it cuts off and gets a red flashing light again i dont know what to do :/

     
    RabidWalker wrote:
    Using the Safe Mode function on your PlayStation 3?
    Safe Mode:
    The option to use Safe Mode on the PlayStation 3 was introduced if a problem occurs where it will no longer start up normally.
    To use this feature the console will need to have the System Software update 2.60 (or later).
    When to Use Safe Mode?
    When starting up the PlayStation 3, and the XMB menu no longer appears (you may see a wavy line on the background instead).
    When the PlayStation 3 is started up, nothing appears on screen.
    When the PlayStation 3 is started up and you encounter the following message ‘The Hard disk’s file system is corrupted and will be restored’. When selecting ‘OK’ the system restores and restarts, however the same message appears.
    When the PlayStation 3 is started up and you encounter the following message ‘The Hard disk’s database will be rebuilt’. When selecting ‘OK’ the system begins the operation and then fails (stopping the restoration of the HDD).
    There is an issue after the PlayStation 3 update process is started, or a rebuilding of the database occurs.
    Safe Mode procedure:
    1)    Ensure the PlayStation 3 is in standby mode (where the red light is apparent), and then turn the console off at the mains switch.
    2)    Turn the mains power on, then while in standby touch and hold the power button.
    3)    Keep your finger pressed on the power button (after 5 seconds you will hear a beep).
    4)    After 10 seconds of holding your finger on the power button, you will hear a second beep and the console will shut down (you can remove your finger).
    5)    Touch and hold the power button again.
    6)    Again hold your finger down on the button until you hear another beep after 5 seconds.
    7)    A number of seconds after this you will hear a double beep- you can remove your finger.
    8)    You will be prompted to plug your controller in and press the PS button on your controller. After doing so you will access the Safe Mode menu with a number of options.
    Safe Mode Option Screen:
    Restart System
    Selecting this option will start up the system normally- It will also allow you to exit the Safe Mode Menu.
    Restore Default Settings
    Selecting this option will restore Default settings on your console (when starting the unit you will be prompted to set time, time zone etc). This option will also delete your PlayStation Network account information from the system.
    Your User information will be deleted and restored- the indicator will be an asterix by your username e.g. *RabidWalker.
    When logging into your user you will encounter no issues with disc based games. However when attempting to play PSN downloaded games you may encounter the message:
    ‘To access the system, you must activate the system.
    Go to [PlayStation Network] > [Account Management] to activate this system. (80029514). ’
    Follow the instruction to activate your PlayStation 3 to play downloaded games (if the system is activated, deactivate and reactivate the system)
    Restore File System
    This option will begin a process to repair data on your Hard Disk Drive. Therefore it will check for any corrupted data and try and recover this. It the data cannot be recovered it may be erased to ensure that it does not interfere with the operation of the PlayStation 3.
    Rebuild Database
    If issues continue to persist and you select this option please note that data will be removed during this process.
    The following information will removed:
    -          Messages
    -          Playlists
    -          User changes to Information Screens
    -          User changes to Picture under Photos
    -          Video Thumbnails
    -          Video Playback History
    -          Video Resume Information
    This process may take same time to complete
    Restore PS3 System
    The option to restore PS3 system is the same as the ‘quick format’ option on the XMB menu. It will reformat the HDD, removing all data and restoring the Hard drive to its original state.
    System Update
    Selecting this option will install the PlayStation 3 Update but only if the update is on an external media storage device plugged into the console.
    This option can be used if any issues are encountered with the installation of the System software update.
    If you have any queries regarding this or any other issues please PM me or catch me on Twitter
    @RabidWalker
    Rabid
     

  • MOD() function - incorrect output

    The following bit of SQL uses the mod() function to determine modulus 2 of two large numbers
    13:37:20 SQL>set echo on
    13:37:24 SQL>@mod_test
    13:37:25 SQL>
    13:37:25 SQL>
    13:37:25 SQL>
    13:37:25 SQL>select mod(power(2,127)-1,2) from dual
    13:37:25 2 /
    MOD(POWER(2,127)-1,2)
    1
    1 row selected.
    13:37:25 SQL>
    13:37:25 SQL>select mod(power(2,128)-1,2) from dual
    13:37:25 2 /
    MOD(POWER(2,128)-1,2)
    -1
    1 row selected.
    13:37:25 SQL>
    Notice that mod(power(2,128)-1,2) returns an incorrect answer, while the
    answer for mod(power(2,127)-1,2) is correct.
    Does someone here know why?
    Is it a limit?
    Or is it a bug?
    Please supply an explanation and/or URL for your answer. :)

    Must be due to the fact the scale for a NUMBER can range from -84 to 127, and Floating Point Number Limits are:
    Value                         Binary-Float          Binary-Double
    Maximum positive finite value 3.40282E+38F  1.79769313486231E+308
    Minimum positive finite value 1.17549E-38F  2.22507485850720E-308

  • OWB10GR2 - Error when try to use 'MOD' function in an Expression

    Hi
    I'm trying to use the MOD function in an expression, e.g. mod(44,12), however, when I validate I get the error:-
    Line 2, Col 18:
    PLS-00201: identifier 'MOD' must be declared
    Line 0, Col 1:
    PL/SQL: Statement ignored
    Has anyone else come across this problem, and can anyone please suggest a solution?
    Thanks
    GB

    Not yet, thanks for the suggestion.
    If you use MOD in an expression or Constant, the expression does not validate but the mapping itself does validate, deploy and runs ok. So
    This issue has been reported as a bug therefore for the time being we can just ignore the expression validation message.

  • How to set mod function in TestStand

    I have trouble to use mod function in a TestStand seq under if condition. There is a syntax error of Unexpected token: MOD.
    I would like advice how to do this correctly. Thanks!
    Solved!
    Go to Solution.

    It should be 100 MOD 1000
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Any Mod function in JAVA?

    I did not find 'MOD' function in the Math class. Is there any 'MOD' function in Java?
    Thanks!

    What is your MOD function?
    Does the %-operator do what you need or do you want a strict mathematical modulus that returns only positive values?

  • Ultrabeat's pan mod function?

    Ultrabeat's pan mod function?
    Could someone please explain to me how Ultrabeat's pan mod function works?
    I know how to use automation in LPX's Tracks Area to automate panning but I'd like to avoid that on this occasion.
    I also tried using the LFO to modulate the panning but with limited success.
    And if anyone also knows if there's a good book specifically on Ultrabeat (pref published since the intro of LP9) that'd be awesome because most books don't go into the intricate parameters.

    duplicate post, see: http://forums.ni.com/ni/board/message?board.id=170&message.id=161086
    LabVIEW Champion . Do more with less code and in less time .

  • Using the MOD Function

    Can someone explain to me the syntax of the MOD function. In my Oracle9i book it states "The MOD function find the remainder of value1 divided by value2.
    In a simple sql statement I ran from my test db. For the life of me I cannot see where any division takes place.
    select employee_id, last_name, first_name, salary, mod(salary, 500)
    from employees;
    EMPLOYEE_ID LAST_NAME FIRST_NAME SALARY MOD(SALARY,500)
    100 King Steven 24000 0
    101 Kochhar Neena 17000 0
    102 De Haan Lex 17000 0
    103 Hunold Alexander 9000 0
    104 Ernst Bruce 6000 0
    105 Austin David 4800 300
    106 Pataballa Valli 4800 300
    107 Lorentz Diana 4200 200
    108 Greenberg Nancy 12000 0
    109 Faviet Daniel 9000 0
    110 Chen John 8200 200
    111 Sciarra Ismael 7700 200
    112 Urman Jose Manuel 7800 300
    113 Popp Luis 6900 400

    user12130369 wrote:
    In a simple sql statement I ran from my test db. For the life of me I cannot see where any division takes place.
    select employee_id, last_name, first_name, salary, mod(salary, 500)
    from employees;
    EMPLOYEE_ID     LAST_NAME    FIRST_NAME      SALARY     MOD(SALARY,500) 
    105                   Austin             David                 4800         300 
    113                   Popp             Luis                   6900         400
    For employee 105: 4800 / 500 = 9 remainder 300
    For employee 113: 6900 / 500 = 13 remainder 400
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Calculated member - Mode function

    Hello,
    I need some help. I am quite new to MDX; I've created a cube and the measure needs to behave same as the MODE function in Excel (the following
    link
    describes what the function does). Apparently the only way of achieving this is by MDX (calling the MODE function directly from Excel is not an option for me). Practically the member should return a single value, that represents the price that appears
    most times. There are 4 dimensions in my cube: dates, stores, products and client products. I need the following calculations:
    1. MODE(price) for specific Date, Product and Client Product. There will be multiple lines returned for this set, as there are multiple stores.
    2. MODE(price) for specific Store, Product and Client Product. There will be multiple lines returned for this set, as there are multiple dates.
    I found the below code online, that I've adapted to work against my cube, currently the query returns correct results for the first part, Mode(price) for multiple stores. I can change it to do the same for date. 
    What I need is to create 2 calculated measures using the last select and I am unsure how this can be achieved. Any help will be much appreciated or any other approach in achieving this.
    WITH 
    --Count how often each value appears
    MEMBER [Measures].[ValueCount] AS 
    SUM(  Union([Dim Stores].Store].CurrentMember.Level.Members,       {[Dim Stores].[Store].CurrentMember} AS CurrentStore),
    IIF( ([Dim Stores].[Store].CurrentMember, [Measures].[Price]) = 
    (CurrentStore.Item(0).Item(0), [Measures].[Price]) , 1, null))
    --Only get the items that appear the most
    SET [MaxModes] AS     
    ORDER(FILTER(NONEMPTY([Dim Stores].[Store].Members, {[Measures].[Price]}),    
    [Measures].[ValueCount] = MAX(NONEMPTY([Dim Stores].[Store].[Store].Members, [Measures].[Price]),    
    [Measures].[ValueCount])), [Measures].[Price], ASC)
    SELECT   {[Measures].[Price]} on 0,        
    [MaxModes]       
    --Filter out the duplicates        
    HAVING [MaxModes].CurrentOrdinal = 0 OR [Measures].[Price] <>             ([Measures].[Price], [MaxModes].Item([MaxModes].CurrentOrdinal - 2)) ON 1
    FROM [old_Prices_v2]
    WHERE {[Dim Date].[Date].&[2013-06-23T00:00:00]}*{[Dim Client Products].[Client Product].&[13]}*{[Dim Products].[Product].&[551]}

    I'm describing below what exactly is required:
    The cube has 4 dimensions (Date, Store, Product, Client Product) and one measure (Price). I need a measure to behave same as the MODE function in
    Excel (value that occurs most often). Practically the member should return a single value, that represents the price that appears most times. 
    While browsing the cube I need, for any combination of dimensions/hierarchies, to get the MODE of the price at its lowest grain (that is Date, Store,
    Product, Client Product). No need to aggregate the measure in any way. 
    For example if someone looks at a specific combination of Product & Client Product, the calculated measure would show the price that appears most
    times against that Product+Client Product, in any of the stores and in any of the dates.
    Example:
    Date
    Store Product
    Client Product
    Price
    05-Feb-2013
    Store1 Prod1
    ClProd1 50
    05-Feb-2013
    Store1 Prod1
    ClProd1 60
    06-Feb-2013
    Store2 Prod1
    ClProd1 60
    06-Feb-2013
    Store2 Prod1
    ClProd1 70
    05-Feb-2013
    Store1 Prod1
    ClProd2 80
    05-Feb-2013
    Store1 Prod1
    ClProd2 50
    06-Feb-2013
    Store2 Prod1
    ClProd2 50
    06-Feb-2013
    Store2 Prod1
    ClProd2 70
    Case1: If one looks at Prod1 & ClProd1 then the MODE(Price) is 60 as there are 4 rows to be aggregated and the value that repeats most is 60
    Case2: If one looks at Prod1 & ClProd1 & Store1 then the MODE(Price) is either 50 or 60 as there are 2 rows to be aggregated and both 50 and
    60 repeat 1 time. I this case any of them can be returned (act like TOP 1 in TSQL)
    Case3: If one looks at Prod1 & Store1 then the MODE(Price) is 50 as there are 4 rows to be aggregated and the value that repeats most is 50
    Case3: If one looks at Prod1 & 06-Feb-2013 then the MODE(Price) is 70 as there are 4 rows to be aggregated and the value that repeats most is 70.
    Any guidance will be much appreciated!
    Thank you in advance.
    Mihai

  • Even/Odd MOD Function

    Create an anonymous PL/SQL block that accepts an integer number N through SQL*Plus substituion variable and then determines for each of the numbers in the range 1 through N inclusive whether it is odd or even. Use the MOD function to determine whether a number is odd or even. For example, MOD (10, 2) = 0 and MOD (11,2)=1. Print the results on the screen.
    Your program should handle NULL values. N should be set to 0 if a NULL value is entered.
    Here is the code I generated for this problem:
    ACCEPT num1 PROMPT 'Please enter a number between 1 and 10: '
    DECLARE
    mynum NUMBER := &num1 (stores the user input into a PL/SQL variable);
    mynum1 NUMBER (stores the value returned from the MOD function);
    function MOD(mynum2 NUMBER)
    Return NUMBER (remainder datatype) is
    evenoddnum NUMBER (returns a remainder number from the calculation);
    BEGIN
    evenoddnum := mynum2/2 (divides the number entered by the user by 2);
    Return evenoddnum (the remainder from the division operation);
    END;
    BEGIN
    if (mynum) is NULL then
    mynum :=0;
    end if ; (sets all NULL values entered by the user to 0)
    mynum1 := MOD(mynum) (stores the remainder from the MOD calucation after the function is call. The user's input is passed as a parameter to the function) ;
    if (mynum1 = 0) then
    dbms_output.put_line ('You entered an even number');
    elsif (mynum1 = 1) then
    dbms_output.put_line ('You entered an odd number');
    end if; (test whether the remainder returned in mynum1 is 0 or 1)
    END;
    Error message received:
    SQL> start prog2c.sql
    Please enter a number between 1 and 10: 5
    mynum1 := MOD(mynum);
    ERROR at line 20:
    ORA-06550: line 20, column 18:
    PLS-00306: wrong number or types of arguments in call to 'MOD'
    ORA-06550: line 20, column 8:
    PL/SQL: Statement ignored
    Does anyone have any idea what this error message means???? I am totally confused.
    Thanks!

    First off, creating a local MOD function is a bad idea when there is already a system-level MOD function. At best, you'll totally confuse people.
    How about
    ACCEPT num1 NUMBER FORMAT 99 DEFAULT 0 PROMPT 'Enter a number (1-10): '
    DECLARE
      num  NUMBER := &num1;
    BEGIN
      IF( &num1 IS NULL )
      THEN
        dbms_output.put_line( 'Null' );
      ELSIF( MOD(&num1, 2) = 0 )
      THEN
        dbms_output.put_line( 'Even' );
      ELSE
        dbms_output.put_line( 'Odd' );
      END IF;
    END;Note that I don't check for values > 10 or < 1, you'll have to add that.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Understanding of MOD function

    Hi all,
    I'm not familiar with MOD function, could someone please explain how does it work.
    Actually, why
    select months_between(trunc(sysdate+125,'MM'),trunc(sysdate+125,'Q')) from dual and
    select mod(to_char(sysdate+125, 'mm') - 1, 3) from dual return the same value?

    Hi,
    MOD is a numeric function, which takes two numbers as input and returns reminder of the devision of number 1 by number 2.
    for example
    for, 10/3 , you will get reminder 1. So mod ( 10, 3) will return you 1.
    The two queries you have given are taking one date ( i.e. sysdate + 125 = 02-AUG-11 + 125 = 05-DEC-11 ),
    and returns the difference in months between the starting of current quater and that date.
    Both are doing same things but with different logic.
    select mod(to_char(sysdate+125, 'mm') - 1, 3) from dualMake the piece of this query to understand how its working:
    - Its taking the month of the date i.e. 12 and subtracting 1 from it (i.e 11).
    - its than using the mod funtion to get the reminder of 11 / 3. mod ( 11 / 3 ) = 2.
    HTH,
    Regards,
    Dipali.

  • Implement MOD(%) function

    Please implement MOD(%) function without using the MOD or %.  . Function should take in two integers and return one integer.

    "The only reason to create and use a MOD function over the in build one is if this was a homework exercise. "
    I'd have to classify that statement as false.
    A number of languages have slightly different built-in implementations that are a pain to use.  For example what is mod(-1, 4) ?  In some implementations the answer is -1 in others the answer is 3.  If the built in version returns a value
    that is less useful to you then knowing how to write your own implementation is important and not necessarily a homework assignment.  Some people may genuinely be interested in the mathematical definition of the mod function (or % operator)
    The wikipedia entry whose link is in the response by eyal below is decent and has an interesting table of language specific differences in implementation.  The fact that such a table exists proves that the snarky responses are misguided.  in any
    event, results that are "always non-negative" or results that are governed by the sign of the divisor are in my opinion most justifiable in mathematical terms.  Results that depend on the sign of the dividend are difficult to use when trying
    to compute subscripts for arrays for example.
    The divisor based sign implementation looks like this
    // a = qb + r such that 0 <= r < b and b > 0
    // r = a - qb
    result = a - b*floor(a/b); // a % b
    here is the wikipedia link again
     http://en.wikipedia.org/wiki/Modulo_operation
    The non-answers here reflect cruelty or ignorance (inclusive or)

  • Statistical calc with MDX question (Mode function as an excel)

    Hi All,
      I need to create an MDX Calc to Returns the most frequently occurring, or repetitive, value in an array or range of data.
      For example, the mode of 2, 3, 3, 5, 7, 10 is 3.
      In Excel I use the MODE() function but I don't know how to do this in MDX and add it as a measure in Universe.
      I can't do the formula in WEBI because we have big data volume and I can't retrieve all the customers in WEBI.
      We have SAP BW 7.0 and SAP BusinessObjects XI 3.1 fix pack 1.3
    Thanks in advance.

    Hi,
    it looks like you created the entry twice so I would suggest you close on of them:
    Statistical calc with MDX question (Mode function as an excel)
    I don't think that those kind of statistical functions are available in MDX. you can always go to se37 and use the bapi_get_functions to see the list of supported functions.
    Ingo

Maybe you are looking for

  • File (Directory) object problem?

    Hi there. My problem is as follows. The method below is supposed to access an pre-existing directory with five previously saved test files, read in those files as account objects, add the objects to an ArrayList, then return the ArrayList. It seems t

  • Can I repair a Snow Leopard disk from a Tiger machine?

    I had the hard drive go down on a MacPro with an Intel processor running OS 10.6.4.  When I try to boot, it gets to the Apple screen and shuts down.  Running the disk utility from the installation disk gives me the error: Checking HFS Plus Volume Inv

  • Universal Dock remote capabilities

    Are you able to use the remote that comes with the Universal Dock to also control the computer it's hooked up to? I mainly want to control simple functions of DVD Player with it. I have a 2009 aluminum iMac.

  • Why doesn't my second generation ipod don't get wifi

    Why doesn't my ipod get wifi in my house but my sister's ipod gets wifi in the same house. Please help me

  • Losing wireless connexion from a TC with a MBP

    I don't understand why from time to time I open my mbp and the wireless connexion with my tc can't seem to work. I took a look at the logs in the TC and here is what shows each time I close and open again the airport on the mbp: Jul 12 16:59:21 Sever