Problem in read statement

hi,
my code is ;
select vbeln audat kunnr auart
        from vbak
        into table  t_vbak2
        for all entries in t_vbfa2
        where vbeln = t_vbfa2-vbelv
        and audat in r_daterange
        and kunnr = partner_number.
        if not t_vbak2[] is initial.
          sort t_vbak2 by vbeln audat auart.
        endif.
now if i use read statement :
read table t_vbak2 into wa_vbak2
        with key  vbeln = wa_vbfa1-vbelv
                  audat in r_daterange
                  kunnr = partner_number binary search.
i get a syntax error.
can any one help me with this..
Thanks,
Challa.

You can't use the IN operator in your READ statement, only  =  as you are trying to read with key.  In your case, you must use the LOOP statement.
Loop at t_vbak2 into wa_vbak2
          where vbeln = wa_vbfa1-vbelv
             and audat in R_daterange
             and kunnr = Partner_Number.
* Do whatever you need to do
Exit.   " This is so you only read one record.
Endloop.
Regards,
RIch Heilman

Similar Messages

  • Problem with READ Statement in the field routine of the Transformation

    Hi,
    I have problem with read statement with binary search in the field routine of the transformation.
    read statement is working well when i was checked in the debugging mode, it's not working properly for the bulk load in the background. below are the steps i have implemented in my requirement.
    1. I selected the record from the lookuo DSO into one internal table for all entried in source_packeage.
    2.i have read same internal table in the field routine for each source_package entry and i am setting the flag for that field .
    Code in the start routine
    select source accno end_dt acctp from zcam_o11
    into table it_zcam
    for all entries in source_package
    where source = source_package-source
         and accno = source_package-accno.
    if sy-subrc = 0.
    delete it_zcam where acctp <> 3.
    delete it_zcam where end_dt initial.
    sort it_zcam by surce accno.
    endif.
    field routine code:
    read table it_zcam with key source = source_package-source
                                                 accno  = source_package-accno
                                                 binary search
                                                 transportin no fields.
    if sy-subrc = 0.
    RESULT  = 'Y'.
    else.
    RESULT = 'N'.
    endif.
    this piece of code exist in the other model there its working fine.when comes to my code it's not working properly, but when i debug the transformation it's working fine for those accno.
    the problem is when i do full load the code is not working properly and populating the wrong value in the RESULT field.
    this field i am using in the report filter.
    please let me know if anybody has the soluton or reason for this strage behaviour.
    thanks,
    Rahim.

    i suppose the below is not the actual code. active table of dso would be /bic/azcam_o1100...
    1. is the key of zcam_o11 source and accno ?
    2. you need to get the sortout of if endif (see code below)
    select source accno end_dt acctp from zcam_o11
    into table it_zcam
    for all entries in source_package
    where source = source_package-source
    and accno = source_package-accno.
    if sy-subrc = 0.
    delete it_zcam where acctp 3.
    delete it_zcam where end_dt initial.
    endif.
    sort it_zcam by surce accno.
    field routine code:
    read table it_zcam with key source = source_package-source
    accno = source_package-accno
    binary search
    transportin no fields.
    if sy-subrc = 0.
    RESULT = 'Y'.
    else.
    RESULT = 'N'.
    endif.

  • Problem with READ statement

    hi,
    my data declarations and code is as follows:
    types:ty_bapi_return     LIKE  bapiret2.
    data: t_return            TYPE  STANDARD TABLE OF ty_bapi_return,
          wa_return           TYPE                    ty_bapi_return.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
                 EXPORTING
                      documentheader = wa_bapi_hdr
                 TABLES
                      accountgl      = t_accountgl
                      currencyamount = t_currencyamount
                      return         = t_return.
            READ TABLE t_return INTO wa_return WITH KEY type = 'E'.
              MOVE: wa_return-type       TO wa_msg_table-type,
                    wa_return-message    TO wa_msg_table-message,
                    wa_return-message_v2 TO wa_msg_table-message_v2,
                    wa_bkpf-belnr     TO wa_msg_table-belnr,
                    wa_bkpf-gjahr     TO wa_msg_table-gjahr,
                    wa_bkpf-bukrs      TO wa_msg_table-bukrs.
              APPEND wa_msg_table TO t_msg_table.
              CLEAR wa_msg_table.
              CONTINUE.
    ELSEIF wa_return-type = 'S'.
    call bapi_transaction_commit
              CLEAR   wa_commit_return1.
              REFRESH t_commit_return1.
              CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                   EXPORTING
                        wait   = 'X'
                   IMPORTING
                        return = t_commit_return1.
    Now when i debug and see wa_return , i cant find any values in wa_return.but the table t_return has 2 rows with type 'S'.can anyone tell me what the problem is..thank you.
    regards,
    Challa.

    READ TABLE t_return INTO wa_return WITH KEY type = 'E'.
    If you reading the table looking for TYPE "E"...And the table only got 2 rows with TYPE "S"...You will get a line into WA_RETURN...
    If you want records in WA_RETURN, you should write this...
    READ TABLE t_return INTO wa_return WITH KEY type = 'S'.
    "E" stands for error...If your BAPI have been well performed...You're not going to get any errors -;)
    Greetings,
    Blag.

  • Problems with READ STATEMENT

    Hello ABAPers,
    I have this code:
      SELECT ebeln bukrs
      FROM ekko
      INTO TABLE it_ekko
      FOR ALL ENTRIES IN idata
      WHERE ebeln = idata-vbeln_p.
      LOOP AT idata WHERE ebeln IS NOT INITIAL.
        READ TABLE it_ekko WITH KEY ebeln = idata-ebeln
                                    bukrs = idata-bukrs_r.
        MODIFY idata.
      ENDLOOP.
    I'm getting this error:
    The internal table IT_EKKO has no header line - explicit specification of an output area with INOT wa or ASSIGNING <fs> is required.
    I don't see what I'm doing wrong. Please advise.
    Thanks in advance.
    Ol Pom.

    Hi Ol Pom
      What Neil was pointing to is highlighted below. Please check the same to have some understanding.
    <b>Current Logic</b>:
    SELECT ebeln bukrs
       FROM ekko
       INTO TABLE it_ekko
       FOR ALL ENTRIES IN idata
       WHERE ebeln = idata-vbeln_p.
    LOOP AT idata WHERE ebeln IS NOT INITIAL.
         READ TABLE it_ekko WITH KEY ebeln = idata-ebeln
         bukrs = idata-bukrs_r.
         MODIFY idata.
    ENDLOOP.
    --> Nowhere between the loop and end, any data of
    internal table <b>idata</b> is modified, hence the
    statement MODIFY IDATA doesnt make any modifications.
    For avoiding the syntax error, declare a work area of
    type IT_EKKO or declare IT_EKKO with header line.
    Options to do the same:
    data: wa_ekko like it_ekko.
    <b>OR</b>
    data: begin of it_ekko <b>occurs 0</b>,
          end of it_ekko.
    Above will rectify the syntax error.
    Please see that your code resembles something like below:
    data: wa_ekko like it_ekko.
    IF NOT it_ekko[] is INITIAL.
       SELECT ebeln bukrs
         FROM ekko
         INTO TABLE it_ekko
         FOR ALL ENTRIES IN idata
         WHERE ebeln = idata-vbeln_p.
    ENDIF.
    LOOP AT idata WHERE ebeln IS NOT INITIAL.
         READ TABLE it_ekko into it_ekko
              WITH KEY ebeln = idata-ebeln
                       bukrs = idata-bukrs_r.
         check sy-subrc eq 0.
    *     ... change contents of idata w.r.t it_ekko.
         MODIFY idata.
    ENDLOOP.
    Kind Regards
    Eswar

  • READ statement problem-URGENT.

    hai experts,
    I am facing problem with read statement.
    <b>read table itab with key f1 = '10'."it works.</b>
    But,
    now i store value '<b>10'</b> in variable <b>f</b> and use it as follows.
    <b>read table itab with key f1 = f."it isn't working</b>.
    My requirement is as above.I have to read a particular record from a internal table with key value stored in a variable ,key should not be  hardcoded.
    Do any one have any idea abt this.
    Plz, help me. Its very urgent.
    Thanks & Regards.
    Shivaa

    Hi Shiva
                That isn't a way to access the internal table via variable. Please refer transaction ABAPDOCU to know more information querying internal table(or transparent table) via a Variable and many more..
    <b> Helpfull: Reward points </b>
    Thanks and Kind Regards
    Mohan

  • Read Statement Issue

    HI,
    I am facing problem with read statement, please find below my code and provide the solution.
    My Internal Tables.
    TYPES: BEGIN OF TYP_BSAK,
    BUKRS TYPE BSAK-BUKRS,
    LIFNR TYPE BSAK-LIFNR,
    AUGDT TYPE BSAK-AUGDT,
    GJAHR TYPE BSAK-GJAHR,
    BELNR TYPE BSAK-BELNR,
    BUZEI TYPE BSAK-BUZEI,
    BUDAT TYPE BSAK-BUDAT,
    BLART TYPE BSAK-BLART,
    DMBTR TYPE BSAK-DMBTR,
    SGTXT TYPE BSAK-SGTXT,
    AUGBL TYPE BSAK-AUGBL,
    HKONT TYPE BSAK-HKONT,
    END OF TYP_BSAK.
    DATA : IT_BSAK TYPE STANDARD TABLE OF TYP_BSAK WITH HEADER LINE,
    WA_BSAK TYPE TYP_BSAK.
    READ STATEMENT :
    LOOP AT IT_BSIS INTO WA_BSIS.   -> I am getting data in wa_BSIs
       READ TABLE IT_BSAK INTO WA_BSAK  -> I am Getting record in IT_BSAK bu the same is not populated in WA_BSAK
       WITH KEY BUKRS = S_BUKRS.
       IF SY-SUBRC = 0.
          WA_OUTPUT-SAPSYS    = 'PROBE'.
          WA_OUTPUT-BUKRS     = WA_BSAK-BUKRS.
          WA_OUTPUT-BUKRS     = WA_BSAK-BUKRS.
          WA_OUTPUT-BELNR     = WA_BSAK-BELNR.
          WA_OUTPUT-SGTXT     = WA_BSAK-SGTXT.
          WA_OUTPUT-BUDAT     = WA_BSAK-BUDAT.
          WA_OUTPUT-AUGBL     = WA_BSAK-AUGBL.
          WA_OUTPUT-LIFNR     = WA_LFA1-LIFNR.
          WA_OUTPUT-NAME1     = WA_LFA1-NAME1.
          WA_OUTPUT-STRAS     = WA_LFA1-STRAS.
          WA_OUTPUT-ORT01     = WA_LFA1-ORT01.
          WA_OUTPUT-REGIO     = WA_LFA1-REGIO.
          WA_OUTPUT-PSTLZ     = WA_LFA1-PSTLZ.
          WA_OUTPUT-STCD2     = WA_LFA1-STCD2.
         ENDIF.
    APPEND WA_OUTPUT TO IT_OUTPUT.
       ENDLOOP.
    Thanks and Regards
    VB

    Hi,
    I hope You have use below code solved your problem.
    LOOP AT IT_BSIS INTO WA_BSIS
    READ TABLE IT_BSAK INTO WA_BSAK
    WITH KEY BUKRS = WA_BSIS-BUKRS.
    IF SY-SUBRC = 0.
    WA_OUTPUT-SAPSYS = 'PROBE'.
    WA_OUTPUT-BUKRS = WA_BSAK-BUKRS.
    WA_OUTPUT-BUKRS = WA_BSAK-BUKRS.
    WA_OUTPUT-BELNR = WA_BSAK-BELNR.
    WA_OUTPUT-SGTXT = WA_BSAK-SGTXT.
    WA_OUTPUT-BUDAT = WA_BSAK-BUDAT.
    WA_OUTPUT-AUGBL = WA_BSAK-AUGBL.
    WA_OUTPUT-LIFNR = WA_LFA1-LIFNR.
    WA_OUTPUT-NAME1 = WA_LFA1-NAME1.
    WA_OUTPUT-STRAS = WA_LFA1-STRAS.
    WA_OUTPUT-ORT01 = WA_LFA1-ORT01.
    WA_OUTPUT-REGIO = WA_LFA1-REGIO.
    WA_OUTPUT-PSTLZ = WA_LFA1-PSTLZ.
    WA_OUTPUT-STCD2 = WA_LFA1-STCD2.
    ENDIF.
    APPEND WA_OUTPUT TO IT_OUTPUT.
    ENDLOOP.
    Thanks
    Regards
    I.Muthukumar.
    Edited by: I.Muthukumar on Jun 25, 2010 12:43 PM

  • Problem in writing a Read Statement

    Hi,
    In my Table control I have a POSITION button which is used to find the record in the table.
    I have written the following code.
      CALL FUNCTION 'POPUP_GET_VALUES'
        EXPORTING
    *   NO_VALUE_CHECK        = ' '
          popup_title           = 'Find the record'
    *   START_COLUMN          = '5'
    *   START_ROW             = '5'
    * IMPORTING
    *   RETURNCODE            =
        TABLES
          fields                = lt_tab
    EXCEPTIONS
       error_in_fields       = 1
       OTHERS                = 2
    I have five primary keys in my table, so that in the pop up I am getting all the five fields.
    The user will enter any of the five fields , I want to write a read statement based on the fields entered by the user.
    Could anybody help in writing the Read  statement.
    Or could any one help me in writing out the FIND functionality for a table control
    Regards
    Edited by: SAP LEARNER on Jun 15, 2010 1:40 PM

    Hi,
    I do not know what fields will be filled up.
    as there are 5 PK fields so 5! chances will be there for the where condition in the READ statement.
    How can I do it.
    I tried in the following way.
    I created a structure with the primary key fields and I filled the structure with the user filled values.
    Then I used it in the read statement as below, but it did not work.
        LOOP AT lt_tab .
          IF lt_tab-fieldname = 'SOCIEDAD'.
            lw_pk-sociedad = lt_tab-value.
          ENDIF.
          IF lt_tab-fieldname = 'NATURAL_YEAR'.
            lw_pk-natural_year = lt_tab-value.
          ENDIF.
          IF lt_tab-fieldname = 'CICLO_DE_VENTAS'.
            lw_pk-ciclo_de_ventas = lt_tab-value.
          ENDIF.
          IF lt_tab-fieldname = 'MODEL_VERSION'.
            lw_pk-model_version = lt_tab-value.
          ENDIF.
        ENDLOOP.
        DATA:lw_yrwbw010 TYPE ty_yrwbw010.
        READ TABLE t_yrwbw010 INTO lw_yrwbw010 WITH KEY lw_pk.
         IF sy-subrc = 0.
          table-top_line = sy-tabix.
         ENDIF.
      ENDIF.
    @Rob Burbank
    Could you please help me !! I could not find that in F1 help.
    @ Keshav.T         
    Could you please elaborate it please

  • Problem in using read statement.

    i am using the read statement as follows :
    read table tekpo with key werks = '1001'.
    it is not reading the corresponding record.
    though it reads or not it is returning the sy-subrc value 0.
    plz let me know why it is happening as soon as possible.
    points will be awarded.

    Hi Srinivas rao,
    You can use this example program and make the changes in your program as well:
    DATA: BEGIN OF LINE,
             COL1 TYPE I,
             COL2 TYPE I,
          END OF LINE.
    DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
    FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
    DO 4 TIMES.
      LINE-COL1 = SY-INDEX.
      LINE-COL2 = SY-INDEX ** 2.
      APPEND LINE TO ITAB.
    ENDDO.
    READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
    <FS>-COL2 = 100.
    READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
    DELETE ITAB INDEX 3.
    IF <FS> IS ASSIGNED.
      WRITE '<FS> is assigned!'.
    ENDIF.
    LOOP AT ITAB ASSIGNING <FS>.
      WRITE: / <FS>-COL1, <FS>-COL2.
    ENDLOOP.
    The output is:
             1         1
             2       100
             4        16
    I think you have satisfied.
    Thanks and regards
    Vipin Das

  • READ statement problem

    TYPES : BEGIN OF itab,
             matnr LIKE eban-matnr,
             menge LIKE eban-menge,
           END OF itab.
    TYPES : BEGIN OF itab2,
              maktx LIKE makt-maktx,
            END OF itab2.
    DATA : it_eban TYPE STANDARD TABLE OF itab.
    DATA : it_makt TYPE STANDARD TABLE OF itab2.
    DATA : wa_eban TYPE itab.
    DATA : wa_makt TYPE itab2.
    START-OF-SELECTION.
      SELECT matnr menge INTO CORRESPONDING FIELDS OF TABLE
                            it_eban FROM eban.
      SELECT maktx INTO  CORRESPONDING FIELDS OF TABLE
                           it_makt from makt.
    PERFORM display TABLES it_eban it_makt.
    FORM display TABLES eban_tab makt_tab.
    LOOP AT eban_tab INTO wa_eban.
      WRITE :/ wa_eban-matnr, wa_eban-menge.
      READ TABLE makt_tab with key matnr = wa_eban-matnr.
      "here I'm getting error like
      "the specified type has no structure and therefore no component called "MATNR"
      "How can I write READ statement here to read makt_tab.
    ENDLOOP.
    ENDFORM.

    Try that
    TYPES : BEGIN OF itab,
             matnr LIKE eban-matnr,
             menge LIKE eban-menge,
           END OF itab.
    TYPES : BEGIN OF itab2,
              <b>matnr like mara-matnr,</b>
              maktx LIKE makt-maktx,
            END OF itab2.
    DATA : it_eban TYPE STANDARD TABLE OF itab.
    DATA : it_makt TYPE STANDARD TABLE OF itab2.
    DATA : wa_eban TYPE itab.
    DATA : wa_makt TYPE itab2.
    START-OF-SELECTION.
      SELECT matnr menge INTO CORRESPONDING FIELDS OF TABLE
                            it_eban FROM eban.
      SELECT <b>matnr</b> maktx INTO  CORRESPONDING FIELDS OF TABLE
                           it_makt from makt.
    PERFORM display TABLES it_eban it_makt.
    FORM display TABLES eban_tab makt_tab.
    LOOP AT eban_tab INTO wa_eban.
      WRITE :/ wa_eban-matnr, wa_eban-menge.
      READ TABLE makt_tab into <b>wa_makt</b> with key matnr = wa_eban-matnr.
      "here I'm getting error like
      "the specified type has no structure and therefore no component called "MATNR"
      "How can I write READ statement here to read makt_tab.
    ENDLOOP.
    ENDFORM.
    Message was edited by:
            Jacek Slowikowski

  • Read statement giving problem

    Dear Experts,
    I am making monthly consumption report, In which i am getting monthly data column wise for different month , here firstly i am fetching header mblnr  date according to date from mkpf then i am fetching data from mseg.....
    I have same mblnr in both tables..... Now i am using read statement like this.......
    sort lt_mkpf by mblnr.
    SORT lt_mseg BY mblnr.
    LOOP AT lt_mkpf INTO lw_mkpf.
    READ TABLE lt_mseg INTO lw_mseg WITH KEY mblnr = lw_mkpf-mblnr
                                                mjahr = lw_mkpf-mjahr
                                                        BINARY SEARCH.
    When I am debugging i am getting data in lw_mkpf but sy-subrc = 4 is coming  and getting wrong data in final table by using these above statements..........
    where as if i am using loop like this:
    SORT lt_mkpf BY mblnr.
    SORT lt_mseg BY mblnr.
    LOOP AT lt_mkpf INTO lw_mkpf.
    v_mkpf = lw_mkpf-mblnr.
    LOOP AT lt_mseg INTO lw_mseg WHERE mblnr EQ v_mkpf.
    with this i am getting right data........ But it takes lot of time to execute..........
    Can you please guide me am i using read statement by wrong method. which one is the correct method which one shoul be used.........

    Hello Shelly,
    To solve the issue of read table being failed, Sort the internal table by mblnr and mjahr. say sort lt_mseg by mblnr mjahr but read the internal table mseg will give you only one data. What about the other line items. MSEG is material document line item table. So for one record in MKPF there can be more than one record in MSEG. So to consider all the line items, you need to loop on the MSEG internal table instead of read table.
    LOOP AT lt_mkpf INTO lw_mkpf.
    v_mkpf = lw_mkpf-mblnr.
    LOOP AT lt_mseg INTO lw_mseg WHERE mblnr EQ v_mkpf.
    This statement will take time and create performance issue. So rewrite the statement as
    LOOP AT lt_mseg INTO lw_mseg.
    read table lt_mkpf with key lw_mkpf binary search.
    Regards
    Farzan

  • Problem While reading a file in text mode from Unix in ECC 5.0

    Hi Experts,
    I am working on Unicode Upgrade project of ECC5.0.
    Here i got a problem with reading a file format which it does successfully in 4.6 and not in ECC5.0
    My file format was as follows:
    *4 000001862004060300000010###/#######L##########G/##########G/########
    It was successfully converting corresponding field values in 4.6:
    *4
    00000186
    2004
    06
    03
    00000010
    25
    0
    4
    0
    54.75
    0
    54.75
    0.00
    While i am getting some problem in ECC5.0 during conversion of the above line:
    *4 000001862004060300000010###/#######L##########G/##########G/########
    it was consider in the same # values.
    I have used the following statement to open and read dataset.
    OPEN DATASET i_dsn IN LEGACY TEXT MODE FOR INPUT.
    READ DATASET i_dsn INTO pos_rec.
    Thanks for your help.
    Regards,
    Gopinath Addepalli.

    Hi
          You might be facing this problem because of uni code. So while opening or reading the file, there is a statement call ENCODING. Use that option and keep the code page which you want. Then the problem may be solved.
    Thanks & Regards.
    Harish.

  • Problem in Update Statement

    I got some problem in update statement.Can anybody discuss with me regarding my problem? Below is the occured problem.
    //all the declaration like Connection, ResultSet are declared, setting the ODBC path and so on steps have been set up before this method. When compile it, no error, when I start to run my program, the program�s interface is shown, but the following error was appearred and data cannot be updated, can anybody tell me where is my mistake?
    //ERROR:SQL Error in update statement:java.sql.SQLException [Microsoft][ODBC][ODBC Microsoft Access Driver] Syntax Error in UPDATE statement.
    //emp_overview is the table name
    // last_name, first_name, office_phone�.is the attributes of the table
    //this method had declare in the interface class already
    public String updateData (String idd, String ln, String fn, String op,
                   String oe, String hp, String ps, String ss)
                   throws java.rmi.RemoteException
         {//begin of this method
              String result ="";
              try
              Statement statement = connection.createStatement();
              String sql = "UPDATE emp_overview SET" +
              "last_name=' "+ln+
              " ', first_name=' "+fn+
              " ', office_phone=' "+op+
              " ', office_ext=' "+oe+
              " ', home_phone=' "+hp+
              " ', primary_skill=' "+ps+
              " ', secondary_skill=' "+ss+
              " ' WHERE id="+idd;
              statement.executeUpdate(sql);
              statement.close();
              catch (java.sql.SQLException e)
         System.out.println("SQL Error in update statement: "+e);
              //throw a RemoteException with the exception
              //embedded for the client to receive
         throw new java.rmi.RemoteException("Error in Updating exist row into DB", e);
              return result;
         }//end of this method

    Hi Kevin,
    According to the code you have posted, it looks like you are missing a space between "SET" and "last_name". I suggest you add the following line of code:
    System.out.println(sql);
    before the invocation of "executeUpdate()".
    I also suggest you add the following line of code:
    e.printStackTrace();in your "catch" block.
    Hope this helps.
    Good Luck,
    Avi.

  • Problem in Update statement using Execute Immediate

    Hi All,
    I am facing problem in update statement.
    I am creating dynamic sql and use "execute immediate" statement to execute a update statement.
    But it is not updating any thing there in the table.
    I have created a query like :
    update_query='Update '|| Table_Name ||' t set t.process_status =''Y'' where t.tid=:A';
    Execute immediate update_query using V_Id;
    commit;
    But it is not updating the table.
    I have a question , is execute immediate only does insert and delete?
    Thanks
    Ashok

    SQL> select * from t;
                     TID P
                     101 N
    SQL> declare
      2     V_Id          number := 101;
      3     Table_Name    varchar2(30) := 'T';
      4     update_query  varchar2(1000);
      5  begin
      6     update_query := 'Update '|| Table_Name ||' t set t.process_status =''Y'' where t.tid=:A';
      7     Execute immediate update_query using V_Id;
      8     commit;
      9  end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> select * from t;
                     TID P
                     101 Y                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Problem in UPDATE statement In Multiple Record Block

    Hi Friends,
    I have problem in update Statement for updating the record in multiple record data Block.
    I have two data Block the master block is single Record block and the 2nd data block is Multiple Record data Block.
    I am inserting the fields like category,and post_no for partiular job in single data block
    Now in second Multiple Record Data Block,i am inserting the multiple record for above fileds like no. of employees work in the position
    There is no problem in INSERT Statement as it is inerting all record But whenever i want to update particular Record (in Multiple Block) of employee for that category and Post_no
    then its updating all the record.
    my code is Bellow,
    IF v_count 0 THEN
    LOOP
    IF :SYSTEM.last_record 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES(g_post_no, g_roster_no, g_category, :POST_HISTORY_MULTIPLE.idcode, :POST_HISTORY_MULTIPLE.joining_post_dt,
    :POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    next_record;
    ELSIF :SYSTEM.last_record = 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES (g_post_no,g_roster_no,g_category,:POST_HISTORY_MULTIPLE.idcode,
    :POST_HISTORY_MULTIPLE.joining_post_dt,:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    EXIT;
    END IF;
    END LOOP;
    SET_ALERT_PROPERTY('user_alert',ALERT_MESSAGE_TEXT, 'Record Updated successfuly' );
    v_button_no := SHOW_ALERT('user_alert');
    FORMS_DDL('COMMIT');
    CLEAR_FORM(no_validate);
    Please Guide me
    Thanks in advence

    As you do a loop over all the records in the block, of course every record is updated.
    Also, what you do is not the way is intended to be used. In general, you base a block on a table,then there is no need at all for writing INSERT's or UPDATE's. Forms also know's then, which records to be updated and which not.

  • Problem In Update Statement In Multiple Record Data Block

    Hi Friends,
    I have problem in update Statement for updating the record in multiple record data Block.
    I have two data Block the master block is single Record block and the 2nd data block is Multiple Record data Block.
    I am inserting the fields like category,and post_no for partiular job in single data block
    Now in second Multiple Record Data Block,i am inserting the multiple record for above fileds like no. of employees work in the position
    There is no problem in INSERT Statement as it is inerting all record But whenever i want to update particular Record (in Multiple Block) of employee for that category and Post_no
    then its updating all the record.
    my code is Bellow,
    IF v_count <> 0 THEN
    LOOP
    IF :SYSTEM.last_record <> 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES(g_post_no, g_roster_no, g_category, :POST_HISTORY_MULTIPLE.idcode, :POST_HISTORY_MULTIPLE.joining_post_dt,
    :POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    next_record;
    ELSIF :SYSTEM.last_record = 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
         VALUES (g_post_no,g_roster_no,g_category,:POST_HISTORY_MULTIPLE.idcode,
              :POST_HISTORY_MULTIPLE.joining_post_dt,:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    EXIT;
    END IF;
    END LOOP;
    SET_ALERT_PROPERTY('user_alert',ALERT_MESSAGE_TEXT, 'Record Updated successfuly' );
    v_button_no := SHOW_ALERT('user_alert');
    FORMS_DDL('COMMIT');
    CLEAR_FORM(no_validate);
    Please Guide me
    Thanks in advence

    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;These update statements are without where clause, so it will update all records.
    If it is specific to oracle forms then u may get better help at Forms section.

Maybe you are looking for