How handle currval if nextval fails

hi,
i have to insert the following rows in the table if
Insert into BOOK (BOOK_ID, CNT, ALT_CNT, ROW_INSERT_TMSTMP, ROW_LAST_UPDT_TMSTMP, BOOK_ID,VERSION)
SELECT SEQ_BOOK_ID.nextval, 50 , 500 ,sysdate,sysdate, '123456xyz' ,1 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM BOOK B WHERE b.BOOK_ID = '123456xyz' );
Insert into BOOK_OWNER (BOOK_OWNER_ID, BOOK_ID, USER_ID,VERSION)
SELECT SEQ_BOOK_OWNER_ID.nextval, SEQ_BOOK_ID.currval, '30327def',1 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM BOOK_OWNER AO WHERE AO.USER_ID= '30327def');
commit;
in above #1st statement checking if the value exists in book and inserting if the first insert fails the secound insert statement uses the "SEQ_BOOK_ID.currval" of the parent. if #1 insert fails how to handle the currval of the secound statement?
using oralce 10g

Hi,
[email protected] wrote:
also would like to know in anyof the condition the nextval will fail? i mean for some of the records insertion in getting the primery key violation.
like i am doing one time migration with huge data in to the database around 200 to 300 similar insert statements and some times i am getting the primery key voilation i suspect nextval is failing not able to figure it out.That sounds like some rows were entered with a primary key that was not generated by the sequence.
You should change the sequence so that it is generating numbers higher than anything already in the table.
First, find out what the highest id in the table is. For example:
SELECT  MAX (book_id)
FROM    book;Say this tells you that book_id=12345 is already in the table. Now find out how high the sequence is. For example:
SELECT  seq_book_id.NEXTVAL
FROM    dual;Say this returns 12000, which means you have to add 345 to the sequence.
You don't want to drop and re-create the sequence; that might make procedures invalid, or lose grants.
You could reference .NEXTVAL 345 times, or you could say:
ALTER SEQUENCE  seq_book_id  INCREMENT BY 345;
SELECT  seq_book_id.NEXTVAL
FROM    dual;
ALTER SEQUENCE  seq_book_id  INCREMENT BY 1;This assumes the sequence had originally been incrementing by 1.
The problem is liable to keep happening as long as the table is incremented without using the sequence.
You can add a trigger to guarantee that the sequence is used.

Similar Messages

  • How do I restore a failed external hard drive using Time Machine?

    I have an external hard drive connected to my iMac that is being backed up with Time Machine.  I just realized that should it one day fail and no longer appear as a connected device, I'm not sure how to restore its data to another external drive.  When I disconnected the external hard drive (to mimic a drive crash) and entered Time Machine to see if I could verify that the external hard drive was, in fact, being backed up - I didn't know where to find it.  Under the Today (Now) information, I didn't expect to see it there as it was no longer connected to the machine.  But when I went back a few days, I expected to see its backup appear in the Sidebar.  But no!
    So - how do I restore a failed external hard drive using Time Machine?
    Searches for this information on Google yielded "iffy" results.  I'm hoping someone here is able to offer some clear steps to follow.  Perhaps I'm missing something silly.  Thank you very much!

    I came across this discussion after encountering the same problem. Since my internal HD was cose to full I added an additional external HD to my setup. I moved my iPhoto files to an external HD and backed both this external HD and my internal HD up with Time Machine to another external HD. So far the theory. When I wanted to test if this setup worked I noticed that I could only see my iPhoto libraries on the external HD in Time Machine when the external HD was connected to my computer, but not if I turned it off. This led me to search for a solution on the Apple Support Communities discussion board.
    The suggestions made Kappy seem right, at least in my experience, in that my Time Machine simply did not back up the external HD until I followed the steps he suggested above. These were the following:
    "So, if you want it backed up then here's what you need to do:
    1. In Time Machine preferences remove the external drive from the Exclude list.
    2. Verify that it is now included with your other drive in the backup list.
    3. Do a Backup Now to create a new backup of the external drive."
    After doing this, my external HD showed up in the Backups.backupd as a seperate folder. I could clearly see the Time Machine back-up for my internal HD and my external HD. In addition, in Time Machine itself I was able to find the external harddrive by clicking on my own computers name under "Devices". I hope my experience helps to resolve your issue as this discussion board has helped me resolve mine (which I believe to be very similar).
    Cheers!

  • How Do You Restart a Failing Load Plan

    If a Load Plan step fails, say because of some bad data or a bad join, I know how to correct the error and restart the failing step or the failing task in the Operator.
    How do you restart the failing Load Plan or any higher level step in the Operator?
    Right now my Load Plan steps all say 'Restart from failed task'.
    I can't see the Load Plan itself in the Operator, so I can't restart it directly.

    In the Operator, there is an accordion section labeled "Load Plan Executions". You can restart from there.
    Regards,
    Michael Rainey

  • How to make scheduled jobs Fail if the return partial results?

    How to make scheduled jobs Fail if the return partial results?
    Does anyone know if there is a way to do this?
    We have a number of reports that we schedule to various locations in Excel and PDF. We are frequently getting problems which are manifesting themselves as empty data providers and if we run them as Web Intelligence reports it says Partial Results. Re running the reports normally fixes the problem and returns the data correctly but the problem is that the scheduler reports them as successful and the emails or files get distributed (causing our customers to complain!!!).
    Currently using XIr2 +SAP integration Kit migrating to XI 3.1 in July 2009
    Any ideas/suggestion would be appreciated...
    I did find reference to the adapt case ADAPT01122128 which may help but when and if are unkowns so not much help.
    Ta
    Nick

    This may be helpful to some people:
    http://blogs.sun.com/milan/entry/using_web_service_to_send

  • What are the ways to handle Idocs which are failed to post to R/3

    Hi Experts
    What are the ways to handle Idocs which are failed to post to R/3  after sucessfully configuration of the Scenario.
    Thanks & Regards
    Aravind

    Hi
    Check the Idoc Status in R/3 with WE05.
    Idocs will fail in following conditions
    1) Idoc will be in error if all the mandatory field are not mapped.
    2) If partner profile is not maintained.
    3) Most of the times, idocs will be in error due to functional issues.....check the status and take help from functional guys.
         Once the error resolved, reprocess the same idoc using BD87
    Regards
    Abhijit
    Edited by: Abhijit Bolakhe on Mar 18, 2010 3:11 PM

  • How do I remove one failing hard drive from raid set and replace with new one

    Last Friday apparently one of my raid drives started failing.
    As I mentioned on this forum I started getting continous beeping.
    I was finally able to get the raid working at a degraded level.  I ordered a replacement hard drive which is arriving today.
    (In the meantime I made twice daily backups of my work.....)
    Below was the message I got from the browser based raid software:
    Blahblah 09    1000.2GB   RaidSet Member SamSung HD103SJ
    Blahblah 10    1000.2GB     Free                 SamSung HD103SJ
    Blahblah 11    1000.2GB   RaidSet Member SamSung HD103SJ
    Blahblah 12    1000.2GB   RaidSet Member SamSung HD103SJ
    (See this earlier thread if you wish!)
    http://forums.adobe.com/thread/727867?tstart=0
    At one point when I did the checked the browser interface I saw the message Failed and Degraded
    As I said, I was able to work over the weekend on the degraded system.
    This morning I got the beeping again and did the rescue and now I am running a "full raid" without the notice that one raid was "Free".
    In any case, the new hard drive is arriving today.
    What steps should I take to incorporate the new drive into the raid system.
    I have one OS drive
    and 4 tb raid drives.   One needs to be replaced with the new one that I am getting today.
    Thanks
    Rowby

    Harm,
    Regarding your comment:
    Re: How do I remove one failing hard drive from raid set and replace with new one
    Please tell me how to read the serial number from an individual drive rather easily, without un-installing them:
    If you select the proper drive to change out, you only need to remove one drive and look at its serial number...
    Step 1: Identify bad drive serial number using Areca's tools
    Step 2: Turn off the computer
    Step 3: Remove what you think is the bad drive based on following your numbered cable method, marked hot-swap bays, whatever
    Step 4: Verify that the serial number matches the "bad drive" serial number from step 1; if it does great, proceed; if it does not match, go back to step 3
    Step 5: Change out the CORRECT drive - that's the bottom line for this whole procedure
    Cheers,
    Jim

  • How get Visual Composer deployment failed log?

    hi,expert
    i  compiled Visual Composer iView successfully,but deployment failed.Visual Composer prompt Error in compiling Flex application (1). Consult log file for details.
    How get Visual Composer deployment failed log?Why Visual Composer Compiled Successfully,but deployment failed?
    thanks.

    Hi,
    See the note <b>974494</b>
    This note will guide you how to see the errors in Visual composer screen if compilation fails , while deploying the application.
    If your OS for Enterprise portal is UNIX , then see the <b>Note 886209 - Flex compilation error on Unix Machines</b>
    With Regards,
    Hari

  • But NOT know how handle figure element in old browsers, well?

    dw cs6
    http://www.ancientgreekdramainstitute-cyprus.org/gallery.html
    here I have a gallery but in Chrome or other modern browse like ie9+/firefox/opera/safari appear OK, in ie8 is a mesh... I have a special css for
    browsers<=ie8, but NOT know how handle figure element in old browsers, well?

    <link rel="stylesheet" href="../css/3col-responsive.css" media="screen" />
    <!--[if (lt IE 9) & (!IEMobile)]>
    <link rel="stylesheet" href="../css/3col-responsive-ie-old.css" />
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link rel="stylesheet" href="../css/3col-responsive-print.css" media="print" /><link href="../css/css_all.css" rel="stylesheet" type="text/css" />
    this is correct? better include and print css 3col-responsive-print.css inside <!--[if (lt IE 9) & (!IEMobile)]>...last line inside...?
    i will check if work in ie6-ie8 soon although i uploaded code... i mean the gallery.html and figure element...

  • How can i get a failed down load to re-try?

    does anyone know how i can get a failed down load of excel to re-try?  My excel is now messed up and I think it's related to this situation.  thanks for any help

    You can add a table that provide a list of items (that are in the pop up menu) and a corresponding value (shown on the right):
    In the table on the left you can refer to the table "Price List" to locate the item in column A, then retrieve the corresponding value from column B.
    B2=VLOOKUP(A2,Price List::A:B,2,0)
    this is shorthand for... select cell B1, then type (or copy and paste from here) the formula:
    =VLOOKUP(A2,Price List::A:B,2,0)
    select cell B2, copy
    now select column B, then unselect cell B1, by holding the command key and clicking cell B1
    paste
    change the pop-up menus in column A as needed.

  • How can i get the failed row numbers in batch insertion?

    Afeter execution of batch insert operation into a table, i use OCIAttrGet() to get the error number of insertion, as expected, it returns the correct number. however, when i use OCIParamGet() to get an error handle and then to get the exact failed row numbers , OCIParamGet() returns -2 , means "INVALID_HANDLE". can anyboy tell me why ? how can i get the exact failed rows?
    the snapshot of my code :
    int errNum = 0;
    int nRet = 0;
    nRet = OCIAttrGet((dvoid *)m_pIIOdbc->m_pStmtAll,OCI_HTYPE_STMT,&errNum,
              0,OCI_ATTR_NUM_DML_ERRORS, m_pIIOdbc->m_pErrHandle);
    if (errNum)
         OCIError* pErrHndl;
         int* pRow_off = new int[errNum];
         for (int i = 0; i < errNum; i++)
         nRet = OCIParamGet(m_pIIOdbc->m_pErrHandle,
    OCI_HTYPE_ERROR, m_pIIOdbc->m_pErrHandle, &pErrHndl, i + 1);
         nRet = OCIAttrGet (pErrHndl, OCI_HTYPE_ERROR, &pRow_off, 0,
         OCI_ATTR_DML_ROW_OFFSET, m_pIIOdbc->m_pErrHandle);
              delete []pRow_off;

    now the code is :
    OCIEnv      *m_pEnvHandle;                    
    OCIError      *m_pErrHandle;                         
    OCIError     *m_pErrHandle2;                    
    OCIServer *m_pSrvHandle;                         
    OCISvcCtx *m_pSvcHandle;                         
    OCIStmt *m_pStmtExec;
    OCIStmt *m_pStmtAll;
    OCIError** m_pErrorHndl;     
    int* m_pRowOff; //the array that will contain the failed row numbers
    int     m_nArrayLength; //length of array in once batch operation
    int m_nErrNum; //error number
    int m_nSucCount; //successful record number
    //initialization
    //m_nArrayLength is a parameter passed in, so i can not tell the exact length of the array, dynamic space allocation is needed
    m_pErrorHndl = new OCIError*[m_nArrayLength];
    m_pRowOff = new int[m_nArrayLength];
    //execution
    OCIStmtExecute(
              m_pSvcHandle,
              m_pStmtAll,
              m_pErrHandle,
              (ub4)m_nArrayLength,
              (ub4)0, (OCISnapshot *)NULL, (OCISnapshot *)NULL,
              OCI_BATCH_ERRORS
    //get successful records number
    m_nSucCount = 0;
    OCIAttrGet((dvoid *)m_pStmtAll,OCI_HTYPE_STMT,&m_nSucCount,
              0,OCI_ATTR_ROW_COUNT, m_pErrHandle);
    //get error numbers
    m_nErrNum = 0;
    OCIAttrGet((dvoid *)m_pStmtAll,OCI_HTYPE_STMT,&m_nErrNum,
              0,OCI_ATTR_NUM_DML_ERRORS, m_pErrHandle2);
    //get failed row numbers into the array
    if (m_nErrNum)
              //get failed row numbers into the array
              for (int i = 0; i < m_nErrNum; i++)
                   //initiallize error handles               OCIHandleAlloc((dvoid*)m_pEnvHandle, (dvoid**)&m_pErrorHndl,
                        OCI_HTYPE_ERROR, (size_t)0, (dvoid**)0);
                   OCIParamGet(m_pErrHandle, OCI_HTYPE_ERROR, m_pErrHandle2, (void**)&m_pErrorHndl[i], i);
                   OCIAttrGet (m_pErrorHndl[i], OCI_HTYPE_ERROR, &m_pRowOff[i], 0,
                                            OCI_ATTR_DML_ROW_OFFSET, m_pErrHandle2);
    now, if batch insert is executed, eg, there are 10 records to be inserted, thus m_nArrayLength is set to be 10. There are 5 records of the 10 have exist in database, so some of insert operations will fail. After execution, m_nErrNum is 5, and i can get the failed row numbers.Everything seems go well.
    However, if batch updata is excuted, eg, 10 records to be updated, m_nArrayLength is set to be 10, and also there are 5 records of the 10 have exist in database. After execution, the OCIStmtExecute() returns 1, m_nErrNum got by
    OCIAttrGet((dvoid *)m_pStmtAll,OCI_HTYPE_STMT,&m_nErrNum,
              0,OCI_ATTR_NUM_DML_ERRORS, m_pErrHandle2)
    is 0, and m_nSucNum is 5. Why?? how can I get the rows that fail? i have to know which rows do not exist in database??

  • How to recover data from failed drive that's part of mirrored raid

    Hi Guys,
    hope to get help from someone knowledgeable out there. I have a macpro and recently experienced a failed drive. I set up that failed drive as part of a mirrored raid, this set is not my primary drive and so my computer is stilling up and running but now am wondering how I access the data from the mirrored drive. Should the mirrored drive automatically mount on my desktop whereby I would be able to access the files? This is my first drive failure and I was under the impression having a mirror would duplicate my data and allow me to access it in situations like this. I'm a bit of novice in this area and not sure if the data is truly on the "mirror" or if there are things I need to do.
    I launched disk utility and was able to see the mirrored drive and I selected "mount" drive but it would not mount; I then selected "verify" and got "unrecognizeable filesystem" Is this normal? Am I suppose do something to get access to the mirrored drive? Do I install a new drive in place of the failed drive and expect the raid to rebuild automatically whereby I then see the data?
    Your help is much appreciated.

    Even with a mirror, you still need a backup.
    Along with Disk Utility, you still need 3rd party (TechTool Pro 5, Disk Warrior 4.1.1+).
    And if you like to use RAID and esp mirror RAID, consider
    http://www.softraid.com which is a step above (the pdf guide, manual you can download and they have a demo, so worth the read). SoftRAID can also import/convert an Apple RAID to its own format which has been known to recover drives and data.

  • My Book Live Duo appears to have died. How do I determine what failed

    Drive is making a squealing noise. Seems to make a noise with or without the drives.I cannot access the drive over the network. I have attempted to reinstall the software and find the drive with the search utility. The indicator light starts blue and then turns to amber. Do I need to purchase a new enclosure? What are my options?How can I test the drives without investing in another enclosure. I have 2 2TB drives setup in a mirror RAID configuration. Can't imagine both are bad.  

    If it's making an audible noise with no drives inserted, the enclosure has a failing component somewhere.   There's no moving parts in the enclosure (no fan, etc.) Is it too old for a warranty claim?

  • How can I delete a failed partition space?

    I tried to partition my disk for the first time, but unfortunately, it failed. Now there's a white space left for the supposed partition space. How can I retrieve it back? Help please.

    Would you post a screen shot so people can see what you are seeing? Make sure you cover any personal information using Preview. Post the screen shot in a Reply using the camera icon. Copy and paste doesn't work.
    Screen shots
    Open Disk Utility/Partition and select the drive?
    Do you have Boot Camp installed?

  • How to create workflow-status = failed with ContentService?

    Hi!
    For test-purpose I need a workflow with the status "failed". How can I create one?
    greetings
    Verena

    Hi Robert
    May this help
    <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/d6/eddef503944dc6bbe8d81a2cec44e8/frameset.htm">Customising UWL tabs</a>
    Check the <a href="https://help.sap.com/javadocs/NW04S/current/uw/index.html">UWL API</a>
    <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/57/c223be82104792a15c2df11377b9ed/frameset.htm">Using UWL</a>
    http://help.sap.com/saphelp_nw2004s/helpdata/en/0a/ad68c125ae496f8c04a25090bd2e3c/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/3e/09df7f284f4fb9b50aaedf80652f4c/frameset.htmhttp://help.sap.com/saphelp_nw2004s/helpdata/en/36/dd4ad73c86412e81e9ce66eeb147e7/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/09/6d6b17b29b4eef83a553acaa52f668/frameset.htm
    Thanks
    Swathi

  • How to do I prevent fail over

    This is actually a two part question.
    First - I need to upgrade a wireless controller 4402 and I need update boot loader and software. Can I do both at the same time?
    Second - How can I prevent the APS from failing over when I reboot with out having to go into each AP and take off secondary controller.

    Specific to the AP failover. Why dont you deploy AP FALLBACK? When a controller falls offline for
    any reason the APs join other controllers. HOWEVER when the controller comes online they will fallback to the controllers
    you want with NO intervention from you.
    fyi
    NoteWhen an access point’s primary controller comes back online, the access point disassociates from the backup controller and reconnects to its primary controller. The access point falls back to its primary controller and not to any secondary controller for which it is configured. For example, if an access point is configured with primary, secondary, and tertiary controllers, it fails over to the tertiary controller when the primary and secondary controllers become unresponsive and waits for the primary controller to come back online so that it can fall back to the primary controller. The access point does not fall back from the tertiary controller to the secondary controller if the secondary controller comes back online; it stays connected to the tertiary controller until the primary controller comes back up.

Maybe you are looking for

  • Create a standby logical database in 10g

    Hi, My OS is Windows 2003, using oracle 10g software.. I want to know steps to create a logical standby database from primary database? I read the Dataguard concepts and administration guide, its confusing where it says to add the roles for primary a

  • PO approval from e-mail notifications

    Hi All, We have implemented Oracle EBS 11.5.10.2 on Windows (Financials and SCM). Managers who are responsible for approving POs, want to approve the POs from their e-mails notifications. I want to know how to implement this though I know this is pos

  • IGrid Issue in 12.1 SP 9

    Hi Experts, We are facing the following issue in 12.1,SP 9. When we are trying to display an iGrid having columnlights to show various statuses,we get an output with only the status field coming fine but the other columns coming as black lights inste

  • When i go to editor on garageband 10.2 it does not have the auto tune option. How can i find it or auto tune at all? Do i need to re-install?

    when i go tot he editor option in garageband with the new update it does not give me the option to autotune like what I've seen others have. What should i do so i can get that option?

  • Need licensing advice for a school

    I'm not sure how to approch server licensing for a school. We currently have a 2003 domain licensed "per server" , 500 users we want to relpace the DC with a 2008 server and the academic edition of the OS My questions are these:  are there academic l