Insert of data getting missed/duplicated while using Cursor

Hi all,
Greeting !!
I got a strange issue with cursor usage in a SP . Below is the cursor detail.
Basicially the SP pulls around 2,25,000 records to a temp table(#TMP_ADJ) from there cursor picks and inserts to a physical table(B_SHEET) with some conditions.
Recently we are facing issues in records getting inserted to B_SHEET , the strange part is if this SP is called in a specific period of time i.e every day this job runs at 2 PM GMT and we encountered some of the records getting missed to insert in to B_SHEET
table and some time the record is getting duplicated. Around 200-300 records are getting missed.
we retriggered i.e ran the SP again but this time it was fine, so we confrim that there is no issue with data.
Later we postponed the same job to get triggered at 3 PM GMT post which we dint encounter the problem.
Tough this seems to be not a problem with cursor logic, but i need experts help to identify the exact issue what happens at when the job is triggered at 2 PM GMT.
There has been no change recently done on the SP and the same SP was running fine for past 3-4years.
1 . What are the checks that needs to be done that affects CURSOR.
 DBA has confirmed that CPU utilization / temp db memory are fine during the period of time. And no issues with Data since the second run of the same SP is fine.
Thanks.

If you want suggestions out of the blue, the only recommendation I can give is that you should make sure that the cursor declartion reads:
DECLARE cur CURSOR STATIC LOCAL FOR
The default cursor type is dynamic. Dynamic cursors are difficult to understand and rarely perform well.
Apart from this specific advice, I can only give generic advice since you don't share the code.
It is a common mistake to believe that just because a piece of code produces the expected result that the code is correct. However, the code may only work as intended because of happenstance. For instance a query may be non-deterministic and produces different
results because of the query plan.
Other reasons for "works most of the time, but fails some times" is poor error handling, where you fail to consider errors or handle them inappropriately. In a cursor loop, a common error is also to fail to initiate local variables in the beginning
of the loop, so that they retain their values from the previous iteration.
What I like to emphasise once more is that just because the code works most of the time does not mean that it is correct. The fact that it under some circumstances produces incorrect results, carries much more weight. There is at least one flaw in the code
- you only need to spot it.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • My iphone get's hanged while using facebook,what to do???

    my iphone get's hanged while using facebook,what to do???

    What buttons did you try?  IF you haven't already, try a reset, no data loss.
    Hold down the home/sleep button together until you see the Apple logo and then release, then wait for the phone to boot back up.

  • How to get default values while using the transaction "BP"

    Hi Group,
    I have a query on how to get default values while using the transaction <b>BP</b>?
    The thing is:
    when I enter into the transaction "BP", I need to see some default values to some of the input fields in the screen.
    how can I achieve this?
    So please kindly let me know the procedure to achieve this.
    Thanks & Regards,
    Vishnu.

    Hi,
    The events of BDT can be used to default some fields on creating a partner.
    For this create a function module for ISDAT. attach that event in BUS7.
    In the ISDAT funtion modulethe following code should be used.
    For example to set the nationality:
    I_BUSDEFAULT-NATIO = 'DE.
    CALL FUNCTION 'BUP_BUPA_FIELDVALUES_SET'
    EXPORTING
    i_busdefault = I_BUSDEFAULT
    Regards, Smita.

  • HT201406 1st. Gen iPad question:  the touch keyboard does not appear when attempting to input data into data fields - this happens while using all apps, ex. Notes, Google, Pages, etc..

    1st. Gen iPad question:  the touch keyboard does not appear when attempting to input data into data fields - this happens while using all apps, ex. Notes, Google, Pages, etc.. The cursor prompt is present.  Tapping screen just brings up the option to: "Select   Select All   Paste."   I have rebbooted with no change. 
    Message was edited by: Jimfromutah
    The problem was my connected bluetooth keyboard.

    1st. Gen iPad question:  the touch keyboard does not appear when attempting to input data into data fields - this happens while using all apps, ex. Notes, Google, Pages, etc.. The cursor prompt is present.  Tapping screen just brings up the option to: "Select   Select All   Paste."   I have rebbooted with no change. 
    Message was edited by: Jimfromutah
    The problem was my connected bluetooth keyboard.

  • I was using ios 7.0.3 nd it was working very nice but before some days i got an update 7.0.4 nd i updated and now my iphone is getting switch off while using nd restarts..???? what to do

    i was using ios 7.0.3 nd it was working very nice but before some days i got an update 7.0.4 nd i updated and now my iphone is getting switch off while using nd restarts..???? what to do

    Sorry you cannot go back to previous version once your are updated to the latest iOS version.
    Apple prevents downgrading your phone.

  • My iPhone 5 gets really hot while using it.. its only my 2nd day with it is this normal?

    My iPhone 5 gets really hot while using it.. its only my 2nd day with it is this normal?

    I had same issue, apple give me a new phone, they say it might be software problem, but the 2nd phone has fast drain too, I took it to apple , they restored my phone as new, and iCloud backed up my contact. I thought about the whole thing, I used to sync it to my window, but this time I synced it with my Mac. 87% at 3:30pm. I think that window has bugs. It is not my iPhone 5's problem. After all those stressful days.

  • I just bought my phone few days ago. From the day I bought it I realized the phone heats up after a little use. It gets really hot while using Wifi and downloading. Anyone else having these issues? What's the solution to this?

    From the day I bought it I realized the phone heats up after a little use. It gets really hot while using Wifi and downloading. Anyone else having these issues? What's the solution to this?

    Your VGA is definitely corrupted and it is irreparable, so just make the HP to change your vga.
    Also next time read my post on how to keep your laptop cool to avoid same issues again.
    I assume your laptop was pretty hot during some time and that's the result you've got.
    Make it easier for other people to find solutions, by marking my answer with 'Accept as Solution', if it solves your problem.
    Click on the BLUE KUDOS button on the left to say "Thanks"

  • Phone gets really hot while using the YouTube app.............

    My iPhone gets really hot while using YouTube. Is/has anyone else experienced this? Should I be concerned?I did a search and only came up with threads talking about the phone getting warm while charging, my phone does not get hot/warm while charging, only when using YouTube and sometimes while using Safari. Any input will be greatly appreciated!

    When connected via WiFi or EDGE or no difference.
    My iPhone sometimes gets considerable warm when connected via EDGE with low reception but this is rare when connected via WiFi or with good reception.

  • Not getting PO printed while using bursting pls help

    Hi All,
    Working on converting PO report to XML. While using bursting to print the pdf file the document is not sent to the printer..
    But in the output file of the "XML Publisher Report Bursting Program" getting success.
    Not sure why report output is not sent to the printer.
    Pls help......
    Thanks
    Rajesh
    Edited by: Badsha on Jun 17, 2010 2:19 AM

    Hi...Please check the Burst Control file with the printer & IP details.
    Look for the file below.
    <?xml version="1.0" encoding="UTF-8"?>
    <xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi">
    <xapi:globalData location="stream">
    </xapi:globalData >
    <xapi:request select="/DATA/LIST_DEPT/DEPT/LIST_EMPLOYEE/EMPLOYEE">
    <xapi:delivery>
    <xapi:email server="${EMAIL_SERVER}" port="${EMAIL_PORT}"
    from="${FROM_EMAIL_ADDRESS}"
    reply-to ="${REPL_TO_ADDRESS}">
    <xapi:message id="email1" to="${TO_EMAIL_ADDRESS}" cc="${CC_EMAIL_ADDRESS}"
    attachment="true" content-type="html/text"
    subject="Employee Report for Empno ${EMPNO}">
    Dear ${ENAME}, Please review the attached document.</xapi:message>
    </xapi:email>
    <xapi:filesystem id="file1"
    output="C:\burst\sample\${EMPNO}_${ENAME}_${MGR}_PRINT.pdf"/>
    <xapi:print id="print1" printer="${PRINT_URL}" copies="2"
    orientation-requested="3" />
    </xapi:delivery>
    <xapi:document key="${EMPNO}"
    output-type="pdf" delivery="email1">
    <xapi:template type="rtf" location="${TEMPLATE_LOC}"
    filter=".//EMPLOYEE[DEL_CHANNEL='EMAIL']" >
    </xapi:template>
    </xapi:document>
    <xapi:document key="${EMPNO}" output-type="pdf" delivery="print1">
    <xapi:template type="rtf" location="${TEMPLATE_LOC}"
    filter=".//EMPLOYEE[DEL_CHANNEL='PRINT']" >
    </xapi:template>
    </xapi:document>
    <xapi:document key="${EMPNO}" output-type="pdf" delivery="file1">
    <xapi:template type="rtf" location="${TEMPLATE_LOC}"
    filter=".//EMPLOYEE[DEL_CHANNEL='FILE_SYSTEM']" >
    </xapi:template>
    </xapi:document>
    </xapi:request>
    </xapi:requestset>
    check the printers setting as required....aslo check what printer you are using for pdf printing...Pasta Printing??
    Thanks
    Ratnesh

  • Running out of memory while using cursored stream with large data

    We are following the suggestions/recommendations for the cursored stream:
    CursoredStream cursor = null;
              try
                   Session session = getTransaction();
                   int batchSize = 50;
                   ReadAllQuery raq = getQuery();
                   raq.useCursoredStream(batchSize, batchSize);
                   int num = 0;
                   ArrayList<Request> limitRequests = null;
                   int totalLimitRequest = 0;
                   cursor = (CursoredStream) session.executeQuery(raq);
                   while( !cursor.atEnd() )
                        Request request = (Request) cursor.read() ;
                        if( num == 0 )
                             limitRequests = new ArrayList<Request>(batchSize);
                        limitRequests.add(request);
                        totalLimitRequest++;
                        num++;
                        if( num >= batchSize )
                             log.warn("Migrating batch of " + batchSize + " Requests.");
                             updateLimitRequestFillPriceForBatch(limitRequests);
                             num = 0;
                             cursor.releasePrevious();
                   if( num > 0 )
                        updateLimitRequestFillPriceForBatch(limitRequests);
                   cursor.close();
    We are committing every 50 records in the unit of work, if we set DontMaintianCache on the ReadAllQuery we are getting PrimaryKeyExceptions intermittently, and we do not see much difference in the IdentityMap size.
    Any suggestions/ideas for dealing with large data sets? Thanks

    Hi,
    If I use read-only classes with CursoredStream and execute the query within UOW, should I be saving any memory?
    I had to use UOW because when I use Session to execute the query I get
    6115: ISOLATED_QUERY_EXECUTED_ON_SERVER_SESSION
    Cause: An isolated query was executed on a server session: queries on isolated classes, or queries set to use exclusive connections, must not be executed on a ServerSession or in CMP outside of a transaction.
    I assume marking the descriptor as read-only will avoid registering in UOW, but I want to make sure that this is the case while using CursoredStream.
    We are running in OC4J(OAS10.1.3.4) with BeanManagedTransaction.
    Please suggest.
    Thanks
    -Raam
    Edited by: Raam on Apr 2, 2009 1:45 PM

  • Missing warnings while using softproofing ?

    First, congratulations for all the new or enhanced features !
    Especially the softproofing function is great : the histogramm is now showing what is happening in the destination color space.
    My question is about the warnings on the image while using softproofing : after activating both monitor and destination warnings, and evenif my image is voluntarily completly blown up with highlights, i see very few warnings on the image.
    Am i doing something wrong or the warning function is not working well ?
    Charles, France

    I suspect but could be totally off, that a single color channel will not cause the OOG overlay. You should be able to see this anyway in the normal Histogram (in this case, a blue spike on the end of the Histogram). Again, going out on a limb, I suspect that the profile has to be used to tell LR that all three channels fall outside of gamut, in other words, this isn’t a channel by channel OOG but the entire group. Maybe someone from Adobe can comment.
    I can get the OOG warning to show up with only one or two channels saturating. It appears to have been done correctly. See the screenshot below. The channel info shows only red saturating at 255 in the red-masked OOG area
    Now I can say that I think there is a zoom bug in terms of the OOG in that I’ve seen some overlay colors appear or disappear based on the zoom ratio. Even saw this in Julieanne’s video demo. So you may want to zoom in at 100% (1:1) to get a more accurate OOG preview.
    I am not so sure whether that is a bug or simply a cause of how the Develop preview is generated. LR has to render a low resolution preview and inevitably that involves some downscaling and resharpening (LR has been doing some sharpening on the develop preview for a while now). It is possible that if you are on the edge of being out of gamut, the lower resolution preview can get pushed out of gamut by the sharpening and perhaps by noisy data that is not smoothed away by the noise reduction that would happen at 1:1 but doesn't happen the same way zoomed out at fit or fill.
    P.S. as we found in the thread linked above there are some minor bugs in the softproof notably with proofing for sRGB. So I wouldn't trust it too much yet and just look at it as a preview of how it might or will be implemented in the release.

  • What are the limitations in terms of data size  or performance while using csv or text file as datasource?

    <p>Also what are the limitations in terms of data size  or performance related issues while using csv or text file?</p><p>Is it the best practice to use csv , text file to use as a datasource to improve performance?</p><p>Please Advice.... </p><p>&#160;</p>

    <p>Hi,</p><p>Create Same Data Input for CSV and Text File ,Create 2 different reports one for CSV and One for Text ,run them one you have done that.</p><p>Go to Report Menu and Select Performance Information .Use the Data in that to check which one is good datasource to improve performance</p><p>Cheers</p><p>Rahul</p>

  • How can I get HD quality while using my iSight on my MBP?

    Hey Folks.
    Im interested in knowing a little more information regarding the isight cam... I want to get HD quality while video chatting with family & friends on skype & iChat. Please let me know.
    I know that there are other webcams that have HD capabilities.
    http://www.huehd.com/
    http://benchmarkreviews.com/index.php?option=com_content&task=view&id=98&Itemid= 1
    http://digitalurban.blogspot.com/2008/11/tutorial-torch-webcam-hd-timelapse.html
    http://www.logitech.com/index.cfm/webcam_communications/webcams/devices/4528&cl= us,en
    Let me know.
    Thanks.
    -Joey

    Yes.
    I have a web cam that can do 1.3Mp
    This App can get those that Can, to Display (And Display Only) the native format of the camera.
    iMovie is likely to be able to see it as it can handle Camcorder feeds.
    The difference you see in iMovie to iChat is the difference.
    iChat, MSN (If connected via a Exchange Server to do Video), Yahoo (Vid only no Audio) and Skype on the IM apps use 640 X 480 or in Skype's case less.
    Photo Booth seems to use the same as iChat to allow for the Composition tweaks (It uses the same Quartz files in the Compositions Folder)
    By eye Comic Life that came bundled with some Intels also seems to use 640 X 480
    So to an extent it depends what you are going to use the camera for.
    iGlasses is a cross app Add-On that can "improve" and tweak the picture in various applications such as iChat outside of what the OS and Application Software have commonly set as Defaults.
    the Adjustments tend to be within the scope set up by the manufacturer (i.e. allowing colour, white balance and Contrast and other settings the camera may have been designed for but not in the app settings)
    Quicktime Pro, if you have it, can be set in Preferences > Recording to "Device Native" which tends to allow a sort of in-between iChat and iGlasses control (some features but not all) but will work with iGlasses as well.
    It is restricted to a 4:3 format window though but this would apply to most Web cams anyway.
    10:38 AM Saturday; May 2, 2009

  • Getting  Short Dump while using the FM"SAP_CONVERT_TO_TEX_FORMAT"

    Hello Experts,
        I am using the FM SAP_CONVERT_TO_TEX_FORMAT to convert the  data in text format and use
    that  converted data to create the file on application server. When I used this FM to convert the data from T0599Z table  then it's giving me dump for other tables it's working fine.
    Can anyone suggest why this is happening?
    Thanks

    Can you write the codes...
    Try something of below sort..
      CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
       EXPORTING
         i_field_seperator          = ','           "For CSV Files
        TABLES
          i_tab_sap_data             = gt_outtab1
       CHANGING
         i_tab_converted_data       =  gt_outtab.

  • How to manipulate data in multiple rows without using cursor??

    Hi all,
    I have a form in which there is a push button & 4 text fields.
    Push button : Process
    Text fields: Year, Month, Financial_To_Year, Financial_From_Date.
    In database , there are tables like, CUSTOMER_MASTER, FD_ACCOUNT_MASTER, FD_ACCOUNT_DTL, CUSTOMER_YEARLY_INTEREST, etc.
    In table FD_ACCOUNT_MASTER, there are columns, like CUST_CODE, FD_ACCT_NO, FD_AMOUNT, ACCT_OPEN_DT, ACCT_CLOSE_DATE, ACCT_TYPE, INTEREST_RATE, etc.
    There are thousands of records in the table.
    For Push button : Process , TRIGGER: When button pressed,
    I have to do all the process of FD for all the FD_ACCOUNTS at once. Process means i have to calculate Interest for all the accounts, calculate interest monthly, quarterly, yearly and make the FD_Accounts disable after the date of ACCT_CLOSE_DATE is reached, make the accounts renewed , etc all the process.
    But to do this process for multiple rows at once, we use cursor, but i don't want to use cursor as i feel its too tedious to do.
    Is there any other way , where i do process of multiple records at once without using cursor??
    Help me, Thank You.
    Oracle Forms Builder 6i.
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

    An Update statement certainly can update sets of data instead single row updates:
    UPDATE Statement
    if you can't do it in a single statement you can use bulk processing as well:
    PLSQL 101
    cheers

Maybe you are looking for