Query for deletion

Hi to all.........
      Plz tell me the ABAP query for how to delete the duplicate posting months from dfkkop & after  
      then the query to count the no of rows of dfkkop ??
Thanks & Regards........
Rajeev Shrivastava

hi check this..
tables:marc .
data: it_marc like marc occurs 0.
select-options:s_matnr for marc-matnr .
data: v_count type i .
select matnr
        werks
         from
           marc into table it_marc
           where matnr in s_matnr .
delete adjacent duplicates from it_marc comparing werks .
describe table it_marc lines v_count .

Similar Messages

  • Query for deleting the minimum updated record.

    Hello Everybody,
    I have table USER_RECENT_PROJECTS which has SIX columns USER_NAME,PROJECT_ID,CREATED_BY,CREATED_ON,UPDATED_BY
    and UPDATED_ON.The purpose of having this table to get 5 recent PROJECTS
    on which user has worked on.
    I have trigger called RECENT_PRJ_TRIGG which IS FIRED when the data is inserted or updated on PROJECT table.After this trigger calls procedure PROC_USER_RECENT_PRJ and that procedure puts the data in this table.
    It is inserting the data upto 5 records when the six records comes it deleting the record which is least UPDATED_ON from the table USER_RECENT_PROJECTS but the problem is it is deleting
    the record from other user that i don't want.I want to delete the the record which is
    least UPDATED_ON from particular user.
    Please help me on this issue.
    Here is the trigger
    CREATE TRIGGER RECENT_PRJ_TRIGG
    AFTER INSERT OR UPDATE ON PROJECT
    FOR EACH ROW
    DECLARE
    NUMBER_OF_PROJECTS NUMBER:=0;
    EXISTING_PROJECT_ID NUMBER:=0;
    BEGIN
    SELECT COUNT(*) INTO NUMBER_OF_PROJECTS FROM USER_RECENT_PROJECTS WHERE USER_NAME=:NEW.UPDATED_BY;
    SELECT PROJECT_ID INTO EXISTING_PROJECT_ID FROM USER_RECENT_PROJECTS WHERE PROJECT_ID=:NEW.PROJECT_ID AND USER_NAME=:NEW.UPDATED_BY;
    NVLX.PROC_USER_RECENT_PRJ(NUMBER_OF_PROJECTS,:NEW.PROJECT_ID,EXISTING_PROJECT_ID,:NEW.UPDATED_BY,:NEW.CREATED_BY,:NEW.CREATED_ON);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NVLX.PROC_USER_RECENT_PRJ(NUMBER_OF_PROJECTS,:NEW.PROJECT_ID,0,:NEW.UPDATED_BY,:NEW.CREATED_BY,:NEW.CREATED_ON);
    END;
    And this is the procedure which is inserting the data
    CREATE OR REPLACE PROCEDURE PROC_USER_RECENT_PRJ (
                   NUMBER_OF_PROJECTS IN NUMBER,
                   NEW_PROJECT_ID IN PROJECT.PROJECT_ID%TYPE,
                   EXISTING_PROJECT_ID IN USER_RECENT_PROJECTS.PROJECT_ID%TYPE,
                   USER_NAME IN CONTENT_USER.USER_NAME%TYPE,
                        CREATED_BY IN PROJECT.CREATED_BY%TYPE,
                        CREATED_ON IN PROJECT.CREATED_ON%TYPE)
              IS
                                  MAX_RECENT_PROJECTS NUMBER := 5;
              BEGIN
                        IF NUMBER_OF_PROJECTS<=MAX_RECENT_PROJECTS AND EXISTING_PROJECT_ID=NEW_PROJECT_ID THEN
                             UPDATE USER_RECENT_PROJECTS SET USER_RECENT_PROJECTS.UPDATED_ON=SYSDATE,USER_RECENT_PROJECTS.UPDATED_BY=USER_NAME WHERE PROJECT_ID=EXISTING_PROJECT_ID
                             AND USER_RECENT_PROJECTS.USER_NAME=USER_NAME;
                        ELSE IF NUMBER_OF_PROJECTS<MAX_RECENT_PROJECTS AND EXISTING_PROJECT_ID!= NEW_PROJECT_ID THEN
                        INSERT INTO USER_RECENT_PROJECTS VALUES (USER_NAME,NEW_PROJECT_ID,CREATED_BY,CREATED_ON,USER_NAME,SYSDATE);
                        ELSE IF NUMBER_OF_PROJECTS=MAX_RECENT_PROJECTS AND EXISTING_PROJECT_ID!= NEW_PROJECT_ID THEN
                        DELETE FROM USER_RECENT_PROJECTS WHERE USER_RECENT_PROJECTS.PROJECT_ID IN(
                                       SELECT PROJECT_ID FROM USER_RECENT_PROJECTS
                                                 WHERE UPDATED_ON=(SELECT MIN(UPDATED_ON) FROM USER_RECENT_PROJECTS
                                  WHERE USER_RECENT_PROJECTS.USER_NAME=USER_NAME));
                   INSERT INTO USER_RECENT_PROJECTS VALUES (USER_NAME,NEW_PROJECT_ID,CREATED_BY,CREATED_ON,USER_NAME,SYSDATE);
                        END IF;
                        END IF;
                        END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NVLX.PROC_USER_RECENT_PRJ(NUMBER_OF_PROJECTS,NEW_PROJECT_ID,0,USER_NAME,CREATED_BY,CREATED_ON);
    END PROC_USER_RECENT_PRJ;
    Please help me on this issue.
    Thanks in advance.....

    Thanks for your suggestion....
    I am using the trigger for populating the data in USER_RECENT_PROJECTS.This
    trigger is fired when data is INSERTED or UPDATED in PROJECT table.And that trigger will call the procedure PROC_USER_RECENT_PRJ.This is used
    to put data in USER_RECENT_PROJECTS table.I am getting the problem in procedure the problem is upto five records it is inserting the record when i go for insert sixth record it should delete least UPDATED_ON and insert new record.But it is deleting the record from other user that i don't want.I want to delete the record from the paarticular user.I am using this query for deleting the record..
                   DELETE FROM USER_RECENT_PROJECTS WHERE USER_RECENT_PROJECTS.PROJECT_ID=(
         SELECT PROJECT_ID FROM USER_RECENT_PROJECTS
                        WHERE UPDATED_ON=(SELECT MIN(UPDATED_ON) FROM USER_RECENT_PROJECTS WHERE USER_RECENT_PROJECTS.USER_NAME=USER_NAME)
                             AND USER_RECENT_PROJECTS.USER_NAME=USER_NAME
                   ) AND USER_RECENT_PROJECTS.USER_NAME=USER_NAME;
    when i fire this query individually it is deleting the proper record,but when i use it
    inside procedure it is creating the problem it is deleting the record from other user.
    Please suggest me other query for deletion.
    Thanks in advance.......

  • Query for deleting rows older than 25?

    Am trying to delete rows older than 25... How would the query for this be like? I tried this "DELETE FROM DB LIMIT 25,100" But getting errors...

    what is older than 25? Does it mean with id greater then 25?
    then you should have a query like
    DELETE FROM tableName WHERE id > 25

  • Spatial query for delete duplicates of geometry

    Hello,
    I have a table so done:
    link table
    id  type  geometry
    1  4110 SDO_GEOMETRY(2002, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(8.817363, 45.2586799, 8.8175389, 45.2586922))
    2  4110 SDO_GEOMETRY(2002, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(9.673168, 45.9441037, 9.6737121, 45.9439068, 9.6743082, 45.9437246, 9.6744819, 45.9437006, 9.6745598, 45.9436942))
    3  4120 SDO_GEOMETRY(2002, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(9.0274561, 45.5738369, 9.0274676, 45.5737538))
    4  4110 SDO_GEOMETRY(2002, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(8.8630649, 45.804841, 8.8632493, 45.804992, 8.8633701, 45.805095, 8.8637156, 45.8053738))
    5  4110 SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(10.2349279, 45.5008616, NULL), NULL, NULL)
    6  4120 SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(10.2591062, 45.501003, NULL), NULL, NULL)
    7  4120 SDO_GEOMETRY(2002, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(10.0924794, 45.1855654, 10.0927326, 45.1854935))
    ...I think that the geometry of the rows with feattyp=4120 are all included (or are equal) into geometry of rows with feattyp=4110. In this case I can delete all rows with feattyp=4120.
    I'm thinking to use SDO_ANYINTERACT function but I don't know how do the query.
    Can you help me?
    Thank you in advance.

    I have done so:
    SET SERVEROUTPUT ON
    DECLARE 
      CURSOR cur IS SELECT * FROM link WHERE FEATTYP=4110;
      rec cur%ROWTYPE;
    num_tot_not_intersections NUMBER(20);
    num_not_intersections NUMBER(20);
    BEGIN
    num_not_intersections := 0;
    num_tot_not_intersections := 0;
      OPEN cur;
      LOOP
      FETCH cur INTO rec;  
        EXIT WHEN cur%NOTFOUND;
        SELECT count(ID) INTO num_not_intersections FROM link2 WHERE NOT EXISTS (SELECT count(st2.ID) from link2 st2 WHERE st2.FEATTYP=4120 AND SDO_ANYINTERACT(st2.geometry, rec.geometry)='TRUE'); 
        num_tot_not_intersections := num_tot_not_intersections + num_not_intersections;
      END LOOP; 
      DBMS_OUTPUT.PUT_LINE('Totally '||num_not_intersections||' rows with feattyp=4120 without intersection with feattyp=4110');
      CLOSE cur;
    END;
    /What do you think?
    thanks

  • Dynamic query for delete statement

    Hi friends,
    I have a table hierarchy where suppose i have tables with following hierarchy
    Level1
    level2 (child of level1)
    level3 (child of level2)
    level4 (child of level3)
    Now i want to delete data from lowest level table depending on level one table value which is provided to me.
    I have a requirement where i want to create this delete query dynamically.
    Any help in this concern...
    Thanks,
    Sachin

    Yon can use on delete cascade as satyaki suggested like
    SQL> select * from level1;
            ID DESCRIPTION
             1 L1_1
             2 L1_2
             4 L1_3
             5 L1_4
    4 rows selected.
    SQL> select * from level2;
            ID DESCRIPTION                                                                                           L1_FK
             1 L2_1                                                                                                  1
             2 L2_2                                                                                                  1
             4 L2_3                                                                                                  2
             5 L2_4                                                                                                  2
    4 rows selected.
    SQL> delete from level1 where id =1;
    1 row deleted.
    SQL> select * from level1;
            ID DESCRIPTION
             2 L1_2
             4 L1_3
             5 L1_4
    3 rows selected.
    SQL> select * from level2;
            ID DESCRIPTION                                                                                           L1_FK
             4 L2_3                                                                                                  2
             5 L2_4                                                                                                  2
    2 rows selected.
    SQL>

  • "ORA-21700: object does not exist or is marked for delete" select from ADT

    Posted this in OLAP section as well, but since this is Object technology, I thought I would repeat it here. Sorry about the duplication.
    BTW, I'm using Oracle9i 9.2.0.4.1.
    I'm trying to create a script that can automate the process of generating abstract data types for use in an OLAP_TABLE function. I'm following the examples in the documentation. Everything runs great the FIRST time I run my script, but when I drop my types and re-create them, when I run the next SELECT statement against the OLAP_TABLE function, I get:
    ERROR at line 1:
    ORA-21700: object does not exist or is marked for delete
    My script drops the ADTs before creating, but somehow they are not REALLY being dropped.
    SET ECHO ON
    SET SERVEROUT ON
    DROP TYPE ts_table_6;
    DROP TYPE ts_row6;
    CREATE TYPE ts_row6 AS OBJECT(
    CONJ2002 VARCHAR2(400),
    CONJ2002_DATA number(16),
    PERIOD VARCHAR2(10),
    PERIOD_NAME VARCHAR2(20));
    CREATE TYPE ts_table_6 AS TABLE OF ts_row6;
    SELECT CONJ2002, period, period_name, conj2002_data FROM TABLE(OLAP_TABLE(
    'REFVLMTA DURATION QUERY',
    'ts_table_6',
    'limit CONJ2002 to first 3',
    'MEASURE CONJ2002_DATA from CONJ2002.DATA
    DIMENSION CONJ2002 from CONJ2002
    DIMENSION PERIOD from PERIOD WITH
    ATTRIBUTE PERIOD_NAME from period.name'));
    Again, it works the first time, but not the second time. I need to bump up the ADT names to ts_row7 and ts_table_7. SQL Plus says the types are being dropped.
    Any ideas?
    Dan Vlamis [email protected]

    Hi Dan
    What append if you do a connect between the DROP and the CREATE statements?
    Chris

  • How to query for messages on JMS Queue?

    Hi All,
    What is the best way to query on a JMS Queue? I would like to query for messages based on values entered on a screen. Can this be achieved using the JMS Adapter or any other adapter?
    JDev : 11.1.1.4
    Thanks and Regards.

    Hi,
    I am not 100% clear on your requirement and what selection criteria you need. I would be surprised if you need the DB adapter. If you just want to query how much message are in the queue or other related queries for example related to header information then DB adapter can be used. This only works when JMS queue is stored in the database. Personally I have never come across this requirement.
    I suggest to look in more detail of the JMS adapter. The JMS adapter can be used to select (subscribe) to certain messages. Please read the below for more information:
    http://docs.oracle.com/cd/E17904_01/integration.1111/e10231/adptr_jms.htm#CJACBCHJ
    The message is automatically removed from the queue (implicit delete) the moment it is picked-up. I would not recommend deleting a message directly from the queue using DB adapter. What is the point of publishing the message in the first place?
    Thanks
    Sander

  • DB Adapter Polling for Delete

    Hi,
    I want to poll the Database table for delete.
    If there is delete event on table I want to capture that record.
    if anyone has idea, how to achieve this with DbAdapter Polling.
    Thanks,
    Arun Jadhav.

    Hi,
    there are 2 ways of using db polling on table.
    1. Physical delete: where you delete the record after reading the record from the table.
    2. Logical Delete: where you logically disable the record from polling after its read once. In logical delete, you actually need to take a read_flag column and update the flag value once that record is read. Say, you insert the new record--its initial read flag value will be N and after its read you update the read flag value to Y so that the same record is not read again.
    Let me know if your query is answered.
    Regards,
    Gautham

  • Marking Z table entry for Deletion

    Hi All,
    Based on some condition in my program,
    I am entrying one entry in Custom Z table.
    Also for some other condition,
    I need to mark the Table entry for deletion only, but it should not Delete.
    So pls guide me for:
    1) How to make Custom table entry as Mark for Deletion?
    2) When I put Select Query on table, how  can I write that do not Select those
        Records which are marked for  Deletion ?
    Rishi

    Hi Rishi,
    Create a new field of type 'CDXFELD' (Data Type) in the Custom Z table. Now populate that new field with 'X' if it is marked for deletion. Then you can select all those entries which that field 'CDXFELD' = Space.
    i.e., if the field 'CDXFELD' = 'X' then it is marked for deletion else not.
    Select *
      from Zcustom talbe
      in to IT_TAB
      where  CDXFELD = space.
    Hope this will help..
    Regards,
    Ravi..

  • When is query cache deleted?

    Hello All,
    I searched this forum and SAP for notes but couldn't find exactly when query cache is deleted.
    For example, we know when new data is loaded to an infocube, but what about when new master data is loaded?  If a query still has the existing transaction data loaded, but new master data is loaded (and a query output is reading and attribute), should it NOT read cache?
    What are the hard and fast rules?
    Thank you so much!

    Queries check to see if new data has been loaded to a cube/DSO since teh data has been cached. If new data has been loaded, the old cached data for that query is deleted and the new execution of the query will read the data from the database.  A new master data load would not effect the last load date on a cube/DSO, so it would not cause the the cache to be deleted for a quary on the cube/ODS.  If you had set the Master Data InfoObject to be an InfoProvider and had just a master data query (no cube/ODS), the cached master data query results should get deleted.
    As a matter of practice, Master Data should be loaded before loads to the cubes/ODS are done.
    As mentioned you can delete OLAP cache from tran RSRCACHE.  There is also a batch program you can run to delete entries from OLAP cache.  You can specify specific query results to be deleted, and you can also use it to delete all cached results that are older than a specifiied number of days.

  • Mass For Deletion of Info Record

    Dear Experts
    Is there any Code  for Deletion of the Purchasing  Info record By Mass T-code.
    Rgds
    Pankaj Agarwal

    Hi Pankaj,
    find below the steps,
    1. Flag Info-Records for deletion
    2. Run the archiving program - RM06IW30 (Menu path -> Logistics - Materials Management u2013Purchasing - Master Data - Info Record - Follow on Functions - Archive)
    Create Archive File: Info Record:
    a) Select Action: Archive and enter a new Variant, for example: Z_EINA_ARCH_ 01, press 'Maintain'
    b) On selection screen enter the data range (Vendor, Material, etc.) you want to archive.
    c) Deselect the 'Test' flag if you don't want to test first.
    d) Press green back-arrow and enter the description of this new variantt on the screen which follows.
    e) Save the variantt which brings you again to the selection screen. Press green back arrow again.
    f) To start archiving process (batch-job), press the 'Start Date' button and select the time when you want to start this process. Select 'Immediate' for instant processing and press the 'Save' button on the bottom of the Start Time' window.
    g) Select the 'Spool Parameter' button and save entries. Eventually enter a valid printer to have the result outputted.
    h) You are ready now to start the process. Press the 'Start' button and monitor the success with the 'Job Overview' button You can also go the 'fast path' by using transaction SE38, program RM06IW30 to archive info records. For large data archiving, use the background jobs and run those during off-peak times. If you run the program online, you will see a confirmation on the status bar telling 'New Archive file created:.... '
    Delete Archived Records: Info Record
    a) Follow the menu path: Tools - Administration - Administration - Archiving
    b) Select the Object Name MM_EINA for info records
    c) Select the menu button 'Delete'
    d) Select the menu button: 'Archive Selection'
    e) Click the archive created in previous step
    f) Select Start Date for process and Spool Parameters for output
    g) Submit selection.
    h) Check status by pressing the Job Overview button 
    Hope the above answers your query.
    If helpful award points
    Regards,
    Vivek

  • Query for  to get  database size, used size, freesize, db size after drop

    Pls give me a query for to get database size, used size, freesize, tablespacesize of sometables which is starting with 'RQ%'
    I have to get result like this
    Total size, used size, free size ,tablespace size of RQ tables alone
    Reason why i go for "tablespace size of RQ tables" i want to know the size of database after deleting the rq tables
    Pls reply
    S

    i tried with
    SELECT
    --fs.tablespace_name name,
    df.totalspace/1024/1024 mbytes,
    (df.totalspace - fs.freespace)/1024/1024 used,
    fs.freespace/1024/1024 free
    FROM
    (SELECT
    --tablespace_name,
    ROUND(SUM(bytes)) TotalSpace
    FROM
    dba_data_files
    ) df,
    (SELECT
    --tablespace_name,
    ROUND(SUM(bytes)) FreeSpace
    FROM
    dba_free_space
    ) fs
    i AM GETTING total bytes, used bytes, free bytes
    I WANT TO include one more column.. database size after deleting rq tables
    Pls reply
    S
    Edited by: AswinGousalya on Jul 10, 2009 2:17 PM

  • Create POWL query for specific user (not self)

    Hello All,
    was wondering if anyone had an idea on how to create a POWL query for a specific user. Even the low level method in class CL_POWL_QUERY_ACCESSOR seem to assume that you either are creating an administrator query for any/everyone or just for yourself.
    One option is to create multiple queries (for each selection criteria that I want) and assign these directly to user (rather than the role) in the config - but that's config that I'd need to transport up - for what is essentially user level personalisation.
    My strong favourite at the moment is to throw a breakpoint in CL_POWL_QUERY_ACCESSOR and manually change the user name as I save new queries in directly in production - but that's not exactly the cleanest solution.
    Surely someone has had a need to actually create queries for users, not just delete them as per program POWL_D01?
    Many thanks for any hints and tips
    Cheers,
    Chris

    Well - I should point out that you don't have to transport those user assignment of queries - tables are production maintainable. However, you do have to transport up the query itself - so not ideal.
    Oh well - don't think this one has an answer => closing it to open another question.
    Cheers,
    Chris

  • Approval Query for AP Invoices Containing Budget Related GL Account

    Hi Experts,
    I would like to create a approval template for all AP invoices that include a GL account that is related to the budget. Can you please help me with the approval query?
    Thank you!
    Jane

    Hello Gordon Du,
    "B1 approval will only apply to document level. If you want to check line level, only the first line can be subjected to."
    I was thinking to trigger the approval process based on a document (AP invoice) containing relevant cost centres on a line by line basis as entered via one of the enabled dim fields.
    Writing a trigger query for each cost centre effected? This does not appear to be a good solution, what is a better direction. Is there another way? (PO are not yet used via SAPB1)
    Currently my invoices add, but do not trigger the approval process based on my attempts thus far.
    Can the originator manually choose an approval pathway?
    If this is against posting etiquette delete and advise.
    I am a relative newbie to SAP B1, so am happy to be pointed to relevant help files. I arrived via  google searching and arrived here.
    Thankyou.

  • Determine if Object is Marked For Deletion

    Hello,
    How can I determine if an object is marked for deletion in a UnitOfWork? Is there a UnitOfWork method I can use to determine this?
    I am querying for an object that may have been deleted in the current UnitOfWork. I am trying to avoid conforming the results of the query so I can avoid hitting the database, but I must make sure I don't find objects that are marked for deletion.
    Any suggestions are appreciated.

    The UnitOfWork interface currently lacks a method available on the concrete implementation. The UnitOfWork.isObjectDeleted(object) will return true if the object has been passed into UnitOfWork.deleteObject(object). It will not include objects that are being automatically deleted at commit due to them being removed from privately-owned relationships.
    For 9.0.4.x I would have to recommend using:
    ((oracle.toplink.publicinterface.UnitOfWork) uow).isObjectDeleted(empWC)
    Beyond 9.0.4 we will have this method added to the interface so that you will not need to cast to the implementation class.
    Doug

Maybe you are looking for

  • Can't log in on a safari page

    I need to log in on a Safari page but cannot even enter my username or password. What's up?

  • Ipod Touch 5th gen won't sync after iOS update

    iPod Touch will not sync after iOS 7 update. It's stucked at "changes are being applied" and won't go past that point. Tried 5 times and got the same problem. I have the latest iTunes installed. Any suggestions?

  • FIREWIRE PORT MISSING ON MY DV6-2088DX LAPTOP

    When I tried to download film from my Camcorder, I learned that the firewire port on my dv6-2088dx laptop is optional.   I bought it at Best Buy.  It was fully loaded, and I thought that included a firewire port. I reviewed the online manual and lear

  • App gets runtime error 429 when deploying via SCCM

    I have an application I'm trying to deploy and it works fine when manually running the app (silently) on my test machine. When deploying it from SCCM and then trying to run the program you get a message saying "Run time error 429 - activex component

  • Icons Pixelated, AIM Freezing, Battery Crashing... HELP!

    I own an iBook G4 which was purchased in February of 2005. I have never had problems with the computer (with exception of the keyboard letters fading..) until a few weeks ago. The computer is running the latest version of OS X 10.3.9. The problems ca