Sequence PK generation is messed up after table import

Thought I'd post this here where the possibility of direct object manipulation is what it needed.
Recently created new 10.2.0.1.0 database on new machine as a copy of one running on another machine. Installed Apex 2.2 and used the data import feature within to transport tables from the one machine to the new one. All tables were imported exactly as they were in the original DB. Primary Keys and column types are set exactly the same as the orig along with exact same AUTOID_PK column definition. New sequence was created and associated with correct PK column as in orig. Data import was all successful.
Then imported the associated Apex Application from orig DB, exported as 2.2 into new 2.2 Apex.
Problem occurs now when attempting to add new records, getting a PK violation apparently due to duplicate keys being created at insertion time from the PK's associated sequence.
I've done this same procedure in the past and not had this problem.
Using SQL Developer to look at the associated PK index I see that the index sees 205 distinct keys, 205 rows, and a sample size of 205.
++++ Does the problem stem from the next sequence value being generated is 206 ???? +++
I'm not a pro with the functionality of Oracle as you may be able to tell.
The duplicate AUTOID value may come from the fact that although there are only 205 records and 205 distinct different AUTOID values, the values themselves do not run from 1 to 205 since there have been many deletions and additions. The highest value in the AUTOID field is 376, and I would assume the sequence needs to start generating the next value from 377 forward so as not to cause this PK violation.
That is just a deduction rather than possible fact, can anyone help with identifying the problem if I'm wrong, and can I get some help correcting this so I can continue on from where I left off?
This is a problem in 2 tables at the moment, shouldn't be any more.
Thanks to anyone who can help.
Jacob

If I understood you correctly, sequences were precreated on target db before running import. If so, that is where problem was created. Oracle exports sequence definition not with original START WITH value but rather with START WITH last_number. This ensures imported sequence will not generate already generated values. You, most likely, precreated sequences with START WITH 1 and used imp with IGNORE=Y. As a result sequences started to generate duplicate values.
SY.

Similar Messages

  • Sequence error after table import

    I swear I'll never cross post again, this is also in PL/SQL but after reading it it appears the responses I'll get there are geared more towards someone using sql plus.
    Had an app, tables & sequences running fine in 2.2 on one machine. Set up another machine to mirror working version with Apex 2.2. Imported tables into new tables on target, created sequences during import that mirror original tables and sequences.
    Sequence populates into AUTOID column as in orig. When attempting to insert a new record I get a primary key violation. If I hit the back button and resubmit the page it accepts the record. When I look into the pk index I see 205 unique keys and 205 records. This record count is correct but there have been deletions and additions to this table in the orig database and thus new AUTOID values were generated and the values in the target table are not linear from 1to205. They skip around and the highest is actually now 266.
    Is this problem due to the sequence seeing 205 unique keys and generating the next one at 206, which already exists in the table?
    If so, why can I back up to the form and successfully resubmit?
    At any rate, anyone have an idea how to correct this or change the sequence starting number to something higher than anything in the table so I don't have to deal with this?
    Thanx
    Won't cross post again :)

    I did notice though that when I start a table off with a column named AUTOID as a number Apex seems to pick that column as default when I create a sequence.
    Probably because it's the 1st column in your table. The name being "AUTOID" doesn't mean anything to ApEx.
    When I look at the structure of the sequence I still don't see where in the sequence it finds what number to pull next. I do see that it selects from dual, which I never understood the purpose of anyway, but I don't see how the next number is determined. Is that where the cache comes in? Does it save 20 numbers and just keep decrementing?
    If you use the ApEx Object Browser, you can see the last value of the sequence.
    In order to get the next value of the sequence, you have to SELECT it from something. DUAL is typically used because it always has 1 column & 1 row. Thus, you can guarantee that a statement such as this:
    select my_sequence.nextval from dual
    Will always bring back 1 row - which will be the next value of the sequence.
    The "20" which you are referring to is the number of values it will cache in memory. This is why you may see gaps of 20 in your sequences - depending on the load of the Database, the values may get flushed out of the cache.
    Again - sequences are guaranteed to be unique - you will almost always have gaps.
    Thanks,
    - Scott -

  • Enq: TX - row lock contention in forms 10g sequency number generation

    Iam Getting the Deadlock issue in oracle formdeveloper 10g database is 11g Acutually in our small Hospital organization using different forms generating entrying labrequest form finally save time
    one sequency number will generated i have give procedure below every save criteria form using below procedure some time iam getting lock iam using blocksession query i have find out some
    OSUSER
    MACHINE
    TERMINAL
    PROGRAM
    SQL_ID
    LOGON_TIME
    BLOCKING_SESSION_STATUS
    BLOCKING_SESSION
    EVENT
    user423
    UMCCDOM\LEVEL4-MICU
    LEVEL4-MICU
    PrjMcr.EXE
    0ccngw7dfkmgb
    23/09/2013 11:34:41 AM
    VALID
    277
    enq: TX - row lock contention
    SYSTEM
    WORKGROUP\PRIAPPSVR
    PRIAPPSVR
    frmweb.exe
    0ccngw7dfkmgb
    23/09/2013 11:32:50 AM
    VALID
    186
    enq: TX - row lock contention
    SYSTEM
    WORKGROUP\PRIAPPSVR
    PRIAPPSVR
    frmweb.exe
    0ccngw7dfkmgb
    22/09/2013 2:49:47 PM
    VALID
    277
    enq: TX - row lock contention
    SYSTEM
    WORKGROUP\PRIAPPSVR
    PRIAPPSVR
    frmweb.exe
    0ccngw7dfkmgb
    23/09/2013 7:00:22 AM
    VALID
    186
    enq: TX - row lock contention
    user290
    UMCCDOM\LEVEL2-N
    LEVEL2-N
    PrjMcr.EXE
    0ccngw7dfkmgb
    23/09/2013 10:28:06 AM
    VALID
    277
    enq: TX - row lock contention
    lock are happen after open the code i have find out used FOR UPDATE in procedure please tell me any alternative for this every labrequest form saving time using this procedure for generating prefix sequence number multiple user using with different systems
    PROCEDURE   Gsp_GenSeqNum (I_SvPrefixCd IN VARCHAR2,I_SvUserName IN VARCHAR2,
                              O_SvSeqNum OUT VARCHAR2) IS
    --This Procedure generates the sequence number
    --by retrieving the prefix based on the code
    --supllied to the procedure.
      CURSOR  crSeqGenerator IS
             SELECT Gsn_prefix_last_num, Gsn_prefix_year
                FROM G_SEQUENCE_NUMBER
             WHERE Gsn_prefix_Cd = I_SvPrefixCd
                   AND Gsn_prefix_year = TO_CHAR(SYSDATE,'YYYY')
      FOR UPDATE OF Gsn_prefix_last_num;
      udSeqNum        G_SEQUENCE_NUMBER.Gsn_Prefix_last_num%TYPE;
      udNextSeqNum    G_SEQUENCE_NUMBER.Gsn_Prefix_last_num%TYPE;
      udYear          G_SEQUENCE_NUMBER.Gsn_Prefix_year%TYPE;
      udPrefix        G_SEQUENCE_PREFIX.Gsp_Prefix_Value%TYPE;
    BEGIN
      SELECT Gsp_Prefix_Value
      INTO udPrefix
      FROM G_SEQUENCE_PREFIX
      WHERE Gsp_Prefix_Cd = I_SvPrefixCd;
      OPEN crSeqGenerator;
      FETCH crSeqGenerator
       INTO udSeqNum,
            udYear;
      IF crSeqGenerator%FOUND THEN
         udNextSeqNum  :=udSeqNum + 1;
         O_SvSeqNum     := udPrefix||'/'||TO_CHAR(SYSDATE,'YY')
                                   ||'/'||LPAD(TO_CHAR(udNextSeqNum),6,'0');
      ELSE
    INSERT INTO G_SEQUENCE_NUMBER VALUES(I_SvPrefixCd,TO_CHAR(SYSDATE,'YYYY'),0,I_SvUserName,SYSDATE);
         udSeqNum      :=0;
         udNextSeqNum  :=udSeqNum + 1;
         O_SvSeqNum:=UdPrefix||'/'||TO_CHAR(SYSDATE,'YY')
                             ||'/'||LPAD(TO_CHAR(udNextSeqNum),6,'0');
      END IF;
      UPDATE G_SEQUENCE_NUMBER
         SET Gsn_Prefix_last_num=udNextSeqNum
       WHERE Gsn_Prefix_Cd = I_SvPrefixCd
         AND Gsn_Prefix_year=TO_CHAR(SYSDATE,'YYYY');
      CLOSE crSeqGenerator;
    END Gsp_GenSeqNum;
    Thanks
    subbu

    This application is inbuit with some modules VB (cath ,cardio)and oracle forms for required sequence number generation different time used this procedure whereever required the sequence Prefix generation.If i replace the procedure sequene to oracle standard sequency if the user cannot save the form unnessary sequency generated order is missing from sequence.

  • How to call a javascript method after table load on JSFF Fragment load?

    Hello,
    The usecase is to invoke a javascript method after table is done loading (fetching data) when user lands to a JSFF fragment. With JSPX pages I can achieve that by using PagePhaseListener. I have tried with RegionController as follows, and the problem i face is that I cannot prevent multiple calls to the Javascript call when user presses a tab or button in a screen, or changes drop-down value with autosubmit on.
    import javax.faces.context.FacesContext;
    import oracle.adf.model.RegionBinding;
    import oracle.adf.model.RegionContext;
    import oracle.adf.model.RegionController;
    import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
    import org.apache.myfaces.trinidad.util.Service;
    public class MyListener implements RegionController{
    public MyListener() {
    super();
    @Override
    public boolean refreshRegion(RegionContext regionContext) {
    int refreshFlag = regionContext.getRefreshFlag();
    System.out.println("Render flag is: "+refreshFlag);
    if (refreshFlag == RegionBinding.PREPARE_MODEL)
    initializeMethod();
    regionContext.getRegionBinding().refresh(refreshFlag);
    return false;
    public boolean validateRegion(RegionContext regionContext) {
    regionContext.getRegionBinding().validate();
    return false;
    public boolean isRegionViewable(RegionContext regionContext) {
    return regionContext.getRegionBinding().isViewable();
    public void initializeMethod() {
    FacesContext f = FacesContext.getCurrentInstance();
    ExtendedRenderKitService service = Service.getRenderKitService(f, ExtendedRenderKitService.class);
    service.addScript(f, "myJSFunction();");
    @Override
    public String getName() {
    return null;
    I need the javascript to be called only once after the table is done loading when user lands to a fragment (jsff).
    Any ideas appreciated?
    JDeveloper version is 11.1.1.5.0
    Thank you.
    Valon
    Edited by: Valon on Apr 11, 2013 3:10 PM

    One of the requirements is to compare every row with the next row and highlight the changes. There are other requirements as well where JavaScript solution is used.
    The question remains the same. Is it doable or not without changing the solution from JavaScript solution to server-side solution ? Can we call a JavaScript only once when the user lands to a jsff fragment ?
    Hope that is clear.
    Thanks.
    Valon

  • My computer no longer seesmy 3rd generation ipod nano.  after following the on line directions to re-install I get a message it is ok to discinnect instead of do not disconnect.  how to I get the ipod back onto my computer?

    my computer no longer seesmy 3rd generation ipod nano.  after following the on line directions to re-install I get a message it is ok to discinnect instead of do not disconnect.  how to I get the ipod back onto my computer?

    Hello rh3362,
    I would start with this:
    http://support.apple.com/kb/TS1369
    Hope this helps.
    ~Julian

  • I have a 3rd generation nano ipod and after connecting it to my mac to sync my calendar, it said it no longer would sync the calendar.  What's up with that???

    I have a 3rd generation nano ipod and after connecting it to my mac to sync my calendar, it said it no longer would sync the calendar.  What's up with that???

    Thanks Bob, I don't know why but it all of a sudden worked a few days later. It's a mystery but at least problem solved.

  • Management Studio 2008 does not refresh after table create / alter

    hello
    Management Studio 2008 does not refresh after table create / alter, why?
    f5 / refresh button does not work in "Object Explorer".... i always need the restart the whole application to see any changes, this is strange...
    regards, jan

    Hi jm,
    I’m writing to follow up with you on this post. Was the problem resolved after performing Vishal ‘s steps? If you are satisfied with our solution, I’d like to mark this issue as "Answered". Please also feel free to unmark the issue, with any new findings
    or concerns you may have.
    Thanks,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Finding missed sequence numbers and rows from a fact table

    Finding missed sequence numbers and rows from a fact table
    Hi
    I am working on an OLAP date cube with the following schema:
    As you can see there is a fact transaction with two dimensions called cardNumber and Sequence. Card dimension contains about three million card numbers. 
    Sequence dimension contains a sequence number from 0 to 255. Fact transaction contains about 400 million transactions of those cards.
    Each transaction has a sequence number in 0 to 255 ranges. If sequence number of transactions of a card reaches to 255 the next transaction would get 0 as a sequence number.
    For example if a card has 1000 transactions then sequence numbers are as follows;
    Transaction 1 to transaction 256 with sequences from 0 to 255
    Transaction 257 to transaction 512 with sequences from 0 to 255
    Transaction 513 to transaction 768 with sequences from 0 to 255
    Transaction 769 to transaction 1000 with sequences from 0 to 231
    The problem is that:
    Sometimes there are several missed transactions. For example instead of sequence from 0 to 255, sequences are from 0 to 150 and then from 160 to 255. Here 10 transactions have been missed.
    How can I find all missed transactions of all cards with a MDX QUERY?
    I really appreciate for helps

    Thank you Liao
    I need to find missed numbers, In this scenario I want the query to tell the missed numbers are: 151,152,153,154,155,156,157,158,159
    Relative transactions are also missed, so I think it is impossible to get them by your MDX query
    Suppose this:
    date
    time
    sequence
    20140701
    23:22:00
    149
    20140701
    23:44:00
    150
    20140702
    8:30:00
    160
    20140702
    9:30:00
    161
    20140702
    11:30:00
    162
    20140702
    11:45:00
    163
    As you can see the sequence number of the last transaction at the 20140701 is 150
    We expecting that the first transaction of the next day should be 151 but it is 160. Those 10 transactions are totally missed and we just need to
    find missed sequence numbers

  • Need help with HR_INFOTYPE_LOG_GET_DETAIL, before/after tables

    Greetings experts:
    I've searched SDN for assistance with this question before posting but haven't been able to find anything to address my specific question which is, how do I "convert" the data that is in the before and after tables returned by this FM into the appropriate structure?
    I tried concatenating all of the data in DATA1-DATA7 into a string and then using ASSIGN to CAST it into a structure of type P0167 (the particular record I was looking at in PCL4 was a change to this infotype).  I noticed, however, in debug that the data just didn't look right, i.e., the DATA1 began with BAREA but there are many other fields ahead of this in P0167 so it's no wonder when this code executed I got garbage in my data object typed as P0167.
    Any advice would be appreciated!

    Hi Jamie
    Just check that 'FIELD' table is optional/mandatory.
    Also cross-check for 'type' of Exporting/tables parameters with the parameters that you are supplying
    Regards
    Ashish Jain

  • Ipod nano 6th generation discharges 4 hours after full charge-what can be done?

    ipod nano 6th generation discharges 4 hours after full charge-what can be done?

    i have the problem it will barely tuen on after 5 hours of charging and i think the battery is duff, ive barely used this thing and am really disappointed

  • Ipod touch 4th generation became too slow after ios 6. How can I rollback to iOS 5 or what else can be done. I already did  master reset and restored to factory default but no improvement.

    Ipod touch 4th generation became too slow after ios 6. How can I rollback to iOS 5 or what else can be done. I already did  master reset and restored to factory default but no improvement.

    You cannot downgrade

  • How to generate a  number sequence for a column of a Z*table?

    Hi ,
    How to generate a  number sequence for a column of a Z*table?
    plz guide me.
    thanks
    Albert

    1) Use SNRO for defining a number range.
    2) Use FM NUMBER_GET_NEXT for getting the next number with object, sub object etc..
    See one example below.
          CALL FUNCTION 'NUMBER_GET_NEXT'
            EXPORTING
              nr_range_nr                   = c_01
              object                        = c_z_prd_code
    *           QUANTITY                      = '1'
             subobject                     = p_vkorg
    *           TOYEAR                        = '0000'
    *           IGNORE_BUFFER                 = ' '
           IMPORTING
             number                        = in_prd_code
    *           QUANTITY                      =
    *           RETURNCODE                    =
            EXCEPTIONS
                  interval_not_found            = 1
                  number_range_not_intern       = 2
                  object_not_found              = 3
                  quantity_is_0                 = 4
                  quantity_is_not_1             = 5
                  interval_overflow             = 6
                  buffer_overflow               = 7
                  OTHERS                        = 8
    3) You may write these code in main program of the table maintinence
    rgds,
    TM.

  • On generation of an idoc which tables gets updated?

    friends on generation of an idoc which tables gets updated?(other than edidc,ediddd,edids
    ,rfcdes).

    HI Raja,
        YOu can just go to SE11 transaction.
    Type EDI* and press F4. You would get a list of all the EDI tables(Usually all IDOC related tables start with EDI ).
    In case you do not have system access: here are some more:
    EDICONFIG                      Parameter Table for User-specific Configur
    EDID2                          IDoc Data Record from 3.0C onwards       
    EDID3                          IDoc Data Record from 3.0 onwards        
    EDID4                          IDoc Data Records from 4.0 onwards       
    EDIDC                          Control record (IDoc)                    
    EDIDD_OLD                      IDoc Data Record                         
    EDIDO                          Value table for IDoc types               
    EDIDOCINDX                     Control record (IDoc)                    
    EDIDOT                         Short description of IDoc types          
    EDIDS                          Status Record (IDoc)                     
    EDIE5                          Assign logical address to physical destina
    EDIFCT                         IDoc: Assignment of FM to log. message and
    EDIFM                          IDoc: Function modules for creating file n
    EDIFMT                         IDoc: Text table for EDIFM (funct. module
    EDILOGADR                      Assign logical address to physical destina
    EDIMAP                         EDI: Assignment Table Between IDoc and App
    EDIMSG                         Output Types and Assignment to IDoc Types
    EDIMSGT                        Short description of SAP message types   
    EDIPHONE                       Telephony Data for Partner Profiles      
    EDIPO                          Table for description of ports for EDI   
    EDIPO2                         Table for R/2 Port Definitions           
    EDIPOA                         Table for ALE Port Definitions           
    EDIPOD                         Table for File Port Definitions          
    EDIPOF                         Ports for ABAP programming interface     
    EDIPOI                         Table for describing Internet ports      
    EDIPORT                        Summary Table for all Port Types for IDoc
    EDIPOX                         Table for Description of XML Port        
    EDIPOXH                        Table for XML HTTP Port Description      
    EDIPOXU                        Conversion of special characters for XML 
    EDISDEF                        IDoc Development : IDoc Segment Definition
    EDISEG                         EDI: IDoc Segments with Assignment to Segm
    EDISEGMENT                     IDoc Development : IDoc Segment          
    EDISEGT                        EDI: Short Description of IDoc Segments  
    EDISYN                         Syntax Description for Extended Basic Type
    EDI_CNVBAS                     Conversion Table for Basic Types         
    EDI_CNVDOC                     Conversion Table for Field DOCTYP        
    EDI_CNVEXT                     Conversion Table for Extensions          
    EDI_CNVMES                     Conversion Table for Logical Message Types
    Regards,
    Ravi

  • XFCE4 Desktop messed up after upgrade

    Hi
    After upgrading to the latest XFCE Desktop - using pacman -Syu last friday - my XFCE Desktop ist totally messed up after restarting:
    . mouse cursor is displayed as cross instead of xfce pointer
    . windows do not have decoration and title bar
    . there are no more multiple desktops
    . keyboard shortcuts are no more working
    . menubar on several apps like thunderbird or firefox is not working
    . new windows are always placed on top left of the screen
    . more to find...!!
    In shorter words: the desktop is unusable. I deleted .config/xfce4, but this did not help anything. What can I do to quickly restore my desktop to a working state?
    Thanks, melman

    Thanks for your reply. That solved the problem. I just started xfwm4 in a terminal and now everything works fine. Even after restarting XFCE4.

  • Error while importing text file to Power Pivot via Table Import Wizard

    Hello there,
    I'm a rookie at handling Excel to be honest. I've been trying to import a .txt file to Excel (it contains around 14 million rows of information) but Excel won't let me since it can only handle around 1 million rows per sheet (too troublesome to do such thing
    14 times in 14 different sheets). Then I googled that Power Pivot let me handle around 100 million rows in a Pivot.
    I'm trying to import this .txt file to Power Pivot by doing the following:
    Home tab > From Text > File Path (insert .txt location here) > Finish
    After that it shows the Table Import Wizard retrieving the rows from the .txt file. Problem is... at the end of the import (once it hits row 14,000,000 or so) it shows an error. It states the following:
    "Memory error: Allocation failure : Not enough storage is available to process this command. .
    The current operation was cancelled because another operation in the transaction failed."
    Please note that the size of the .txt file is 900 MB.
    Another thing is that, when I select the .txt file from its location at the File Path section, the "preview" field only shows 50 rows, not all of them. Is that okay to happen?
    Is it because the size of the .txt file is too big?
    Please let me know if you need more info in regards to this.
    Thanks in advance.

    Hi AdiUser,
    Only showing 50 rows for the preview is normal behaviour. Based on what you've described, it sounds like Power Pivot is running out of memory when you are loading this .txt file. Are you running the 32 bit or 64 bit version of Excel. Also, if you are running
    the 64 bit version how much RAM is available?
    If you're running the 32 bit version then the available RAM for Power Pivot is less than 1 GB even if the system has more than this installed. You can address this by installing the 64 bit version. If you're running the 64 bit version then it may be
    that you don't have enough RAM to accommodate this amount of data and you may consider upgrading the RAM. Alternatively, you could try and reduce the size of the table in memory by using the preview screen to remove any columns that are not of use. This
    is especially important if there are any column with a high number of unique values that aren't actually needed in the model. In addition to removing columns altogether, you could try filtering the data so that only a subset of the rows are imported.
    This can also be done from the preview screen.
    Regards,
    Michael Amadi
    Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to vote it as helpful :)
    Website: http://www.nimblelearn.com
    Blog: http://www.nimblelearn.com/blog
    Twitter: @nimblelearn

Maybe you are looking for

  • Install DVD in Chinese

    Hey everyone, I just installed SL last night without so much as a hiccup. Everything works and I got an astonishing 26gb back! My question is probably very easily answered so forgive me if it seems dumb. When I mounted the install disc, the user agre

  • Error in INTEGRATION_DIRECTORY_HMI and CACHE REFRESH

    Hi guys, well after checking the forum and several blogs i can't get rid of my problem! I have a problem concerning INTEGRATION_DIRECTORY_HMI and CACHE REFRESH. i wanted to get a file from a FTP-Server via CC and i got error:   <SAP:AdditionalText>Er

  • Newbie: How do i use a stateless session bean in a backing bean?

    I have a stateless session bean with a function 'getVoterList()'; how do i instantiate the bean and use it in from my managed bean? I dont want to use seam; coz the stateless serrion bean/EJB is written by another developer and we cant updat eit now

  • Using LDAP as security realm

    Hi, Our goal is to use LDAP(Iplanet Directory Server 5.0) as a security Realm for Weblogic Personalization and Commerce 3.5. Using the WLCS console, I've modified the config.xml file and following elements are added: <LDAPRealm AuthProtocol='simple'

  • Notification sounds in 3rd party apps

    I'd like to use different notification sounds for Facebook and my news apps. Can this be done in iOs 5?