Sql delete record where duplicate in part of raw

in sql table  i need to delete all record where the time between it  1 or 2 minute or the same and must be the same id but keep the firest record
    ID             Time                            SN   SD   WE   
FW
    10    2014-06-30 19:17:37.000    I    0    100    0
    10    2014-06-30 19:17:42.000    I    0    100    0
    10    2014-06-30 19:17:46.000    I    0    100    0
    10    2014-06-30 19:17:58.000    I    0    100    0
    10    2014-06-30 20:37:46.000    I    0    100    0
or
     ID             Time                            SN   SD   WE   
FW
    10    2014-07-01 21:10:33.000    I    0    100    0
    10    2014-07-01 21:11:06.000    O    0    100    0
    10    2014-07-02 20:53:36.000    I    0    100    0
    10    2014-07-02 20:53:38.000    I    0    100    0
    10    2014-07-02 20:54:33.000    O    0    100    0
    10    2014-07-02 20:54:41.000    O    0    100    0
    10    2014-07-02 20:55:22.000    o    0    100    0
to be
    ID             Time                            SN   SD   WE   
FW
    10    2014-06-30 19:17:37.000    I    0    100    0
    10    2014-06-30 20:37:46.000    I    0    100    0
and
    ID             Time                            SN   SD   WE   
FW
    10    2014-07-01 21:10:33.000    I    0    100    0
    10    2014-07-02 20:53:36.000    I    0    100    0

i think this
SELECT *
--DELETE t
FROM NEWFP.dbo.CHECKINOUT t
WHERE EXISTS (
SELECT 1
FROM NEWFP.dbo.CHECKINOUT
WHERE USERID = t.USERID
AND CHECKTIME < t.CHECKTIME
AND CHECKTIME >= DATEADD(minute,-5,t.CHECKTIME)
Once you're happy that it gives you the required records just comment the SELECT *, uncomment the DELETE part and execute
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Excel query/macro , delete records where the aggregate value is not over 100

    I have a spreadsheet with about 5000 records. I need to delete out the records where the Amount column is less than $10.00 unless the aggregate of the amount column is greater than or equal to $100. I have an ID column that matches to the name on the record.
    So is it possible to create something that for each ID number in the ID column if the Amount column is less than $10 delete it unless the same ID appears again and is greater than $100? TIA

    HI mkozz28,
    >> I need to delete out the records where the Amount column is less than $10.00 unless the aggregate of the amount column is greater than or equal to $100.
    In my option, you could sort the data by column ID, then loop through the column Amount, if the value of the Amount is less than 10, then find the cell according the same ID, if the Amout is less than 100, delete the enterRow.
    For more information about Find method, you could turn to the link below
    # Range.Find Method (Excel)
    https://msdn.microsoft.com/en-us/library/office/ff839746.aspx
    For the row delete, the link below might be useful to you
    # Delete Method [Excel 2003 VBA Language Reference]
    https://msdn.microsoft.com/en-us/library/office/aa223863(v=office.11).aspx
    A simple demo as below, you need to modify it to your own requirement.
    Sub test1()
    For i = 2 To 8 'row number
    Debug.Print ActiveSheet.Cells(i, 2).Value
    'ActiveSheet.Cells(i, 2).Select
    If (ActiveSheet.Cells(i, 2).Value <= 10) Then
    Set cell = ActiveSheet.Range("A1:A8").Find(ActiveSheet.Cells(i, 1).Value, After:=ActiveSheet.Cells(i, 1), LookIn:=xlValues)
    If cell Is Nothing Then
    ActiveSheet.Cells(i, 2).EntireRow.Delete
    Else
    Debug.Print ActiveSheet.Cells(cell.Row, 2).Value
    If ActiveSheet.Cells(cell.Row, 2).Value < 100 Then
    ActiveSheet.Cells(i, 2).EntireRow.Delete
    End If
    End If
    End If
    Next i
    End Sub
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • SQL: delete command for duplicate rows for any particular user

    Hello Experts,
    I've a table like below, where 'X' is the primary key.
    X Y Z
    a | p | amit
    b | q | amit
    c | r | amit
    d | p | amit
    e | s | amit
    f | p | manish
    g | t | manish
    h | p | akash
    Objective:
    Find and delete all the rows who has duplicates (for 'Y') for user 'amit'. Here, 'p' is given as an example. We don't know what the actual duplicate value is.
    Expected Result:
    rows 'a' and 'd' should be deleted
    SQL:
    ===
    select Y, count(*) from T where Z='amit'
    group by Y
    having count(Y) >1
    This query works to get the duplicates and the total count.
    However, how to delete these rows from actual table is the question. Please note that I need to run this query through a JDBC program.
    Thanks,

    You could try
    delete from tableb
      where x not in ( select max(s.x)
                        from tableb s
                        group by s.y, s.z);The easiest way I've found to build these sort of statements is to write a select first which gives you the records you want ( or not want in this case ). Then to write the delete round that statement.
    Edited by: Nigel Ren on 07-May-2011 01:23

  • Servlet sql delete record

    Hi, thanking you in advance for your help. I want to delete a record, but the following code:
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    HttpSession session = request.getSession();
    String userID = (String)session.getAttribute("edituserID");
    response.setContentType("text/html");
    PrintWriter pw = response.getWriter();
    pw.println("userID is " +userID+ "<br>");
    String connectionURL = "jdbc:mysql://localhost/cms_college";
    Connection connection=null;
    try{
    Class.forName("com.mysql.jdbc.Driver");
    connection = DriverManager.getConnection(connectionURL, "root", "");
    Statement st = connection.createStatement();
    st.executeUpdate("DELETE *from users WHERE userID="+"'"+userID+"'" );*
    *catch (Exception e){*
    *pw.println(e);*
    *pw.println("<a href='ListUserServlet.jsp'><br>Deleted</a>");*
    gives an error:
    userID is 16
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' from users WHERE userID='16'' at line 1
    Deleted

    Thanks matey. You were right. I put a * in where it wasn't needed. It's obvious now, but I just couldn't see it.

  • Does a SQL Server record delete (row or multiple related rows) stand up to the official definition of record destruction for a system that needs to meet DOD 5015.2 requirements?

    I am being asked by our records manager about whether or not when a delete occurs from SQL Server that it can stand up in court as true if we declare that the record has been destroyed and is no longer available.  In other words, are there ways in
    which forensic experts could analyse the disk and actually recover records that have been deleted from a table or tables?  If so, then we would be in error if we declare that the records have been deleted.
    Steve

    Agree with Erland here deleted records can be read from transaction log and there are tools in market which can do it unless all Virtual log file( you can consider this as small log files) which were part of that transaction has been underwritten by new
    information.  If they are still there and VLF is not reutalized it can be read. I an not exactly sure about the mechanism how it does it
    Here you gently point out a not-so-small error in my post. I said that the data would be zeroed out after the log has been truncated. But that is not the case. As you say, the data will be there until the log has run around. Which can take a long time with
    a large log file.
    Erland I dont agree to fact that Ghost cleanup task would take minutes to just clean up things in case_large chunk data_ is deleted there are of factors involved and it can take more than couple of hour(in my case it did). Actually time frame is not definite
    Yes, you are correct. I wanted to diminsh the issue with the ghost records, since they may be the smallest issue in this case. The log file, and most of all the backups are a lot more significant.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Delete records in itab1 where key fields does not exit in itab2 w/o Loop

    Hi,
    I am trying to find the most efficient way to compare two internal tables and filter out (delete) the entries in Internal Table 1 (ITAB1) where the key fields does not exist in internal table 2 (ITAB2).
    Here is the codes using the Loop.
    Loop at itab1.
      read table itab2 where field1 = itab1-field1 and field2 = itab1-field2.
      if sy-subrc ne 0.
       delete itab1 where field1 = itab1-field1 and field2 = itab-field2.
      endif.
    endloop.
    Instead of looping thru each record of ITAB1, is there a way to use the "DELETE" or other efficient way? This is in ECC 6.0.
    Thanks for any advice in advance.

    Not sure if its possible without using even a single loop. Though you can avoid the read statement this way
    loop at itab2.
    delete itab1 where field1 NE itab2-field1 and field2 NE  itab2-field2.
    endloop.

  • 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.

  • Delete records in a table and at the same time print out for reference

    I am working on a req to delete some records from a table and at the same time, record/print the deleted records in the outstream (DBMS_OUTPUT.PUT_LINE)
    DECLARE
    v_rec_po hst_po%ROWTYPE;
    BEGIN
    DELETE FROM hst_po po
    WHERE abbrpoid = '&opportunity_code'
    AND updatedby = (SELECT employeeid
    FROM tes_employee
    WHERE name = &emp_name)
    AND audittimestamp BETWEEN TO_DATE ('&start_timestamp',
    'DD-MON-YYYY HH24:MI'
    AND TO_DATE ('&end_timestamp',
    'DD-MON-YYYY HH24:MI'
    END;
    I was thinking of using returning into and then using DBMS_output to pull out the delted records, but there will be multiple rows deleted fro this statements. I am stuck here..Can anyone help

    How about:
    SQL> create table t
      2  (x int)
      3  /
    Table created.
    SQL> insert into t
      2  select rownum
      3    from all_objects
      4   where rownum <= 10
      5  /
    10 rows created.
    SQL> declare
      2     cnt pls_integer;
      3  begin
      4     delete from t;
      5     cnt := sql%rowcount;
      6     dbms_output.put_line ('Removed: '||to_Char (cnt));
      7  end;
      8  /
    Removed: 10
    PL/SQL procedure successfully completed.Edited by: Alex Nuijten on Jun 4, 2009 8:58 AM

  • What is the best approach to track deleted records

    Dear all,
    We have build a CMS platform which is based on SQL server 2012 tables structure hosted in Azure.
    We have build on top of this some REST API method in order to access data from any type of client application.
    The issues we need to solved now is what his the best way to track deleted records in order that client application gets informed through web service about deleted data from our CMS.
    We were thinking of 2 path actually :
    - having a kind of Ghost table for each of our real table where deleted records will be inserted into ( physical delete ). This would mean adding as many Ghost tables as we have production tables
    - Adding a IsDeleted flag to each of our table which will be set to true when a record is deleted from our CMS ( logical delete ). This would means adding an IsDelete field to each of our tables, create and update all our store procedure and web services
    in order to taken in account that new filter criteria to fetch our records. Quite huge job
    Will there be any other approach ?
    We are looking the best solution with minimum impact on our current solution
    reagards
    Your knowledge is enhanced by that of others.

    Hello,
    @Tom, based on your question
    "The question would be what do you need to do with the deleted records and how long do you need to keep them?"
    When records is deleted, then I simply want to delete them and informed any client application about deleted items in order to get data in Sync. I will not have any reporting on deleted data !
    The only reason of tracking delete tables items, is simply to informed client application through web service sync about the data to be ignored. Client application have a caching database records for performance reason and is is require to not used data
    from that local storage which has been reported as deleted by the SQL server on Aure.
    Does this make sense ?
    regards
    Your knowledge is enhanced by that of others.

  • How to find out query for the deleted record.

    Hi Guys,
    We are using Oracle9i release 1. We are about 5 employees who are working on the same application. All Employee are connected to the same Schema (User)
    User: Employee/web
    Now one of the user have deleted like 200,000 records from a table. We just want to trace out the query by which these records were deleted.
    From which file i can get the log of executed queries so that i can recover the data.
    Just want to know the query executed for this deletion of records?
    we are using windows server.
    Regards,
    Imran Baig

    If you do not need an exact query, but only the way you can reconstruct the data, LogMiner can be solution for you. Below I have put a simple example – you can review it if you want.
    [email protected]> create table t201 as select object_id , object_name from all_objects where rownum < 10;
    Table created.
    [email protected]> select * from t201;
    OBJECT_ID OBJECT_NAME
    17918 /1005bd30_LnkdConstant
    7540 /10076b23_OraCustomDatumClosur
    23355 /10297c91_SAXAttrList
    14204 /103a2e73_DefaultEditorKitEndP
    22920 /1048734f_DefaultFolder
    10154 /10501902_BasicFileChooserUINe
    23566 /105072e7_HttpSessionBindingEv
    23621 /106ba0a5_ArrayEnumeration
    9830 /106faabc_BasicTreeUIKeyHandle
    9 rows selected.
    [email protected]> delete t201 where object_id < 10000;
    2 rows deleted.
    [email protected]> commit;
    Commit complete.
    [email protected]> alter system switch logfile;
    System altered.
    [email protected]> select * from v$log;
    GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
    1 1 41 10485760 2 YES ACTIVE 58320830 25-MAR-06
    2 1 42 10485760 1 NO CURRENT 58348006 25-MAR-06
    3 1 40 10485760 1 YES INACTIVE 58293190 25-MAR-06
    [email protected]> select * from v$archived_log where sequence# = 41;
    RECID STAMP
    NAME
    DEST_ID THREAD# SEQUENCE# RESETLOGS_CHANGE# RESETLOGS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME BLOCKS
    ARC APP
    DEL S COMPLETIO DIC DIC END BACKUP_COUNT ARCHIVAL_THREAD# ACTIVATION#
    86 585998848
    C:\ORACLE\ORADATA\MOB92\ARCH\ARC00041.001
    1 1 41 57407039 20-MAR-06 58320830 25-MAR-06 58348006 25-MAR-06 20282
    YES NO
    NO A 25-MAR-06 NO NO NO 0 1 2555135919
    [email protected]> exec dbms_logmnr.add_logfile('C:\ORACLE\ORADATA\MOB92\ARCH\ARC00041.001',dbms_logmnr.new)
    PL/SQL procedure successfully completed.
    [email protected]> exec dbms_logmnr.start_logmnr(options => dbms_logmnr.dict_from_online_catalog)
    PL/SQL procedure successfully completed.
    [email protected]> l
    1 select sql_undo, sql_redo
    2 from v$logmnr_contents
    3 where username = 'MOB' and timestamp > sysdate - 1
    4* order by timestamp
    insert into "MOB"."T201"("OBJECT_ID","OBJECT_NAME") values ('7540','/10076b23_OraCustomDatumClosur');
    delete from "MOB"."T201" where "OBJECT_ID" = '7540' and "OBJECT_NAME" = '/10076b23_OraCustomDatumClosur' and ROWID = 'AAAIE2AAXAAAFVaAAB';
    insert into "MOB"."T201"("OBJECT_ID","OBJECT_NAME") values ('9830','/106faabc_BasicTreeUIKeyHandle');
    delete from "MOB"."T201" where "OBJECT_ID" = '9830' and "OBJECT_NAME" = '/106faabc_BasicTreeUIKeyHandle' and ROWID = 'AAAIE2AAXAAAFVaAAI';
    Best Regards
    Krystian Zieja / mob

  • Help in SQL Delete

    Hi,
    I want to delete duplicate rows from the NON KEY table A.
    Like Table A has rows
    1 A B
    2 C D
    1 A B
    3 K J
    3 K J
    Here I want to delete 1 and 3 repeated twice. I wants to delete 1 each.
    I have huge data. Can any one help me in the sql for this delete.
    Thanks,
    Madhu

    Hi, Madhu,
    Here's one way:
    DELETE     a
    WHERE     ROWID  NOT IN (
                              SELECT    MIN (ROWID)
                    FROM        a
                    GROUP BY  column1, column2
    ;This will leave one row for every distinct combination of (column1, column2); all other rows with the same combination will be DELETEd.
    You can GROUP BY as many columns as you need to.
    895553 wrote:
    ... I want to delete duplicate rows from the NON KEY table A.
    ... I have huge data. Can any one help me in the sql for this delete.It's a good idea to have a primary key for each table, especially if you have "huge data".

  • Deleting record on basis of master table ID

    Hello,
    SQL> desc news
    Name                                      Null?    Type
    NEWS_ID                                   NOT NULL NUMBER(14)
    NEWS_DATE                                          TIMESTAMP(0)
    SL_ID                                              NUMBER(2)
    HEADING                                            VARCHAR2(3120)
    DESCRIPTION                                        VARCHAR2(3900)
    SQL> desc news_location
    Name                                      Null?    Type
    NEWS_ID                                            NUMBER(14)
    COUNTRY                                            VARCHAR2(32)
    REGION                                             NUMBER(2)
    SQL> desc news_product
    Name                                      Null?    Type
    NEWS_ID                                            NUMBER(14)
    PRODUCT_CATEGORY_ID                       NOT NULL NUMBER(14)
    PRODUCT                                            VARCHAR2(27)
    SQL> desc news_service
    Name                                      Null?    Type
    NEWS_ID                                            NUMBER(14)
    SERVICE_ID                                NOT NULL NUMBER(14)
    SRVIS                                              VARCHAR2(16)
    SQL> desc news_info
    Name                                      Null?    Type
    NEWS_ID                                            NUMBER(14)
    SOURCE                                             VARCHAR2(203)
    ORIGIONAL_NEWS                                     VARCHAR2(3900)
    HEADING                                            VARCHAR2(3110)
    SQL> select count(*) from news where TO_CHAR(news_date,'YYYY') <  2012;
      COUNT(*)
          8759I am trying to delete news that are published before 2012 but detail tables consists child record on basis of news_id. Certainly simple delete query will not work
    Please advise and thanks in anticipation

    Thanks again for favorable replies
    SQL> alter table news_info drop constraint NEWS_INFO_FK;
    Table altered.
    SQL> alter table news_info add constraint NEWS_INFO_FK FOREIGN KEY (news_id) REF
    ERENCES   news(news_id) on delete cascade enable novalidate ;
    Table altered.
    SQL> alter table news_info modify constraint NEWS_INFO_FK validate ;
    Table altered.
    SQL> alter table news_location drop constraint NEWS_LOCATION_FK;
    Table altered.
    SQL> alter table news_location add constraint NEWS_LOCATION_FK FOREIGN KEY (news
    _id) REFERENCES   news(news_id) on delete cascade enable novalidate ;
    Table altered.
    SQL> alter table news_location modify constraint NEWS_LOCATION_FK validate ;
    Table altered.
    SQL> alter table news_PRODUCT drop constraint NEWS_PRODUCT_FK;
    Table altered.
    SQL> alter table news_PRODUCT add constraint NEWS_PRODUCT_FK FOREIGN KEY (news_i
    d) REFERENCES   news(news_id) on delete cascade enable novalidate ;
    Table altered.
    SQL> alter table news_PRODUCT modify constraint NEWS_PRODUCT_FK validate ;
    Table altered.
    SQL> alter table news_SERVICE drop constraint NEWS_SERVICE_FK;
    Table altered.
    SQL> alter table news_SERVICE add constraint NEWS_SERVICE_FK FOREIGN KEY (news_i
    d) REFERENCES   news(news_id) on delete cascade enable novalidate ;
    Table altered.
    SQL> alter table news_SERVICE modify constraint NEWS_SERVICE_FK validate ;
    Table altered.
    SQL> delete from news where TO_CHAR(news_date,'YYYY') <  2008 ON DELETE CASCADE;
    delete from news where TO_CHAR(news_date,'YYYY') <  2008 ON DELETE CASCADE
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    SQL> select constraint_name, constraint_type, table_name, delete_rule
      2    from user_constraints
      3   where constraint_name= 'NEWS_SERVICE_FK';
    CONSTRAINT_NAME                C TABLE_NAME                     DELETE_RU
    NEWS_SERVICE_FK                R NEWS_SERVICE                   CASCADE
    SQL> select constraint_name, constraint_type, table_name, delete_rule
      2    from user_constraints
      3   where constraint_name= 'NEWS_PRODUCT_FK';
    CONSTRAINT_NAME                C TABLE_NAME                     DELETE_RU
    NEWS_PRODUCT_FK                R NEWS_PRODUCT                   CASCADE
    SQL> select constraint_name, constraint_type, table_name, delete_rule
      2    from user_constraints
      3   where constraint_name= 'NEWS_LOCATION_FK';
    CONSTRAINT_NAME                C TABLE_NAME                     DELETE_RU
    NEWS_LOCATION_FK               R NEWS_LOCATION                  CASCADE
    SQL> select constraint_name, constraint_type, table_name, delete_rule
      2    from user_constraints
      3   where constraint_name= 'NEWS_INFO_FK';
    CONSTRAINT_NAME                C TABLE_NAME                     DELETE_RU
    NEWS_INFO_FK                   R NEWS_INFO                      CASCADE
    SQL> delete from news where TO_CHAR(news_date,'YYYY') <  2008 ON DELETE CASCADE;
    delete from news where TO_CHAR(news_date,'YYYY') <  2008 ON DELETE CASCADE
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    SQL>Edited by: Christy H. on Jan 17, 2013 1:58 AM
    I removed ON DELETE CASCADE and ran again delete from news where TO_CHAR(news_date,'YYYY') <  2008; Wow deleted!!
    This forum is miracle to learn oracle. Thanks from the bottom of my heart

  • Deleting records in a table based a collection

    I wanna delete records in a table which do not match the records in the collection.
    Since the collection is a pl/sql collection I cannot do it like
    v_t v_type;
    DELETE FROM sample WHERE flex_name NOT IN (SELECT * FROM TABLE(v_type(SELECT * FROM v_t)));
    is there any other alternative to do the same ?

    Hi
    please use this code it is working
    DATA :
       BEGIN OF fs_itab,
          first(2) TYPE c,
          second TYPE c,
          third TYPE c,
          fourth(2) TYPE c,
       END OF fs_itab.
    DATA :
    t_itab LIKE STANDARD TABLE OF fs_itab.
    CLEAR fs_itab.
    fs_itab-first = 'AA'.
    fs_itab-second = 'Z'.
    fs_itab-third = 'Y'.
    fs_itab-fourth = 'AA'.
    APPEND fs_itab TO t_itab.
    CLEAR fs_itab.
    fs_itab-first = 'AA'.
    fs_itab-second = 'Z'.
    fs_itab-third = 'Y'.
    fs_itab-fourth = 'AA'.
    APPEND fs_itab TO t_itab.
    CLEAR fs_itab.
    fs_itab-first = 'AA'.
    fs_itab-second = 'Z'.
    fs_itab-third = 'Y'.
    fs_itab-fourth = 'CC'.
    APPEND fs_itab TO t_itab.
    CLEAR fs_itab.
    fs_itab-first = 'BB'.
    fs_itab-second = 'P'.
    fs_itab-third = 'Q'.
    fs_itab-fourth = 'DD'.
    APPEND fs_itab TO t_itab.
    CLEAR fs_itab.
    fs_itab-first = 'BB'.
    fs_itab-second = 'P'.
    fs_itab-third = 'Q'.
    fs_itab-fourth = 'BB'.
    APPEND fs_itab TO t_itab.
    LOOP AT t_itab INTO fs_itab.
      IF fs_itab-first NE fs_itab-fourth.
        DELETE TABLE t_itab FROM fs_itab.
      ENDIF.
    ENDLOOP.
    LOOP AT t_itab INTO fs_itab.
      WRITE :
         / fs_itab-first,
           fs_itab-second,
           fs_itab-third,
           fs_itab-fourth.
    ENDLOOP.
    Regards
    Pavan

  • [DW MX 2004] DELETE RECORD

    Hi,
    I can't DELETE RECORD in LOCAL SERVER (MySQL Server 5.0)
    and REMOTE SERVER , but INSERT AND UPDATE WORKS.
    Page code is
    <?php require_once('../Connections/connpuntofermo.php');
    ?>
    <?php
    session_start();
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";
    // *** Restrict Access To Page: Grant or deny access to this
    page
    function isAuthorized($strUsers, $strGroups, $UserName,
    $UserGroup) {
    // For security, start by assuming the visitor is NOT
    authorized.
    $isValid = False;
    // When a visitor has logged into this site, the Session
    variable
    MM_Username set equal to their username.
    // Therefore, we know that a user is NOT logged in if that
    Session
    variable is blank.
    if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only
    certain
    users based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
    $isValid = true;
    // Or, you may restrict access to only certain users based
    on their
    username.
    if (in_array($UserGroup, $arrGroups)) {
    $isValid = true;
    if (($strUsers == "") && true) {
    $isValid = true;
    return $isValid;
    $MM_restrictGoTo = "index.php";
    if (!((isset($_SESSION['MM_Username'])) &&
    (isAuthorized("",$MM_authorizedUsers,
    $_SESSION['MM_Username'],
    $_SESSION['MM_UserGroup'])))) {
    $MM_qsChar = "?";
    $MM_referrer = $_SERVER['PHP_SELF'];
    if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
    if (isset($QUERY_STRING) && strlen($QUERY_STRING)
    > 0)
    $MM_referrer .= "?" . $QUERY_STRING;
    $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar .
    "accesscheck=" .
    urlencode($MM_referrer);
    header("Location: ". $MM_restrictGoTo);
    exit;
    ?>
    <?php
    function GetSQLValueString($theValue, $theType,
    $theDefinedValue = "",
    $theNotDefinedValue = "")
    $theValue = (!get_magic_quotes_gpc()) ?
    addslashes($theValue) : $theValue;
    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" :
    "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) .
    "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" :
    "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue :
    $theNotDefinedValue;
    break;
    return $theValue;
    if ((isset($_GET['ID'])) && ($_GET['ID'] != "")) {
    $deleteSQL = sprintf("DELETE FROM news WHERE ID=%s",
    GetSQLValueString($_GET['ID'], "int"));
    mysql_select_db($database_connpuntofermo, $connpuntofermo);
    $Result1 = mysql_query($deleteSQL, $connpuntofermo) or
    die(mysql_error());
    $deleteGoTo = "ok-cancella.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
    header(sprintf("Location: %s", $deleteGoTo));
    mysql_select_db($database_connpuntofermo, $connpuntofermo);
    $query_rs_elenco = "SELECT ID, `data`, titolo FROM news ORDER
    BY ID DESC";
    $rs_elenco = mysql_query($query_rs_elenco, $connpuntofermo)
    or
    die(mysql_error());
    $row_rs_elenco = mysql_fetch_assoc($rs_elenco);
    $totalRows_rs_elenco = mysql_num_rows($rs_elenco);
    ?>
    <html><!-- InstanceBegin
    template="/Templates/template-adm.dwt"
    codeOutsideHTMLIsLocked="false" -->
    <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>amministrazione Piadineria Punto
    Fermo</title>
    <!-- InstanceEndEditable --><meta
    http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1"><style
    type="text/css">
    <!--
    body {
    background-color: #CCD57B;
    margin-bottom: 0px;
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    -->
    </style>
    <link href="../css/style.css" rel="stylesheet"
    type="text/css">
    <style type="text/css">
    @import "news/domnews.css";
    </style>
    <script type="text/javascript"
    src="news/domnews.js"></script>
    <!-- InstanceBeginEditable name="head" --><!--
    InstanceEndEditable -->
    </head>
    <body>
    <table width="100%" height="100%" border="0"
    align="center" cellpadding="0"
    cellspacing="0">
    <tr>
    <td align="center" valign="middle"><table
    width="760" height="430"
    border="0" align="center" cellpadding="0" cellspacing="1"
    bgcolor="#A7B339">
    <tr>
    <td width="779" align="left" valign="middle"
    bgcolor="#FFFFCC"><table width="760" height="334"
    border="0" cellpadding="0"
    cellspacing="0">
    <tr>
    <td align="center"
    class="body"><strong>AMMINISTRAZIONE SITO
    PUNTO FERMO </strong></td>
    </tr>
    <tr>
    <!-- InstanceBeginEditable name="header" --><td
    height="42"
    align="center" valign="top" class="body"><a
    href="menu.php"
    class="body">torna
    a men&ugrave; principale </a></td>
    <!-- InstanceEndEditable --> </tr>
    <tr>
    <!-- InstanceBeginEditable name="body" -->
    <td align="center" valign="top"
    class="body"><p>ELENCO NEWS
    INSERITE</p>
    <table width="505" border="0" cellpadding="5"
    cellspacing="1"
    bgcolor="#999999" class="body">
    <tr bgcolor="#FFFFA8">
    <td>ID</td>
    <td width="104">DATA</td>
    <td width="134">TITOLO</td>
    <td width="110"> </td>
    <td width="112"> </td>
    </tr>
    <?php do { ?>
    <tr align="left" valign="top" bgcolor="#FFFFCC">
    <td><?php echo $row_rs_elenco['ID'];
    ?></td>
    <td><?php echo $row_rs_elenco['data'];
    ?></td>
    <td><?php echo $row_rs_elenco['titolo'];
    ?></td>
    <td><a href="mod-news.php?ID=<?php echo
    $row_rs_elenco['ID']; ?>"
    class="body">MODIFICA</a></td>
    <td><form name="elimina1" method="post"
    action="">
    <input type="submit" name="Submit" value="ELIMINA">
    </form></td>
    </tr>
    <?php } while ($row_rs_elenco =
    mysql_fetch_assoc($rs_elenco)); ?>
    </table>
    <p>  </p></td>
    <!-- InstanceEndEditable --> </tr>
    <tr>
    <td> </td>
    </tr>
    </table></td>
    </tr>
    </table> </td>
    </tr>
    </table>
    </body>
    <!-- InstanceEnd --></html>
    <?php
    mysql_free_result($rs_elenco);
    ?>
    Where is error?
    Thanks.

    MX 2004 was always a bit "gummy" on this.  Instead of using the DW wizard, I downloaded a free version of Microsoft SQL Server Express Edition.  I use that for all table Inserts, Updates,etc.   This accesses the tables directly on the server.  Nothing needs to be synced, put, gotten or whatever.  Use DW for Form and UI creation and making prebuilt queries.
    Hope that helps
    Jerry H

  • Unable to find the deleted record in the child table

    Hi,
    I have two tables and a trigger:
    CREATE TABLE parent (a INTEGER, b CHAR(10));
    CREATE TABLE child (c CHAR(10), d INTEGER);
    CREATE TRIGGER parent_trigger
    AFTER INSERT OR DELETE OR UPDATE ON parent
    REFERENCING NEW AS newRow
    FOR EACH ROW
    BEGIN
    INSERT INTO child VALUES(:newRow.b, :newRow.a);
    END parent_trigger;
    Now my point is , after insertion or updation of the records in the parent table, the records are created successfully in child table...
    BUT.. on deleting a record the record is deleted successfully from parent table..but the record is not displayed in the child table.
    SQL> delete from parent where A=2;
    1 row deleted.
    SQL> select * from parent;
    no rows selected
    SQL> set feedback on
    SQL> select * from child;
    C D
    a 1
    a 2
    3 rows selected.
    Please help.

    What's the value of :NEW variables after deletion? NULL! What gets inserted into your child table? You guess it... :)

Maybe you are looking for

  • I cant connect my iphone 4 to any PC/MAC help??

    For some reason my iphone 4 will not be recognised by my mac or pc, ive never had this problem but i bought an album so wanted to synch with my mac and it dosnt even charge my iphone, its like its not even plugged in, i decided to try on  my PC and i

  • Automation error while using GetHierarchy

    Hi I have a hierarchical table name "Organization" in my MDM repository. I am using the following VB code to get the hierarchy. The system gives me "Automation error" (cat object is successfully initialized)     Dim oNode As TreeNode     oNode = cat.

  • VMWare Guests can't bridge in to Wifi

    Network setup: WLC4402, 1141 APs.  DHCP is required on all SSIDs.  A co-worker has a setup where his laptop runs VMWare and is attached to Wifi.  On his guest Virtual Machines, he notices that they work fine when in NAT mode, but when he tries to bri

  • How to have Flash movie resize with rest of webpage

    Hi, I ran a search for this but couldn't find anything. Is there code I can write into my webpage (using dreamweaver) that will make my flash movie get larger along with the rest of my webpage when the viewer zooms their internet explorer 8 browser?

  • Problems with PSE for Mac Trial - Downloaded it and cannot find it

    I am fairly computer savvy, but new to Mac.  I had PSCS2 on my old PC and with the conversion to Mac I was going to go for PSE8 (since a lot of the things I use PS for weren't available in PSE when I bought CS2, but are now available with PSE8).  I d