Doubt on update

I have 3 tables. Those are shops, salepoint and storagepoint.
Salepoint and storagepoint both the tables contain doorNumber and village.
Based on the salepoint’s doorNumber and village I have selected the record for update.
The following is the query.
select a.shop_id
                   , a.shop_name,
                     a.propraitor_name,
                     a.license_number,
                     a.address,
                     b.salepoint_id,
                     b.door_number,
                     b.village,
                     c.storagepoint_id,
                     c.door_number as strgDoorNo,
                     c.village as strgVillage
               from shops a,
                      salepoint b,
                      storagepoint c
               where a.shop_id=b.shop_id
                          and
                b.shop_id=c.shop_id
                        and
                b.compare_string=? and b.village=?Now the record is displayed for updation(in the update form) . compare_string is nothing but doorNumber.
Now when I click on update button the system checks whether the salepoint doorNumber already existing or not. The salepoint doorNumber should not exist in the salepoint neighter in the storagepoint.
The following is the query for checking
select a.shop_name,
                    a.propraitor_name,
                    a.license_number,
                    a.address,
                    b.door_number,
                    b.village,
                    c.door_number as strgDoorNo,
                    c.village as strgVillage
                from shops a,
                       salepoint b,
                       storagepoint c
               where a.shop_id=b.shop_id
                           and
               b.shop_id=c.shop_id
                           and
              ((b.compare_string = ? and b.village = ?) or (c.compare_string = ? and c.village = ?))  the above query finds a record if there is a matching door number which is there in the updation form.
please ignore the ? marks. I am sending proper values instead of ? marks. When I run the above query it is returning the same record which I selected for update.it is because in that record there will be the matching salepoint door number My query should not return the same record. It should return any other record(if there is a matching salepoint door number) other than the record that is selected for update . how do i achieve this?
Edited by: Muralidhar on Apr 2, 2012 5:33 PM
Edited by: Muralidhar on Apr 3, 2012 10:04 AM

First of all, I don't know how anyone can think clearly about code written like that without any formatting. The first thing I would do would be to format the two queries so I could see what they are doing, e.g:
select sh.shop_id
     , sh.shop_name
     , sh.propraitor_name
     , sh.license_number
     , sh.address
     , sa.salepoint_id
     , sa.door_number
     , sa.village
     , st.storagepoint_id
     , st.door_number     as strgdoorno
     , st.village         as strgvillage
from   salepoint    sa
     , shops        sh
     , storagepoint st
where  sa.compare_string = ?
and    sa.village = ?
and    sh.shop_id = sa.shop_id
and    st.shop_id = sa.shop_id;
select sh.shop_name
     , sh.propraitor_name
     , sh.license_number
     , sh.address
     , sa.door_number
     , sa.village
     , st.door_number     as strgdoorno
     , st.village         as strgvillage
from   salepoint    sa
     , shops        sh
     , storagepoint st
where  (    (sa.compare_string = ? and sa.village = ?)
        or  (st.compare_string = ? and st.village = ?) )
and    sh.shop_id = sa.shop_id
and    st.shop_id = sa.shop_id;Now if I understand your question you want a version of the second query that returns all rows not matched by the second query. Isn't that just
where  not
       (    (sa.compare_string = ? and sa.village = ?)
        or  (st.compare_string = ? and st.village = ?) )(That's a bit of a guess though as I'm not sure I understood the question.)

Similar Messages

  • Doubt on updating PROJN field in EKKN

    Hi Friends,
    I have a requirement to update the PROJN(old pos number) field in EKKN table with some shipment date from input file.
    i have checked with BAPI_PO_CHANGE for updation.
    I cannot accurately find a specific field where i need to update for PROJN  in that BAPI.
    Actually the PROJN field is not in use now.
    Can anybody help me with which field in ME22N denotes the PROJN field.
    Is there any ways to update an non-existing field with some other field.
    <b><REMOVED BY MODERATOR></b>
    Message was edited by:
            Alvaro Tejada Galindo

    As the field is no longer used I doubt if there is a bapi or other object that allows you to update the field. Even if there was a bapi then support for updating that field could be withdrawn in the future. To be safe you should look at using another field. If you get replies telling you to directly update ekkn-projn then ignore them, thats silly.

  • Doubt about UPDATE STAT COLUMN

    Hi,
    I have a doubt of when to execute update stat:
    i create this SQL to generate an SQL script to generate update stat for all my tables:
    select 'UPDATE STAT ' || schemaname || '.' || tablename || ' ESTIMATE SAMPLE 20 PERCENT' from tables where schemaname = 'DBUSER' and not tablename like 'JDBC%' AND type = 'TABLE'
    and created this SQL to generate an SQL script for update stat for all columns.
    select 'UPDATE STAT COLUMN(*) FOR ' || schemaname || '.' || tablename || ' ESTIMATE SAMPLE 20 PERCENT' from tables where schemaname = 'DBUSER' and not tablename like 'JDBC%' AND type = 'TABLE'
    my doubt is i really need run that second script? or the UPDATE STAT for table dont UPDATE STAT for all columns?
    thanks for any insight
    Clóvis

    > my doubt is i really need run that second script? or the UPDATE STAT for table dont UPDATE STAT for all columns?
    Hi Clovis,
    hmm... good question.
    There are a few things to know about the UPDATE STAT command here.
    1) It will always generate statistics for key or indexed columns.
    2) The optimizer won't be able to generate a better plan when there are column statistics for non-indexed columns present.
    3) The command will also collect column statistics for all columns that already have statistics.
    The direct effect of 3) is that by running your second command just once - all column statistics will always be collected.
    Since you can easily change the default sample size for your tables via
    ALTER TABLE SAMPLE SIZE 20 PERCENT
    I would say: drop your script and just use
    UPDATE STAT DBUSER.* ESTIMATE
    This single command would lead to the same statistics as your script does.
    And if you really, really want to leave out the JDBC tables - then just set their default sample size to 0 and they will be ignored by the UPDATE STAT command.
    regards,
    Lars

  • Doubt in UPDATE Statement

    Hi,
    I need to update all values in 2 columns (Net_Quantity) and (Net_Amount) based on join condition with the another table in plsql block.
    Query which i tried
    UPDATE TFS_FRCST_TOOL_LINES SET NET_ORDERS_QTY=l_net_orders_qty and NET_AMOUNT=l_net_amount
    WHERE TFS_FRCST_TOOL_HDRS.HEADER_ID =TFS_FRCST_TOOL_LINES.HEADER_ID;
    It not updating, returns error like command not properly ended.
    Can any one please give idea to solve this.
    Regards
    Ajan

    Dave is right. The first thing that struck was 'and' and I had pointed it to the user who posted this.
    To Ajan --> You can try either of the options below,
    UPDATE TFS_FRCST_TOOL_LINES
    SET
    NET_ORDERS_QTY=l_net_orders_qty,
    NET_AMOUNT=l_net_amount
    WHERE
    TFS_FRCST_TOOL_LINES.HEADER_ID IN (SELECT TFS_FRCST_TOOL_HDRS.HEADER_ID FROM TFS_FRCST_TOOL_HDRS) ;
    UPDATE (select NET_ORDERS_QTY, NET_AMOUNT
    from TFS_FRCST_TOOL_LINES,TFS_FRCST_TOOL_HDRS
    where TFS_FRCST_TOOL_LINES.HEADER_ID=TFS_FRCST_TOOL_HDRS.HEADER_ID)
    set
    NET_ORDERS_QTY=l_net_orders_qty,
    NET_AMOUNT=l_net_amount

  • Doubt in Update query

    I have a problem using update query, for updating one column in a table with another column in another table. For eg say i have two tables, collector and survey
    Fields in Collector:
    col_n_account_num
    col_v_email
    col_n_phone_number
    Fields in survey
    sur_v_question_id
    sur_n_account_num
    sur_v_response
    update collector
    case when sur_v_question_id=collector_email then col_v_email=sur_v_response end,
    case when sur_v_question_id=collector_phone then col_n_phone_number=sur_v_response end
    Thanks in advance
    Regards,
    ss

    write two simple update statements
    update collector set col_v_email =
    (select sur_v_response from survey
    where sur_v_question_id=collector_email )
    and
    update collector set col_n_phone_number =
    (select sur_v_response from survey
    where sur_v_question_id=collector_phone)

  • Doubt in update function module

    dear friends..
    i have created an UPDATE function module with Processing type- Update Module, Start Immediate. i have handled the exceptions using Raise statement in the function module..
    the call function looks as..
      CALL FUNCTION 'ZFI_LCTXN_TABLES_UPDATE'
        in update task
        EXPORTING
          ZLCTMB1  = p_lctmb1
          NU_ENTRY = p_global-ins_zlctmb1
        TABLES
          UPD_PO   = UPD_PO
          UPD_SH   = UPD_SH
        EXCEPTIONS
          ERROR    = 1
          OTHERS   = 2.
      p_subrc = sy-subrc.
      commit work.
    but if the update fails, and even though the RAISE ERROR works, and update termination message is registered in SM13, i dont get the value for sy-subrc as 1 .
    is it the right way..if yes please tell me how to generate an error message within the transaction..so that the user knows the update has failed..
    thank you for your time
    Nivin

    Hi,
    Maybe it's usefull  for you.
    <b>
      IF sy-subrc EQ 4.
        MESSAGE e001 RAISING not_found.
      ELSEIF sy-subrc EQ 8.
        MESSAGE e002 RAISING not_found.
      ELSE.
      ENDIF.</b>
    Using this to create a message and raise in the same time !
    Regards.
    Marcelo Ramos

  • Doubt in updating database

    Hi friends,
    I need some suggestions,
    I am designing a desktop application with HSQLDB. Database contains 5 or 6 tables with image names , local path to those images and user login details. Desktop version is working fine but now problem is, there will be a central database on server which needs to be updated when the user clicks update. I need to update any new entry in DB and some times i need to upload those images to server.
    One way of doing is, include a separate entry in each table like new and whenever user updating get that entry and if its true i need to update that particular table row in the server and upload images to server if necessary, if everything is fine i need to change that entry to false. I think this will be fine for small number of tables but if it increases i need to check each and every table, update server, upload images and again update local db.
    So what will be the better way of doing this operation ? I can't update server db simultaneously as most of the time application run offline.
    Thanks in advance
    madhav

    thanks for your suggestion. its a good idea when all tables are same but prob is,
    say exactly i have 7 tables. 4 are for different types of images which contains name and path as columns. one table is to hold user login details like 'uname', 'pwd' and 'isadmin', 2nd one is to hold list of customers with column 'name' and last one is to hold logo info with column 'path'.
    Means, i need to create one single table with lot of columns or need to create 4 other tables to check for updates or am i misunderstood your suggestion ?
    I am sorry if i am not very clear in my first post

  • Doubt regarding update

    Hi all,
    I've three update statements need to execute on a single table.
    Is there a way I can exeucte the three update statements in a single statement?
        UPDATE xxops_forecast_extract b SET territory_id = (SELECT a.territory_id
             FROM fdev_hier_node_mv a
             WHERE a.shr_node_id = b.shr_node_id
              AND NVL(end_dt,SYSDATE) > SYSDATE) ;
        COMMIT;
        UPDATE xxops_forecast_extract b SET position_id = (SELECT a.row_id
            FROM s_postn a
            WHERE a.name = 'TD-'||UPPER(b.am_id))
            WHERE position_level = 7
            AND b.am_id IS NOT NULL;
        COMMIT;
        UPDATE xxops_forecast_extract b SET position_id = (SELECT a.row_id
            FROM s_postn a
            WHERE UPPER(a.desc_text) = UPPER(TRIM(B.POSITION_NAME)))
            WHERE position_level = 7
            AND b.am_id IS NULL;
    Below are the sample data for the tables.
    xxops_forecast_extract
    shr_node_id am_id position_name  position_id  territory_id
    2231211     Dave     (null)        (null)       (null)
    2231211     Michele  (null)        (null)       (null)
    2231211     (null)   COMM WEST 230 (null)       (null)
    2231211     (null)   COMM ISAM 110 (null)       (null)
    fdev_hier_node_mv
    shr_node_id territory_id
      2231211      5694
    s_postn
    row_id    name       desc_text
    12122   TD-Dave     (null)
    12123   TD-Michele  (null)
    89381   (null)          COMM WEST 230
    89382   (null)          COMM ISAM 110
    Resulting table after update
    xxops_forecast_extract
    shr_node_id am_id position_name  position_id  territory_id
    2231211     Dave     (null)        12122       5694
    2231211     Michele  (null)        12123       5694
    2231211     (null)   COMM WEST 230 89381       5694
    2231211     (null)   COMM ISAM 110 89382       5694Thanks all.

    Hi,
    You can combine the statements by combining the sub-queries.
    Any logic that does not apply to all the original UPDATEs has to be taken out of the WHERE-clause and put into a CASE statement.
    Any CASE statements should "update" a column to itself if none of the conditions apply.
    For example, your last two UPDATE statements, which both have sub-queries on s_postn, can be combined like this:
    UPDATE     xxops_forecast_extract     b
    SET     position_id =
         SELECT     CASE
                   WHEN     (     b.am_id          IS NOT NULL
                        AND     UPPER (a.name)     = 'TD-' || UPPER (b.am_id)
                   OR     (     b.am_id          IS NULL
                        AND     UPPER (a.desc_text)     = UPPER (TRIM (b.position_name))
                   THEN     a.row_id
                   ELSE     b.position_id
              END
         FROM     s_postn     a
            WHERE     UPPER (a.name)          = 'TD-' || UPPER (b.am_id)
         OR     UPPER (a.desc_text)     = UPPER (TRIM (b.position_name))
    ;There seem to be some errors in the UPDATE statemnts you posted. For example, the last two refer to a column called position_level which doesn't exist in either table.
    The statement above produces the results you want with the data you posted.
    As you can see, the coding is much harder to understand, debug and maintain.
    Whether the gain in performance (if any) justifies the addional complexity is debatable in this case.
    I feel sure that combining all three queries would not be worthwhile.
    Consider using MERGE: it's sometimes easier to use, even if, as in this case, you're never INSERTing.

  • Doubt in updating multiple records

    i am displaying all the records using table. once i selected the records for updation using checkbox, all those records should be updated.
    how to pass the multiple records to server side for updation?
    it is urgent...can anyone help me?

    Hi,
    Using request.getParameter("checkBoxName") we will come to know what are all the records need to be updated.
    Here put check box value is id of the record .
    <input type=checkbox value="idOf theRecord" >
    Now you know the id 's of all the records.
    Use stored procedure or write the Update query with
    update set column_name = 'somevaue' table_name
    where id in (id's of records);
    hope this will solve your problem
    Thanks
    Veeru

  • Doubt in updating database table

    hi all
    i want to modify values ztable from a internal table ....
    for eg : the ztable contains matnr and accept_qty
    matnr   qty
    mat01   
    mat02
    i need to modify qty of the table .. i am using where condition (ie modify where matnr = ) but where condition is not working for database tables .... how to proceed with this ..
    thanks
    lokesh

    hi,
    before that :- modify statemnt will modify a record if there is record having the same key like that of record in work area.
    if there is no record in itab with key of work area record, it will insert a new record in itab.
    look this sample code.
    *modify internal table
    loop at itab into wa.
    wa-field1 = data1.
    wa-field2 = data2.
    wa-field 3= data3.
    modify itab from wa transporting field1 field2 field3 where key_field = wa-keyfield. "there shuld not be any chang in key field.
    endloop.
    *now update database table
    *work area and data base structure shuld be same type
    if itab[] is not initial.
    modify ztable from table itab.
    endif.
    rgds
    anver
    if hlped pls mark points

  • Doubt Regarding Updated Rows

    Hello,
    After using Bulk Collect & FORALL for updating rows in a table
    How to find the total number of rows Affected (Updated) ...
    please explain by an example..??

    Hi Aijaz,
    If i'm correct you need to know the number of rows updated after the DML.
    This might help.
    -- Example Using the RETURNING Clause with a Record
    DECLARE
    TYPE setRec IS RECORD (key_name settings.settings_key%TYPE,
    value_1 settings.settings_date_value%TYPE );
    TYPE t_set_info IS TABLE OF setRec;
    set_info t_set_info := t_set_info( NULL );
    BEGIN
    UPDATE settings SET settings_date_value = SYSDATE WHERE settings_key LIKE '%DATE%'
    RETURNING settings_key, settings_date_value BULK COLLECT INTO set_info;
    DBMS_OUTPUT.PUT_LINE('Total rows ' || set_info.COUNT );
    ROLLBACK;
    END;
    /

  • Doubt on update Statment

    Removed
    Message was edited by:
    MIND

    Like this ?
    WHERE (    LICNXX.PRPR_ID = AFRSXX.SRV_PRPR_ID
           AND LICNXX.LICN_STATE = AFRSXX.SRV_PRAD_STATE
           AND LICNXX.PRPR_TYPE ='F'
           AND AFRSXX.CLCL_CL_SUB_TYPE ='I')
    OR    (    LICNXX.PRPR_ID = AFRSXX.PRCP_ID
           AND LICNXX.LICN_STATE = AFRSXX.SRV_PRAD_STATE
           AND LICNXX.PRPR_TYPE ='C'
           AND AFRSXX.CLCL_CL_SUB_TYPE ='P')
    AND ROWNUM = 1Nicolas.

  • Doubt in updation of fd33 using SD_CUSTOMER_MAINTAIN_ALL

    hi,
        i am using SD_CUSTOMER_MAINTAIN_ALL fm to upload customer master data however the customer is being created but when we open the tcode fd33 the credit limit is not being assigned to the customer however if we ar creating the same customer through xd01 we can see a credit limit being assigned . how to solve this problem

    Hi Trupti
    SD_CUSTOMER_MAINTAIN_ALL is used in standard during the maintenance of a consumer using the standard customer master data transaction XD01 & XD02.
    It is not intended to be used out of the transaction and in no case it should be used out of its original context. Due to the specificity of the function module, out of the original context we may face limitations and data inconsistencies.
    This is precisely what you face in your case.
    For the maintenance of customers, there is NO BAPI and NO direct function module.
    There are some functions modules like the one above where the name is looking nice. But these should not be used.
    Below ECC 2005 (6.00), the only solution was batch input and DEBMAS idocs. See [note 384462|https://service.sap.com/sap/support/notes/384462]
    Starting with ECC 2005 (6.00) and above: a synchronisation tool has been introduce. See class CMD_EI_API and VMD_EI_API
    As an additional information, class CMD_EI_API would fully solves your question in one step. No need of a BAPI to maintain the address.
    Hope this helps
    BR
    Alain

  • Update doubt

    I have a problem using update query, for updating one column in a table with another column in another table. For eg say i have two tables, collector and survey
    Fields in Collector:
    col_n_account_num
    col_v_email
    col_n_phone_number
    Fields in survey
    sur_v_question_id
    sur_n_account_num
    sur_v_response
    update collector
    case when sur_v_question_id=collector_email then col_v_email=sur_v_response end,
    case when sur_v_question_id=collector_phone then col_n_phone_number=sur_v_response end
    Thanks in advance
    Regards,
    ss

    Please don't create duplicate threads.
    Doubt in Update query

  • How to update item instance in oracle install base?

    Hi,
    I have a doubt in updating item instance in oracle install base.
    I am using a API named csi_item_instance_pub.update_item_instance for this. I want to update Party OWNER, party contacts, Current location,Install location, bill_to address,ship_to address..etc. When i try to update party owner, it is updating in csi_i_parties(col:party_id) as well as updating in csi_item_instance(owner_party_id). In csi_item_instance table,owner_party_id column is updated. but corresponding owner_party_account_id is not changed. I have given party_account_id to update in csi_ip_accounts table. It has changed in csi_ip_accounts table. But in csi_item_instance table(owner_party_account_id) is not changing. Can anybody help on how to change owner_party_account_id in csi_item_instance table please? Thanks in advance.
    --Muruga
    Edited by: Murugeshapps on Jul 1, 2009 12:07 AM

    Out of the box, I don't think that there is any API or program to delete the records from csi_item_instances because deleting IB record affects many modules (like Inventory, Order, Service Contracts etc). IB records should be expired if they are created incorrectly and you can run Transaction History Purge program to delete all history records related to that item.
    Thanks
    Shree

Maybe you are looking for

  • BW Hirerachy Authorization Error

    Hi, I created a No of hirerachies authorizations on cost center hierarchy by creating an authorization object in RSSM and then by generating a profile and using that profile as a templete to the role. i created 20 roles and each for one cost center.

  • Script Error in Movieclip

    I am creatign a flash website with in it a movieclip. The movieclip contains 8 frames. In frames 1 to 4 you will find text which belongs together. With the use of buttons you can skip one frame to the next part of the text (with on press gotoandstop(

  • PerDiems are not displayed in PR05 when the trip is being settled (ECC 5.0)

    A trip is created with the below expenses  ( in the t code TRIP) a) Air Ticket (Actual Epxneses) $160.00 b) Meals PerDiem: $50.00 c) ACcommodation PerDiem: $80.00 c) Other Expenses: $35.00 Total expenses in the trip are : $325.00 which is correctly s

  • Why when I export does my aspect ratio change?

    My camcorder is a Canon HDV 30 and any time I export a Quicktime movie using either current setting, compressor native or 1920/1080, the aspect ratio gets messed up...typically going 4:3. Does anyone know what export setting you use so that the exact

  • Has Apple come up with a fix for Parental Controls?

    I've browsed around on this forum quite a bit but haven't seen any real fix for the fact that Parental Controls does not work as advertised (come to think of it, it doesn't work at all). Is there a fix?? I'm using a new iMac with 10.5.2 (clean instal