Walk thru all database table records until match is found then delete

I have a database connected form. It has a scipt that checks to see if that forms data has already been submitted by searching thru the records for the formID number. I want the records to be deleted if found and then add new records incase the form data has been changed. I can make this work once by using the script below. Is there a short way to make it continue searching and deleting all the records that start with that form ID number instead having to copy this script 12 times (maximum number of records allowed).
var oFile = Subform1.FileName.formattedValue;
var bFound = false;
while(!oDB.isEOF()){
if(xfa.record.DataConnection2.FileName.value == oFile){
bFound = true;
break;
oDB.next();
if(bFound){ 
oDB.delete();
oDB.update();

types : begin of ty_jtab,
       f1(10) type c,
       end of ty_jtab.
data : jtab type standard table of ty_jtab with header line,
       itab type standard table of ty_jtab with header line.
data : wa_jtab type  ty_jtab,
       wa_itab type  ty_jtab.
*populate itab for say db
itab-f1 = '1000'. append itab.
itab-f1 = '2000'. append itab.
itab-f1 = '3000'. append itab.
*populate jtab
jtab-f1 = '1000'. append jtab.
jtab-f1 = '4000'. append jtab.
jtab-f1 = '8000'. append jtab.
jtab-f1 = '9000'. append jtab.
sort itab by f1.
sort jtab by f1.
clear: itab, wa_itab.
loop at itab into wa_itab.
  read table jtab into wa_jtab with key f1 = wa_itab-f1
                                         binary search.
  if sy-subrc ne 0.
    delete itab from wa_itab.
    if sy-subrc ne 0.
      write :/ 'fail', wa_itab-f1.
    endif.
  endif.
endloop.
*o/p is two times fail which shows the assumption.
br,
vijay

Similar Messages

  • Is there a way to select all emails at once on the iPad and then delete them at one time?

    Is there a way to select all emails at once on the iPad and then delete them at one time?

    Tap on the edit button at  the top right of the email list. This will let you select the emails to delete, once all are selected, tap on the bottom right button that says delete to delete them all at once.

  • How to print database table records in graphical format?

    In ABAP Editor,I put select query on one database table and fetch few records .Now I want to show these records in BAR Graph / pie chart.Kindly let me know is it possible and how?
    Thanks in advance.
    Edited by: rushah on May 21, 2009 5:30 AM

    Hi Hadiman,
    Can you please elaborate more on it.
    Like my code is......
    SELECT * FROM trfcqout
      INTO CORRESPONDING FIELDS OF itab
      WHERE ( qstate = 'SYSFAIL' OR qstate = 'CPICERR' OR errmess <> '' )
    and ( QRFCDATUM >= date-low and QRFCDATUM <= date-high ).
        count = 0.
        if itab is not initial.
          SELECT * FROM trfcqout
          INTO CORRESPONDING FIELDS OF itab1
          WHERE qname = itab-qname AND errmess = ''.
            count = count + 1.
          ENDSELECT.
          itab-retrydate = sysdate.
          itab-retrytime = systime.
          itab-qtype = 'OUTBOUND'.
          itab-nentries = count - 1.
          append itab.
          MODIFY zqueue FROM itab.
        endif.
      ENDSELECT.
    Print details on Report
      write: / sy-vline no-gap,(7) 'QTYPE' COLOR 1, sy-vline no-gap,(23)
    'QNAME' COLOR 1,sy-vline no-gap,(14) 'QSTATE' COLOR 1, sy-vline no-gap,
    (54) 'Error' COLOR 1,sy-vline no-gap,(10) 'Number' COLOR 1.
      uline.
      LOOP AT itab.
        write: /   sy-vline no-gap,  (8)  itab-qtype no-gap,
                   sy-vline no-gap,  (24) itab-qname no-gap,
                   sy-vline no-gap,  (15) itab-qstate no-gap,
                   sy-vline no-gap,  (55) itab-errmess no-gap,
                   sy-vline no-gap,  (10) itab-nentries no-gap.
      ENDLOOP.
      uline.
      refresh itab.
    endform.                    "queuedata
    Now I want to print data in graphical form. how to do that?

  • Z database table needs to have field creation/update/deletion tracked

    Hi,
    I have a Z database table.
    I have a program that gets data from an excel file and uploads the content to the Z database table.
    I need to track the creation/update/deletion of the records in the Z database table.
    The Z database table can also have records changed/updated/deleted manually thru table maintenance. These changes also need to be tracked.
    How do I do this?
    ~ Eric

    Hi
    For a my z-table (called ZFAGTD01), I created the object for change documents, this is the log after generating it:
    Change documents: Display information about generated sources                                                                               
    Change doc. object Z_PROAGE_PRV                                                                               
    Generation on      23.07.2004 11:51:28                                 
                of     SVIL01                                                                               
    Include programs and function modules                                  
    Data declaration, TOP...................... FZAGPCDT                   
    Consisting of............................. FZAGPCDF                   
    and....................................... FZAGPCDV                   
    Update function module..................... Z_PROAGE_PRV_WRITE_DOCUMENT
    Call update function module................ FZAGPCDC                                                                               
    Dictionary structures                                                  
    VZFAGTD01
    Just as you see, the system has created the fm and some includes containing all data it needs to call the fm.
    So u need only to use those includes, just only u need to consider before calling the fm u need to fill:
    - The change flag: usually called UPD_<Z table>;
    - Fill the header Y<ZTABLE> of z-table with old data;
    - Fill the header X<ZTABLE> of z-table with new data;
    - Fill the variables   TCODE, UTIME,  UDATE,  USERNAME,
    - Fill the variable OBJECTID with the key of Z-table
    For example my object is used in my program in this way:
    FORM INSERT_CHANGE_DOCUMENT.
      CHECK FL_CHANGE_DOC = 'X'.
      CHECK SY-SUBRC = 0.
      CONCATENATE XZFAGTD01-MANDT XZFAGTD01-BUKRS XZFAGTD01-GJAHR
                                              XZFAGTD01-BELNR INTO OBJECTID.
      TCODE = SY-TCODE.
      UTIME = SY-UZEIT.
      UDATE = SY-DATUM.
      USERNAME = SY-UNAME.
    * Load old data: header
      IF ZFAGTD0K IS INITIAL.
        CLEAR YZFAGTD0K.
      ELSE.
        SELECT SINGLE * INTO YZFAGTD0K
                        FROM ZFAGTD0K WHERE BUKRS   = XZFAGTD01-BUKRS
                                        AND GJAHR   = XZFAGTD01-GJAHR
                                        AND BELNR   = XZFAGTD01-BELNR.
      ENDIF.
    * Load old data: items
      SELECT * INTO TABLE YZFAGTD01 FROM ZFAGTD01
                                FOR ALL ENTRIES IN XZFAGTD01
                                       WHERE BUKRS   = XZFAGTD01-BUKRS
                                          AND GJAHR   = XZFAGTD01-GJAHR
                                          AND BELNR   = XZFAGTD01-BELNR
                                          AND POSNR_P = XZFAGTD01-POSNR_P.
      SORT: XZFAGTD01 BY POSNR_P,
            YZFAGTD01 BY POSNR_P.
    * Check if heade was changed
      IF YZFAGTD0K <> ZFAGTD0K.
        UPD_ZFAGTD0K = 'U'.
      ELSE.
        CLEAR UPD_ZFAGTD0K.
      ENDIF.
      UPD_ZFAGTD01 = 'U'.
      PERFORM CD_CALL_Z_PROAGE_PRV.
      REFRESH XZFAGTD01.
    ENDFORM.                    " INSERT_CHANGE_DOCUMENT
    Max

  • How to automate creation of MS Access databases/tables/records

    Can someone point me to some examples that automate the creation of MSAccess database files and tables?
    Can I do this with a bat file? If not, a ps1 file?
    I bing searched and could not find an example.
    I want to test the existence of a mdb (or accdb) file and if it does not exist, create it.
    Then I want to see if that mdb (or accdb) file contains a table named "parts".
    If it does not contain that table named "parts", create the table.
    If that table does not contain any records, than add some sample data, presumably with some SQL "INSERT" statements.
    What is the preferred API for this? I was thinking we should use the ADO.NET/OleDB API. I did find a few examples of queries of MSAccess databases with the old ADO API.
    ADOX seems very old for creating databases. Is there any thing more modern?
    Is powershell the easiest scripting language to do this?
    Thanks
    Siegfried
    siegfried heintze

    This blog post should have most (if not all) of what you need:
    http://blogs.technet.com/b/heyscriptingguy/archive/2009/02/16/how-can-i-use-windows-powershell-to-create-an-office-access-database.aspx
    One thing to watch out for is the db provider for the connection string.  The "Jet Engine" has been superseded by
    ACE.

  • Reg : Joining the all internal table records into a single internal table

    Hi all
    I am having 5 internal tables and i want to put all these entries in a single intrnal table and my requirement is for each and every record it has to go through all the internal tables and if an entry is missing meand.it has to go through the other internal tables and for missing entries i should leave it as blank and rest of the contents i have to display can any please gimme some logic how to do this??
    Thanks in advance

    Don't have time or will to deliver turnkey solutions, but here is a frame:
    LOOP AT itab1...
      READ TABLE itab2 WITH TABLE KEY... (fields linking itab1 and itab2)
      READ TABLE itab3 WITH TABLE KEY... (fields linking itab1 and itab3)
      LOOP AT itab4 WHERE... (fields linking itab1 and itab4)
        READ TABLE itab5 WITH TABLE KEY... (fields linking itab4 and itab5)
        MOVE-CORRESPONDING... (all five work areas to target work area)
        APPEND itabtarget...
      ENDLOOP.
    ENDLOOP.
    so use READ when there is a 1:1 relationship (e.g. check table entry), and LOOP when there is a 1:N relationship (e.g. items for a header)
    Thomas

  • Deleting a MS Access database table record using JOptionPane

    hi!
    just want some help here..
    is there a way to delete a MS Access database record through using JOptionPane?? i've gone through some, probably alot of examples on SELECT, INSERT, UPDATE, DELETE statements but none came up to the stuff i need.
    so far i've seen the DELETE statement like this and also this is a common DELETE statement..
    statement.executeUpdate("DELETE FROM tableName WHERE fieldName01 = 'blablabla' AND fieldName02 = 'etcetcetc'");like INSERT, there's a coding somewhat like this:
    String asd = JOptionPane.showInputDialog(null, "Enter blablabla stuff");
    statement.executeUpdate("INSERT INTO whatEverTableName (tableFieldName) VALUES('"+asd.getText()+"')");so, is it possible using the same method for DELETE??
    help and advices are appreciated in advanced..

    Here's how I did it. Research does help, but sometimes looking at others code does too... You do have to have a dummy file that you made with access though. You can't just make a file file.mdb (it will be corrupt)
         public void createDatabase(String database) throws SQLException{
              try{
                   // This file needs to have been created with MS Access
                   File dbfile = new File(this.dataBaseDir + "dummy.mdb");
                   // This is the new database file being made
                   File newFile = new File(this.dataBaseDir + database + ".mdb");
                   // Copy all bytes from dummy file to new DB file.
                   FileInputStream instream = new FileInputStream(dbfile);
                   FileOutputStream ostream = new FileOutputStream(newFile);
                   int numBytes = instream.available();
                   byte inBytes[] = new byte[numBytes];
                   instream.read(inBytes, 0, numBytes);
                   ostream.write(inBytes, 0, numBytes);
              catch(FileNotFoundException e) { e.printStackTrace();}
              catch(IOException e) { e.printStackTrace();}
              if(DEBUG) System.out.println("creating the " + database + " database");
         }

  • What do you suggest me for task "please comment up all database tables"

    I have in Oracle 10g database in one schema ca 600 ("business") tables created. Most of those tables don't have comments.
    I don't understands most of the tables, and no one does. Can you give me some hints, how i should start to comment those tables?
    I just want to put firstly comments to tables, later i will comment columns.
    I understand that some tables are with mandatory data to the System, something like table ala "SystemRights" would sound to be with mandatory 3 rows that are needed for System to run up. some tables doesn't contains mandatory data for the System, like ala "UserOptions" which sounds like it contains data that User has inserted for herself, so this data is not important for the System. I could maybe distinguish between tables other way, maybe some other hints are important to clarify the purpose of the table.
    Can you suggest something helpful how i should do the commenting of those 600 tables?
    If you are amazes that there doesn't exist not much persons who could know the porpouse of the tables, then you shouldn't be amazed, take this as reality.
    I won't dig into Java code that uses those tables, i believe there wont be much comments either anyway.

    Should i do so:
    1. run query to get table listing:
    SELECT 'select * from ' || t.Table_Name t, c.Comments, COUNT(*) Over() Cnt
    FROM User_Tables t, User_Tab_Comments c
    WHERE c.Table_Name = t.Table_Name
    ORDER BY t.Table_Name;2. From table list take one table into attention.
    3. Run "select * from" to see data of the table.
    4. Now look the data and look the table name and try to figure out what the data represents.
    5. Then open table definition in Tool/IDE to see if table contains FK-columns. Open the tables pointing by FK-keys and to light analyzing of them.
    6. Now look the data of the table again and figure out the porpouse of the table and write it down as table comment.

  • All of a sudden, after installing "avery" program, then deleting it because it inserted "ask" search feature, NOW I am missing the line at the top that has the WEB ADDRESS, BACK BUTTON, HOME BUTTON ETC. NONE OF THESE ARE THERE, HOW DO I GET THEM BACK?

    I have Windows XP.
    my home page is Google. this is coming up, but without the web address area and all the buttons at top such as back arrow, forward arrow, refresh, etc . all those things that are usually there are not there. I cannot type in a web address. I can only get to an address by typing it into the google search window in middle of the page, even if I know the web address because there is nowhere to type the web address! How do I get this important line back on the screen!! thanks !

    Please read this article to see if it helps:
    http://support.mozilla.com/en-US/kb/Back+and+forward+or+other+toolbar+items+are+missing

  • Retrive last inserted  record  from database table

    Hi,
    some body inserting a record into table 'A' through some procedure/java program.i want to retrive the last inserted record from database table.records are not stored in order.Can any body help me.

    In general, unless you are storing a timestamp as part of the row or you have some sort of auditing in place, Oracle has no idea what the "first" or "last" record in a table is. Nor does it track when a row was inserted.
    - If you have the archived logs from the point in time when the row was inserted, you could use LogMiner to find the timestamp
    - If the insert happened recently (i.e. within hours), you may be able to use flashback query to get the value
    - If you're on 10g or later and the table was built with ROWDEPENDENCIES and the insert happened in the last few days and you can deal with a granularity of a few seconds and you don't need 100% accuracy, you could get the ORA_ROWSCN of the row and convert that to a timestamp.
    If this is something you contemplate needing, you need to store the data in the row or set up some sort of auditing.
    Justin

  • Database tables in SD

    Please let me know what all database tables are used to store the data in the entire cycle of SD.
    Thanks in advance,
    Vs

    Hi,
    Sales and Distribution:
                      Table  Description
    Customers         KNA1   General Data
                      KNB1   Customer Master – Co. Code Data (payment method, reconciliation acct)
                      KNB4   Customer Payment History
                      KNB5   Customer Master – Dunning info
                      KNBK   Customer Master Bank Data
                      KNKA   Customer Master Credit Mgmt.
                      KNKK   Customer Master Credit Control Area Data (credit limits)
                      KNVV   Sales Area Data (terms, order probability)
                      KNVI   Customer Master Tax Indicator
                      KNVP   Partner Function key
                      KNVD   Output type
                      KNVS   Customer Master Ship Data
                      KLPA   Customer/Vendor Link
    Sales Documents   VBAKUK VBAK + VBUK
                      VBUK   Header Status and Administrative Data
                      VBAK   Sales Document - Header Data
                      VBKD   Sales Document - Business Data
                      VBUP   Item Status
                      VBAP   Sales Document - Item Data
                      VBPA   Partners
                      VBFA   Document Flow
                      VBEP   Sales Document Schedule Line
                      VBBE   Sales Requirements: Individual Records
    SD Delivery DocumeLIPS   Delivery Document item data, includes referencing PO
                      LIKP   Delivery Document Header data
    Billing Document  VBRK   Billing Document Header
                      VBRP   Billing Document Item
    SD Shipping Unit  VEKP   Shipping Unit Item (Content)
                      VEPO   Shipping Unit Header
    Thanks
    Hussain

  • To find all the child records are processed before parent records

    Hi,
    When i am trying to process consignment pulls and my client is using third party tool to insert the data into interface tables. My logic is written in such a way that it should pick parent record associated with child but there is some delay in child records and not all the child records are being pulled with parent.
    In a brief, i need to write a condition in such a way that my parent cursor should pick all the child records with max(last_updated_date) and then it should be processed.
    eg: I have a family and need to catch bus with all my family members. I need to check now for the last family member who get into and should wait for atleast 2mins so as to ensure all my family members are in. I am unable to achieve this with count. Please do revert back soon.
    Details are below:
    CURSOR c_pull (p_pull_id NUMBER) IS----------------------------------parent cursor
    SELECT ecp.ROWID ROW_ID
    ,ecp.*
    FROM consignment_pulls ecp
    WHERE ecp.process_flag IN ( 2, 3 )
    AND ecp.pull_id > NVL(p_pull_id,0)
    ORDER BY ecp.pull_id
    FOR UPDATE OF ECP.PROCESS_FLAG NOWAIT;
    CURSOR c_line (p_pull_id NUMBER) IS----------------------------------child cursor
    SELECT ecpi.ROWID ROW_ID
    ,ecpi.*
    FROM consignment_pull_items ecpi
    WHERE ecpi.process_flag IN ( 2, 3 )
    AND ecpi.pull_id = p_pull_id
    FOR UPDATE OF ecpi.process_flag;
    Edited by: Prathyusha on Apr 5, 2012 12:07 AM
    Edited by: jerry on Apr 5, 2012 12:10 AM

    Hi Helios,
    Thanks for the info. But its not a concurrent request something like we can filter with start date and completion date. Its all about selection of records from headers and lines table and not able to make those selection of header records with a delay of say some 2minutes until all the child records are inserted.
    Thanks,
    Prathyusha.

  • Database Table cannot be found when Verify Database

    Post Author: brentlaw
    CA Forum: Other
    I have been using CRW 7 for many years.  I recently upgraded to XI (I have current version).  I can open existing reports and create new reports fine.  The problem is when I Verify Database I get an error message "The Database table <tablename here> cannot be found. Remove this table from the report". 
    This happens to all existing and new created reports.  The data fills correctly when previewing.  The problem only occurs when Verifying Database. 
    I thought it might be an ODBC driver problem so I upgraded my driver to v 3.525.1117.  At least I think I upgraded it I did not check the version before I installed SQL 2005 SP2.  After installing SP2 it seemed to be fine but a week later the problem came back.  Mysterious eh?
    I am trying to launch a report from VB6 using RDC and rpt file.  I get logged in correctly but at .viewreport I get a generic error message.  I am assuming the problem is related the the issue I raise in this forum post.

    Post Author: brentlaw
    CA Forum: Other
    I fixed the problem.  In CR XI Developer Designer window I opened up Database-SetDataSourceLocation.  I noticed that in "Properties" the last item "Use DSN Default Properties": was set to True.  I changed this value to False.  Now this problem is solved.
    I am Not using Windows Authentication I am using SQLServer authentication.  In my code I was passing SQLServer Authentication credentials. 
    I opened up all of my CR 7 reports in CR XI and changed this setting on both the Main and the Subreort property in the SetDataSourceLocation dialog box and now all my reports work.  I am a happy camper.
    I don't know if this is a CR 7 conversion to CR XI only situation or not.  Hope this information helps someone else.

  • How to modify or put entry in a particular field of a database table

    i want to to modify a field in a database table record identification by primary key fileds
    the situatio is like this
    there are two primay key in database table
    customer number PK
    status PK
    date
    and third field which i want to modify is customer part number.
    based on condition that
    database table1-cuspip = wa_record-cuspip.
    database table1-status <> wa_record-status
    and database table-date = wa_record-date
    if above is true a particular field  the database table  for that record
    ie customer_part_number = 'FAiled'.
    loop at it_record into wa_Record
    endloop.
    please suggest how to modify the database table record if the avove condition is tru and please give me full working code
    regards
    Arora

    Dear Nishant,
    Use UPDATE function for updating the customer part number.
    But please do mention the database table and the keys used for update.
    if en entry already exists with the key then the Entry will fail so use MODIFY statement to modify the Consumber Part Number  with the specificed keys  and transport the modified customer part number and then do COMMIT the changed entry to database.
    Hope this helps you in some way.
    Encourage others to answer you queries by suitably rewarding them.
    Thanks
    Venugopal

  • Which is better:search JTables or search Database tables?

    greetings all
    i have UI With many jtables,every jtable reads data from it's own table in a MySQL database
    and i want to make a search mechanism in a specific column in all the tables
    and once item is found the row is highlighted.
    i made it with two ways:
    1-make for loop in each jtable and once item is found , current loop is exited and other loops are not entered
    2-make connection with the database
    and create several resultsets ,every resultset execute a select query on the desired item
    and if one of the Resultsets returns data means item is found then i highlight it in the equivalent jtable.
    i executed the two ways and felt no difference in the speed of finding item
    but i want to know what is the best way of them or in general,as better design or in case of large applications?
    thanks in advance

    first_knight, you have no bloody idea what you're doing.
    you're asking if it's better to search on the client or the server.
    this suggests to me that the entire contents of the database are brought down to the client. this is usually a bad idea except for very small data sets. in that case, it doesn't matter where you do it.
    if you have lots of data, it's best to let the database do it. first, it will actually have all the data. second, it's been optimized to do searches faster than any code you'll ever write.
    either way, judging from your questions here you'll never get either one to work.
    %

Maybe you are looking for