Use of ORA_ROWSCN

Is it possible to use ORA_ROWSCN in lieu of a version column for optimistic locking?
Our application has a large number of tables and I'd prefer not to add a column to each unless it is unavoidable), hence ORA_ROWSCN looks interesting (I know I can write code to achieve it quite easily).
Also, can anyone suggest pros and cons for choosing between timestamp and version.
Thanks
Mike

Mike,
I have not tried extending the locking policies to support SCN usage but if you can read it in and supply a valid check within the update then I believe it is possible.
For schemas where it is not possible to add locking columns TopLink does offer several out of the box locking policies. You can use the existing columns such that TopLink will check the original values from the read against those that are there during the write. There are 3 options for this:
1. Check all columns
2. Check a specified set of columns
3. Check only the modified columns
I prefer the numeric version field as it is the simplest and most efficient comparison possible. The timestamp is a second choice but you need to make sure the type on the database provides adequate granularity.
These 3 types that use existing column values are great when you need them but they do require slightly more verbose DML.
http://download-west.oracle.com/docs/cd/B14099_06/web.1012/b15901/dataaccs008.htm#sthref1386
http://download-west.oracle.com/docs/cd/B14099_06/web.1012/b15901/dataaccs008.htm#sthref1386
Doug

Similar Messages

  • Hibernate and ora_rowscn

    We are trying to implement optimistic locking through the used of ORA_ROWSCN, and the developers are running into the problem that hibernate is incrementing the ora_rowscn number when updates are done on the row.
    Develpers don't see a way to make using ORA_ROWSCN work with the second-level cache. If they could tell Hibernate to invalidate the cache when updates are done instead of put the updated entity directly into the cache, they think they could make it work. Unfortunately they haven't been able to find a way to modify the cache's behavior.
    Has anybody run into this problem?
    I will appreciate any suggestions on how to make hibernate to work with ora_rowscn.
    We are using Spring 2.5.6 with JPA Hibernate Entity Manager 3.3.2 running on Tomcat 6, we are not using OC4J.
    We are using Atomikos 2.1.7 for our transaction manager, and here are some of our hibernate settings:
    jpa.hibernate.max_fetch_depth=2
    jpa.hibernate.default_batch_fetch_size=16
    jpa.hibernate.order_updates=true
    jpa.hibernate.connection.isolation=4
    jpa.hibernate.generate_statistics=true
    jpa.hibernate.jdbc.use_get_generated_keys=false
    jpa.hibernate.jdbc.fetch_size=0
    jpa.hibernate.jdbc.batch_size=30
    jpa.hibernate.connection.release_mode=after_statement
    jpa.hibernate.default_schema=
    jpa.hibernate.strict_jpaql=true
    jpa.hibernate.cache.use_second_level_cache=true
    jpa.hibernate.cache.use_query_cache=true
    Thanks in advance for any help on this.

    thanks for your reply.
    We are already doing that, but even with that setting we still have the problem and we cannot get hibernate to not increment the ora_rowscn.
    This is what we have in our code.
    @Version
    @Column(name = "ORA_ROWSCN", insertable = false, updatable = false)
    @org.hibernate.annotations.Generated(GenerationTime.ALWAYS)
    private Long version;
    Did anybody run into this problem with hibernate using ora_rowscn?
    Any help will be greatly appreciated.
    Thanks

  • Oracle insert problem(records not in the order they are inserted)

    hi, all:
    I tried to insert a word list into a oracle table, everything is fine except that the words are not in the order they are inserted. For example, the words are inserted in the following sequence:
    accreted     
    accreting     
    accretion     
    accretionary     
    accretive     
    bladebone
    bladed     
    bladeless
    bladelike
    When I retrived the resultset from the table and iterate through each of the record, the words are not in the order inserted, i.e., it may look like this,
    accreted     
    accreting     
    bladebone
    bladed     
    accretion     
    accretionary     
    accretive     
    bladeless
    bladelike
    This strange phenomenon won't happen when the word list is small, like 500 words or so, but when the number of words reaches around 10,000, it takes place. My coworker also experienced this problem when trying to insert large volume of data into oracle table.
    The code I used to insert into the DB table:
    BufferedReader reader=new BufferedReader(new FileReader("C:\\Dictionary.txt"));
    while( (line=reader.readLine())!=null )
         sql="INSERT INTO DICT " +
         "VALUES ('" + line +"')";                         
         statement.executeUpdate(sql);
    Any advice will be highly appreciated,
    thanks

    Well, the best thing to do is follows scsi-boy's advice and add the additional column and either put a sequence number in it from the Java side as you insert, or use an Oracle sequence object to put a sequence number in it from the Oracle side (which is sort of like an auto-generated value, but different).
    Note that an Oracle sequence generates numbers in sequence, but possibly with gaps (usually if the database is rebooted), unless you do some things that slow sequences down substantially. Sequences can also be something of a bottleneck on RAC clusters. See:
    http://www.dizwell.com/oracle/articles/autonumbering.html
    However, if your coworker is commiting after each and every insert (which is bad form and slows the database down, -10 points), and if your coworker is also never ever ever updating the columns after they've been inserted, and if your coworker is using Oracle 10g and not some older version such as 9i, then your coworker could use the ORA_ROWSCN pseudo-column to order by. Those are very very severe constraints and you shouldn't begin to consider doing it that way without a very good reason, and right now you and your coworker wouldn't know a good reason if it snuck up and bit you on the butt, you've got a lot of learning the basics first.

  • Refresh database table

    Hi,
    I've got to find out if a table is being refreshed daily. Apart from looking for scripts that could be doing the refresh (which I've not found), is there a data dictionary view that could tell me and if so what column in the view do I need to look at to tell me if it's been refreshed today or when was the last time it was refreshed.
    thank you.

    Dear,
    Since you are on 10g, you could potentially use the ORA_ROWSCN pseudocolumn. That gives you an upper bound of the last SCN (system change number) that caused a change in the row. Since this is an increasing sequence, you could store off the maximum ORA_ROWSCN that you've seen and then look only for data with an SCN greater than that.
    By default, ORA_ROWSCN is actually maintained at the block level, so a change to any row in a block will change the ORA_ROWSCN for all rows in the block. This is probably quite sufficient if the intention is to minimize the number of rows you process multiple times with no changes if we're talking about "normal" data access patterns. You can rebuild the table with ROWDEPENDENCIES which will cause the ORA_ROWSCN to be tracked at the row level, which gives you more granular information but requires a one-time effort to rebuild the table.
    Another option would be to configure something like Change Data Capture (CDC) and to make your OCI application a subscriber to changes to the table, but that also requires a one-time effort to configure CDC.
    Oracle can watch tables for changes and when a change occurs can execute a callback function in PL/SQL or OCI. The callback gets an object that's a collection of tables which changed, and that has a collection of rowid which changed, and the type of action, Ins, upd, del.
    So you don't even go to the table, you sit and wait to be called. You'll only go if there are changes to write.
    It's called Database Change Notification. It's much simpler than CDC as i mentioned, but both require some fancy admin stuff. The good part is that neither of these require changes to the APPLICATION.
    The caveat is that CDC is fine for high volume tables, DCN is not
    I wish i have answered you well
    Kind regards
    Mohamed ElAzab
    Database Admin at Etisalat
    Edited by: user2974000 on Jul 13, 2010 2:31 PM

  • How to find obsoleted tablespace? (scn or time of last change or access)

    Hi,
    there are many tablespaces in the database which are probably not yet used by applications...
    Please, how do I find which of these can be dropped? That means, how to find last update time or scn of last change or access (last used select for that tablespace)?
    Many thanks in advance in any info how to get forward.
    Pavol

    user10858565 wrote:
    Hi,
    there are many tablespaces in the database which are probably not yet used by applications...
    Please, how do I find which of these can be dropped? That means, how to find last update time or scn of last change or access (last used select for that tablespace)?
    Many thanks in advance in any info how to get forward.
    PavolI suppose you meant tables (in that tablespace)
    There is no direct way where you can find this information if auditing is not enabled.
    To check if insert/update/delete has been performed on table you can use function ora_rowscn to check when it was done last.
    Regards
    Anurag

  • Using ora_rowscn on a FGAC table: bug?

    Oracle 10.1.0.3.0 on Linux AMD/64.
    Trying to use ORA_ROWSCN on a table that has a FGAC policy fails with a ORA-00904: "ORA_ROWSCN": invalid identifier.
    Metalink turns it up as a SQL-Developer bug!?? Bug 5663250 reports the exact same problem. And seeing that the client s/w used was SQL-Developer, it seems that the patch was to put a work-around into SQL-Developer?
    Here's a copy of a SQL*Plus session that shows the problem.
    SQL> -- selecting from a non-FGAC table
    SQL> select protocol_name, protocol, ora_rowscn from protocols where rownum < 11;
    PROTOCOL_N PROTOCOL ORA_ROWSCN
    ip 0 5.2196E+12
    icmp 1 5.2196E+12
    igmp 2 5.2196E+12
    ggp 3 5.2196E+12
    ipencap 4 5.2196E+12
    st 5 5.2196E+12
    tcp 6 5.2196E+12
    cbt 7 5.2196E+12
    egp 8 5.2196E+12
    igp 9 5.2196E+12
    10 rows selected.
    SQL> -- selecting from a FGAC table without using ORA_ROWSCN
    SQL> select service, port, protocol from applications where rownum < 11;
    SERVICE PORT PROTOCOL
    a14 3597 6
    a14 3597 17
    a15 3598 6
    a15 3598 17
    quasar-server 3599 6
    quasar-server 3599 17
    trap-daemon 3600 6
    trap-daemon 3600 17
    visinet-gui 3601 6
    visinet-gui 3601 17
    10 rows selected.
    SQL> -- adding SCN to this select results in an exception
    SQL> select service, port, protocol, ora_rowscn from applications where rownum < 11;
    select service, port, protocol, ora_rowscn from netflow.applications where rownum < 11
    ERROR at line 1:
    ORA-00904: "ORA_ROWSCN": invalid identifier
    SQL>
    Can anyone confirm this bug? Any workarounds? Does it still exist on 10.2?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi Michaels,
    Appreciate your input on this and elegant solution.
    Had created your function in my TEST_VPD schema (with SYS.DBMS_SYS_SQL priviledge)with minor changes as proposed
    by you and it's working fine on  FGAC tables !!!
    What i had done where BOLD text are my changes:
      create or replace function my_ora_rowscn(rid rowid, p_table_name varchar2)
    return integer
    as
      l_table_name varchar2(30) := p_table_name;
      l_ora_rowscn integer;
      l_cur        integer;
      l_ret        integer;
    begin
      /*  You may skip this part if you feed the function directly with a table name
       select object_name into l_table_name from user_objects where object_id = dbms_rowid.rowid_object(rid); */
      l_cur:=sys.dbms_sys_sql.open_cursor();
      sys.dbms_sys_sql.parse_as_user(l_cur,'select ora_rowscn from ' || l_table_name || ' where rowid = :1',dbms_sql.native,0);
      sys.dbms_sys_sql.bind_variable(l_cur,'1',rid);
      sys.dbms_sys_sql.define_column(l_cur,1,l_ora_rowscn);
      l_ret := sys.dbms_sys_sql.execute_and_fetch(l_cur);
      sys.dbms_sys_sql.column_value(l_cur,1,l_ora_rowscn);
      sys.dbms_sys_sql.close_cursor(l_cur);
      return l_ora_rowscn;
    exception when no_data_found then
      return null; 
    end my_ora_rowscn;
      Btw, had tried to find some documentation about DBMS_SYS_SQL in
    "http://www.oracle.com/pls/db102/homepage" but only some reference to the above
    package was found.
    Can you direct me to link that describe the package above ?
    Thanks & Regards
    Zack
    Had found using good old Google that package is
    undocumented and had found the below link:
    Invoker Rights with DBMS_SYS_SQL..PARSE_AS_USER
    "http://www.trivadis.com/Images/ParseAsUser_e_tcm17-7282.pdf"
    Message was edited by:
            Zack.L                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • ORA-00904: "ORA_ROWSCN": invalid makes release 2.1.0.63  unusable

    I originally posted this on an answered post.. reposting since it doesnt seem to get any attention when you post to an already answered post... Plus the error on the original post was a little different...
    Using 2.1.0.63, 10.2.0.4.0 64bit database, AIX OS..
    I am getting this on about 10 to 20% of my tables... ORA-00904: "ORA_ROWSCN": invalid identifier
    To reproduce select table in tree, press data tab, this error appears in Data Editor - Log window with no data in data tab.
    This did not happen in 1.5.5.
    Maybe this is the issue... Evidently this was fixed in Oracle 11g database.
    Metalink bug 5183871
    WORKAROUND:
    Do not use ANSI join syntax with ORA_ROWSCN.

    Even though I marked this resolved I have figured out more about this error. Like I said this is only happening with tables that have a policy - fine grained access. Basically no matter who I log in as, if I have a table with a policy I get the ora_rowscn error and cannot see the data in the data tab. This did not happen in 1.5. I could see the data in 1.5. So, it appears that 2.1 is using ora_rowscn in the query to get the data and 1.5 does not use ora_rowscn. So, in 2.1 if the table has a policy then the database isues the ORA-00904: "ORA_ROWSCN": invalid error and you cannot see the data.
    Can anyone else reproduce this with a table that has a policy - fine grained access.
    So, something is different in the way 1.5 and 2.1 query data from a table into the data tab.

  • How to see inserted rows using load csv data

    Hey all...
    I am using apex 3.1 and I want to know how can I see non failed rows when I insert data from an CSV file.
    the failed rows that I can see are the the ones that shows in the next case: Uploading data that already exists and having a primary key violation. But what I really want to see is the description of the rows that had been succesfully loaded, not just a number of succesfully loaded rows.
    Thanks in advance.
    Luis.

    Try some thing like this
    select  Field, Filed2, ORA_ROWSCN, SCN_TO_TIMESTAMP(ORA_ROWSCN)  from Table Name
    You will get the recent  date of  insert/update of record

  • ORA-00904: "ORA_ROWSCN": invalid identifier prevents data to show

    in sqldeveloper version 2106373 in Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Please fix in next version last version .63 it did not work and this current version same

    I installed Oracle SQL Developer 2.1 Patch 1 (2.1.1.64.39) and it still gave me the error, but after some searching I found the setting.
    You can find it under the preference -> database -> object viewer. Uncheck the check-box in front of the line: "Use ORA_ROWSCN for DataEditor insert and update statements."

  • How to use APP_SESSION

    Hi,
    I have a application which is logged by different user and if one user A is trying to edit a particular row and same row is trying to edit the another user B then how to find the user A which is editing the same row and send a message to user B that user A is editing the row.
    RJC

    Any automated DML carried out by HTML DB uses optimistik locking by default i.e user A hopes to carry out the update providing that the record has not been changed.
    If User B changes the record without USER A knowing about it, USER A transaction will not be commited and a Checksum type error displayed.
    If you have to write some custom DML, you can use the MD% checksum api to implement your own locking
    see http://www.oracle.com/technology/products/database/application_express/howtos/tabular_form.html#MD5
    Alternativly, a different approach is to use ORA_ROWSCN
    see
    Optimistic Locking Solution
    I dont thikn APP_SESSION is what you are after but let me know if any of that helps
    Regards
    Duncan

  • How do I use Edge Web Fonts with Muse?

    How do I use Edge Web Fonts with Muse - is it an update to load, a stand alone, how does it interface with Muse? I've updated to CC but have no info on this.

    Hello,
    Is there a reason why you want to use Edge Web Fonts with Adobe Muse?
    Assuming you wish to improve typography of your web pages, you should know that Muse is fully integrated with Typekit. This allows you to access and apply over 500 web fonts from within Muse. Here's how you do it:
    Select a text component within Muse, and click the Text drop-down.
    Select Add Web Fonts option, to pop-open the Add Web Fonts dialog.
    Browse and apply fonts per your design needs.
    Muse also allows you to create paragraph styles that you can save and apply to chunks of text, a la InDesign. Watch this video for more information: http://tv.adobe.com/watch/muse-feature-tour/using-typekit-with-adobe-muse/
    Also take a look at these help files to see if they help you:
    http://helpx.adobe.com/muse/tutorials/typography-muse-part-1.html
    http://helpx.adobe.com/muse/tutorials/typography-muse-part-2.html
    http://helpx.adobe.com/muse/tutorials/typography-muse-part-3.html
    Hope this helps!
    Regards,
    Suhas Yogin

  • How can multiple family members use one account?

    My children have iphones, ipads, ipods and mac books, my problem is how do you use home sharing with the devices and not get each others data.  My Husband just added his iphone to the account and got all of my daughters contacts.  I understand they could have there own accounts but if i buy music on itunes and both children want the same song, I don't feel i should have to pay for it twice.  Is there away we can have home sharing on the devices and they can pick and choose what they want? and is this icloud going to make it harder to keep their devices seperate?

    My children have iphones, ipads, ipods and mac books, my problem is how do you use home sharing with the devices and not get each others data.  My Husband just added his iphone to the account and got all of my daughters contacts.  I understand they could have there own accounts but if i buy music on itunes and both children want the same song, I don't feel i should have to pay for it twice.  Is there away we can have home sharing on the devices and they can pick and choose what they want? and is this icloud going to make it harder to keep their devices seperate?

  • Iphoto crashing after using mini-dvi to video adapter

    Hi, IPhoto on my Macbook is crashing. I can open it, then as soon as I scroll down it locks up and I have to force quit.
    This started happening right after I used a Mini-DVI to Video Adapter cable to hook my macbook up to my TV. The adapter/s-video connection worked and I was able to see the video on the tv. But iphoto immediately locked up the computer when I went to slide show and now it locks every time I open it.
    Any ideas?
    Thank you:)
    Dorothy

    It means that the issue resides in your existing Library.
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.
    Regards
    TD

  • How do multiple family members use iTunes.? One account or multiple?

    How do multiple family members use iTunes. One account right now but apps gets added to all devices and iTunes messages go to all devices.  Can multiple accounts be setup and still have ability to share purchased items?

    Hey Ajtt!
    I have an article for you that can help inform you about using Apple IDs in a variety of ways:
    Using your Apple ID for Apple services
    http://support.apple.com/kb/ht4895
    Using one Apple ID for iCloud and a different Apple ID for Store Purchases
    You can use different Apple IDs for iCloud and Store purchases and still get all of the benefits of iCloud. Just follow these steps:
    iPhone, iPad, or iPod touch:
    When you first set up your device with iOS 5 or later, enter the Apple ID you want to use with iCloud. If you skipped the setup assistant, sign in to Settings > iCloud and enter the Apple ID you’d like to use with iCloud.
    In Settings > iTunes and App Stores, sign in with the Apple ID you want to use for Store purchases (including iTunes in the Cloud and iTunes Match). You may need to sign out first to change the Apple ID.
    Mac:
    Enter the Apple ID you want to use for iCloud in Apple () menu > System Preferences > iCloud.
    Enter the Apple ID you want to use for Store purchases (including iTunes in the Cloud and iTunes Match) in Store > Sign In. In iTunes 11, you can also click iTunes Store > Quick Links: Account.
    PC (Windows 8):
    Enter the Apple ID you want to use for iCloud in the Control Panel. To access the iCloud Control Panel, move the pointer to the upper-right corner of the screen to show the Charms bar, click the Search charm, and then click the iCloud Control Panel on the left.
    Enter the Apple ID you want to use for Store purchases (including iTunes in the Cloud and iTunes Match) in iTunes. In iTunes 10, select Store > Sign In. In iTunes 11, click iTunes Store > Quick Links: Account.
    PC (Windows 7 and Vista):
    Enter the Apple ID you want to use for iCloud in Control Panel > Network and Internet > iCloud.
    Enter the Apple ID you want to use for Store purchases (including iTunes in the Cloud and iTunes Match) in iTunes 10 in Store > Sign In. In iTunes 11, click iTunes Store > Quick Links: Account.
    Note: Once a device or computer is associated with your Apple ID for your iTunes Store account, you cannot associate that device or computer with another Apple ID for 90 days. Learn more about associating a device or computer to your Apple ID.
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

  • Using SQVI to generate report of open and released delivery schedule lines

    All,
    I'm using SQVI  to generate an excel spreadsheet for some buyers to show open released schedule lines because they are a 1 line item per scheduling agreement company.
    I used the logical database MEPOLDB instead of a table joint and pulled fields from EKKO(vendor, SA #,&purchasing group), EKPO(Material Number), EKEH(schedule line type), and EKET(delivery date, scheduled qty,previous qty).
    Does this sound like I'll get the results I want on paper as long as I use the right selection criteria, because the report I'm getting isn't quite what I expect? I am unable to identify which lines are authorized to ship vs. trade-off zone, planning, etc. in the report thus far.

    Hi Mark,
                 I have faced same requirement. I am not sure about transporting to TST and PROD. I done by this way.
    After generating SQVI program in DEV , I assigned that program  to a transaction and tested in DEV. Later i have regenarated SQVI in Production. then I assigned the generated Program to same transaction in DEV. And transported the Tcode assignment of program to Production..
    About authorization , if its not sensitive report, BASIS can restrict at transaction level.
    Regards,
    Ravi.

Maybe you are looking for

  • IPad has suddenly started showing all images as "negatives"?? How do I get it back to normal??

    iPad has suddenly started showing all images as "negatives"?? How do I get it back to normal??

  • No Basic/Advanced Mode with Adjustment Brush

    I have LR3 and can't make any changes using the Adjustment Brush.  I can highlight an area (and change colors of the overlay) but that's it...any ideas on what I'm doing wrong?  I also have no Basic/Advanced switch... thanks

  • Exchange Server Sizing - Online Users

    I am able to use the Exchange server sizing spreadsheet to determine server size, disk IOPS, memory capacity but it assumes that all users are in cached mode.  How do I calculate if all of my users are using online mode.  This is a setup where we can

  • Applescript photoshop open file delay

    Hi, I have a problem with photoshop and applescript. When I run the following simple applescript which opens a document and saves it in a location: tell application "Adobe Photoshop CS3" open picpathalias -- delay 10 -- quite a long delay is needed s

  • Unlocking OID User Through OIM

    Hi all, I am testing an OID User Process task in OIM which can be run on a user's OIM account and unlock a locked user in OID However, I am getting the following error after executing the task: ERROR 11:54:51,375, RMICallHandler-113 XL_INTG.OID - ===