Need help in archiveing and deleting records

Hi frnds
I wrote a procedure to archive the records and delete the archived one but after inserting and deleting the tot counter is not working and its showing 1 record inserted and i didnt tried the deletion part,pls find my code and how to get the correct no of records inserted as out put and same for deletion.One more thing,before deletion i want to confirm all the records which i going to delete is already inserted eg,if i could'nt able to do insert the specific no of rows the program shud exit without doing the deletion,How to accomplish that
Declare
cnt NUMBER := 0;
tot number :=0;
CURSOR ins IS
select count(*) from Cal_log
where trunc(c_date) ='11-Aug-2008';
BEGIN
FOR rec IN ins LOOP
insert into Calls_arc
select * from Cal_log
where trunc(c_date) ='11-Aug-2008';
tot :=tot + 1
cnt := cnt + 1;
IF (cnt >= 100) THEN
COMMIT;
cnt := 0;
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('inserted ' || tot|| ' records in call_arch.');
FOR rec IN ins LOOP
delete from Cal_log
where trunc(c_date) ='11-Aug-2008';
tot := tot + 1;
cnt := cnt + 1;
IF (cnt >= 100) THEN
COMMIT;
cnt := 0;
END IF;
COMMIT;
DBMS_OUTPUT.PUT_LINE('Deleted ' || tot || ' records from Cal_log');
END;

Since
CURSOR ins IS
select count(*) from Cal_log
where trunc(c_date) ='11-Aug-2008';always returns one row, your loop
FOR rec IN ins LOOPdoes not make much sense. But it does not hurt. The real issue with your code is you increment tot by one while insert processes more than one row (all rows for Aug 11). You should use %ROWCOUNT. And one more thing, never rely on implicit date conversions since default date format is client session sependent. Anyway, all you need is:
BEGIN
    insert
      into Calls_arc
      select  count(*)
        from  Cal_log
        where c_date >= to_date('11-Aug-2008','dd-mon-yyyy')
          and c_date <  to_date('12-Aug-2008','dd-mon-yyyy');
    DBMS_OUTPUT.PUT_LINE('inserted ' || SQL%ROWCOUNT || ' records in call_arch.');
    delete
      from Cal_log
      where c_date >= to_date('11-Aug-2008','dd-mon-yyyy')
        and c_date <  to_date('12-Aug-2008','dd-mon-yyyy');
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Deleted ' || SQL%ROWCOUNT || ' records from Cal_log');
END;
/SY.

Similar Messages

  • Need help to insert and update records in MDM

    Hi ,
    I am trying to develop an webdynpro application which can create and update records in tables of a repository of MDM . For example .. I want to insert values and later update values in Vendor table.
    I am new to webdynpro and MDM. If any one can help step by step or can send a sample code which I can be ready to use that would be great help.
    If anyone can have a sample code .. kindly mail to "[email protected]"
    It is urgent. Please help.
    Regards,
    Niraj
    Edited by: Niraj Kumar on May 23, 2008 6:50 AM

    Hi Niraj,
    Are u going to work with webdynpro Java/ABAP?
    some materials which are found useful are sent.
    Cheers,
    Mary

  • Need help with archive and install

    I'm doing and archive and install. The first try was with a defective retail version of OS X Tiger, which did part of the job then stalled. Now I've been able to get a good DVD of this and was able to do an archive and install,although I couldn't check the box to save user settings etc., On the screen it gives me 3 options transfer info from another mac, transfer info from another partition on this mac or do not transfer my info. I'm new to all this, because of the first failed archive and install do I transfer the info from another partition or not transfer at all and find the old folder later on in the process?

    Hi D,
    I couldn't check the box to save user settings etc.
    I think that is due to the partial previous install moving things to a Previous System folder, but not finshing.
    Let's see if that's what happened... if you have 2 Macs with Firewire this could be a lot easier.
    Oh, do you have a Backup?
    "Try Disk Utility
    1. Insert the Mac OS X Install disc that came with your computer, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.)
    Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
    3. Click the First Aid tab.
    4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
    5. Select your Mac OS X volume.
    6. Click Repair. Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    After quitting DU, look for Terminal in that Menu Bar, open that and type in this...
    Wait, let's hear if you have another Mac or Boot Disk first...

  • Archive and delete sap event management objects

    Team, I need to configure the archiving objects and residence time to Archive and delete EM objects. there are three steps of configuration, and I have never done this before.
    Can any one of you help me in setting up this config and the programs that need to run to archive and delete these objects.
    I would really appreciate you help and quick response on this.
    Define Archiving-Object-Specific Customizing
    Define Residence Times for Archiving or Deleting
    Define Settings for Deleting Document Flow
    Thank you!!!

    Hello Steffen,
    I was told that it would be possible to display archived and deleted event handlers using BAPI /SAPTRX/BAPI_EH_GET_DATA_GEN. I tested it, but could not verify this statement. SAP Help reads:
    "The archiving object /SAPTRX/A0 only supports a technical view in the Archive Explorer of the Archive Information System. This view is similar to the display in transaction SE16."
    It would be great if you could help clarify this. Thank you!
    Best regards,
    Philiipp

  • Archiving  and Deleting of XML Messages in SAP NetWeaver PI 7.31 single stack

    Hello my XI friends!
    Need step by Step Guide to Archiving
    and Deleting of XML Messages in
    SAP NetWeaver PI 7.31 single stack
    Similar to these instructions
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e0afdd69-a8a7-2d10-7e9a-cbf6fa21c5a7?quicklink=index&overridelayout=true
    Regards,
    Rinaz

    Please check the below blog  for archiving java only-(XMLDAS)
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2011/11/16/aae-archiving-in-sap-pi-711-with-xmldas
    For deletion there is standard delete job..
    https://help.sap.com/saphelp_nw73ehp1/helpdata/en/48/b2e0036b156ff4e10000000a42189b/frameset.htm
    Message was edited by: Hareesh Gampa

  • Insert ,Change and Delete  records  in OO ALV

    Hi All,
    This is regarding the functionlaties  Insert ,Change and Delete records  in OO ALV ,
    I have gone through the threads posted here and checked the standard  program BCALV_EDIT_04,
    but still I am not able to capture the Deleted and Inserted records,
    as  I am new to OO ALV,can some one help me out pls.
    Thanks and regrds,
    Sree.

    Hi Sree,
    A lot of material is available on SDN.
    Please see this link. This link contains good example of insertr, delete records in OOPS ALV.
    [OOPS ALV.|Re: Insert ,Delete & Add a row in ALV;
    May it helps you.
    Regards.
    DS.

  • Any RFC To Archive and Delete IDOC from XI?

    hi,
    Is there any standard RFC available which archives and deletes the IDOC?
    In my scenario i have to delete the IDOC that has successfully transmistted an IDOC to a SOAP Receiver.
    client's requirement is to delete the IDOC immediately instead of running a SAP batch program scheduled sometime later.
    Let me know if there is one.
    Thanks,
    Tirumal

    Vijaya -
    I completely understand that scheduling the report every on a timely basis is the best way.
    But you know if i were the manager i could have taken decisions but since i am not i have to do what the client says. No other way.
    We will see.
    Thanks for your patience and helpful answers.
    - Tirumal

  • Archiving and deleting of equipment master data in plant maintenance module

    Hi,
    Can anyone explain me the process to archive and delete the equipment master data in PM module using archiving tools.
    I tried doing it thru t-code SARA, would be grateful if anyone can help me with the steps to follow to archive the equipment master data.
    Thanks in advance,

    Many thanks for your reply,
    I tried doing the same in IDES, but unfortunately the archive file is not getting generated when i write it. I have clearly specified in the variant to create an archive file. Can you please explain how does the system generate an archive file. And also in the customizing " Archiving Object-Specific Customizing " techincal settings, i have maintained the production variant and have marked start automatically.
    Please advise,
    thanks again ,

  • Issue: Archiving and Deleting completed Processes  from GP Administration

    Hi
      IWe want to delete the completed processes from every users "Completed Processes' List.  For this ,
    In GP administration-> Archiving and Deleting-> Maintain Process templates->Global Settings,
        We set 1 day for completed tasks.
        So , after one day,will it remove all the completed processes  or only the processes which were completed after setting the Archiving in Global settings?
    How can I delete all the completed Processes?
    Thanks
    Smitha

    Hi Smitha,
    Basically, there are two ways in which you can delete processes in <b>GP administration-> Archiving and Deleting</b>:
    1. automatically, through the <b>Maintain Process Templates</b> option
    2. manually, through the <b>Begin Archiving</b> option - there you have to ignore the predefined settings and set a date before which you want to delete processes.
    You should delete manually all processes up to now that were not deleted by the automatic scheduling. After that, all newly completed processes should be deleted promptly as you have specified in the global settings.
    Make sure that you also perform the appropriate settings for the archive store and the home path.
    You can check the documentation at: <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/be/67a53d874f46c4b9a25e6e7d16a243/frameset.htm">Process Archive Management</a>.
    Regards, Petja

  • I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    What file format did you export it to?

  • PI 7.11  AAE- Archiving and deletion

    Dear All,
    I just want to get confirm on my understanding regarding AAE archiving and deletion.
    We have 98% interfaces using only AAE in our landscape.
    I had set up XMLDAS archiving for AAE ( After fixing so many issues ) which archives the AAE messages into the local file system. So no issues in that .
    Now my requirements are,
    1) I would like to keep only 7 days of data in the database and 100 days of data in the file system
    2) I do not want to set up any rules for Archiving /Deletion. It means i would like to archive messages older than 7 days in the file system.
    The steps are ( My understanding )
      1) Set the persistence duration in NWA to 7 days . So only 7 days of data will be stored in table BC_MSG.
      2) Set up the archival job in the background processing through RWB  without ANY RULES. So all processed messages older  than 7 days will be achieved in the file system. And Archive will come with default delete procedure as well hence Archived messages will be deleted from table BC_MSG.
      3) Deactivate the delete job . If i have the active delete job in the background processing, it will delete all messages older than 7 days which i don want.  The deletion of messages from BC_MSG will be taken care as part of archival job.
    Is my understanding correct?
    Thanks
    Rajesh

    Hello, any know what did they do to delete the files from the file system after 100 days?
    We have the same problem, when we deleted manualy some messages  from SO AIX but they still appear from the RWB, and when we clic over them we get an error:  ...... java.lang.Exception: XML DAS GET command failed with ErrorCode: 598; ErrorText:  598 GET: Error while accessing resource; response from archive store: 598 I/O Error java.io.FileNotFoundException: /usr/sap/PID/javaarch/archive/usr/sap/pid/x
    Is there any way to delete messages without generating errors / inconcistencias?

  • Need help to import and syncronize HCM pagelets with Interaction Hub, how can I do that?

    Hi,
    I need help to import and synchronize HCM pagelets with Interaction Hub, how can I do that? The default page "Select Remote Content" of the WorkCenter "Unified Navigation WorkCenter" is not working as well, when I run the import/sync button I get the following error message:
    Integration Gateway: General Connection Failed (158,10836)
    This error is thrown when there is no valid response.
    Possible errors include:
    Bad gateway URL
    Sync Service Timeout set and Service actually timed out.
    Java exception thrown - Check Application Server for possible Java exception

    Do you have integration configured between the two systems?  It sounds like you don't from the error.  Here is a walk-through on setting up Unified Navigation although it assumes you have integration already working.  If you haven't done that, it's documented a hundred different places.
    http://remotepsadmins.com/2013/03/04/peoplesoft-unified-navigation-with-peoplesoft-applicatations-portal-interaction-hub/

  • I need help in downloading and installing a previously purchased version of Photoshop Elements 12: AD012822594 1057-0247-4177-3303-6451-8067  or   1057-0904-6949-7119-8323-9165

    I need help in downloading and installing a previously purchased version of Photoshop Elements 12: AD012822594 1057-0247-4177-3303-6451-8067  or   1057-0904-6949-7119-8323-9165

    Please do not share serial numbers  or Order numbers on Forums . Serial numbers and order numbers  are very confidential.
    You can only share serial number with Adobe Customer support staff.

  • I need help in downloading and installing a previously purchased version of Photoshop Elements 12: Serial number removed by moderator

    I need help in downloading and installing a previously purchased version of Photoshop Elements 12: <Serial number removed by moderator>

    Hi There,
    Kindly try: Troubleshoot installation | Photoshop Elements, Premiere Elements | Windows
    Thanks,
    Atul Saini

  • Need Help in installations and connecting displays. Please!

    Hello Everyone,
    Need Help in installations and connecting displays. Please!
    Im planning on installing in a cafe shop : (Store Self improvement)
    4 TV's (can be  Built in Wi-Fi) Store menus
    2 touch screen tablets.  To be use as Emenu (digital Menu)
    1 60' TV ( Built in Wi-Fi) as Entrainment displays and in store advertising
    What do I need to organize my project and make it looks cool and how to manageand controll all of the displays TV.

    TNSTAAFL
    I DO NOT work for Best Buy, Geek Squad and any way affiliated with them. I am a self-employed repairman. I specialize in TV's and desktop computers. I do not take sides. If BB is wrong I will say so. If you are a moron with a false sense of entitlement, then I will tell you.

Maybe you are looking for