Mutating table problem help required

Hi. I am rather hoping someone will be able to help me with this problem.
I have two tables, sa and mv. Create script below:
create table mv (
moduleId Char(2) CONSTRAINT ck_moduleId CHECK(moduleId in ('M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8')),
credits Number(2) CONSTRAINT ck_credits CHECK(credits in (10, 20, 40)),
constraint pk_mv primary key(moduleId)
create table sa (
stuId Char(2) CONSTRAINT ck_stuId CHECK(stuId in ('S1', 'S2', 'S3', 'S4', 'S5')),
moduleId Char(2),
constraint pk_sa primary key(stuId, moduleId),
constraint fk_moduleid foreign key(moduleId) references mv(moduleId)
And the scripts below is to insert data into both:
insert into mv VALUES('M1', 20)
insert into mv VALUES('M2', 20)
insert into mv VALUES('M3', 20)
insert into mv VALUES('M4', 20)
insert into mv VALUES('M5', 40)
insert into mv VALUES('M6', 10)
insert into mv VALUES('M7', 10)
insert into mv VALUES('M8', 20)
insert into sa VALUES('S1', 'M1')
insert into sa VALUES('S1', 'M2')
insert into sa VALUES('S1', 'M3')
insert into sa VALUES('S2', 'M2')
insert into sa VALUES('S2', 'M4')
insert into sa VALUES('S2', 'M5')
insert into sa VALUES('S3', 'M1')
insert into sa VALUES('S3', 'M6')
Now for the actual problems.
Firstly I need to try and overcome the mutating table problem by ensure that stuid = S1 in table sa can not take both moduleId M5 and M6.
Just one or the other. I have created a single trigger, but if fails because of the mutating table problem.
The second problem I need to overcome is that none of the stuids can have moduleIds where total credit value of more than 120 credits. Credit value is stored in the mv table.
Many thanks in advance for any assistance.

Use a statement level trigger:
Firstly I need to try and overcome the mutating table problem by ensure that stuid = S1 in table sa can not take both moduleId M5 and M6.
SQL> create or replace trigger sa_trg
  2  after insert or update on sa
  3  declare
  4  c number;
  5  begin
  6    select count(distinct moduleId) into c
  7    from sa
  8    where stuid = 'S1'
  9    and moduleId in ('M5','M6');
10    if c > 1 then
11       raise_application_error(-20001,'S1 on both M5 and M6!!');
12    end if;
13  end;
14  /
Trigger created.
SQL> select * from sa;
ST MO
S1 M1
S1 M2
S1 M3
S2 M2
S2 M4
S2 M5
S3 M1
S3 M6
8 rows selected.
SQL> insert into sa values ('S1','M5');
1 row created.
SQL> insert into sa values ('S1','M6');
insert into sa values ('S1','M6')
ERROR at line 1:
ORA-20001: S1 on both M5 and M6!!
ORA-06512: at "SCOTT.SA_TRG", line 9
ORA-04088: error during execution of trigger 'SCOTT.SA_TRG'
The second problem I need to overcome is that none of the stuids can have moduleIds where total credit value of more than 120 credits. Credit value is stored in the mv table
SQL> create or replace trigger sa_trg
  2  after insert or update on sa
  3  declare
  4  c number;
  5  begin
  6    select count(distinct moduleId) into c
  7    from sa
  8    where stuid = 'S1'
  9    and moduleId in ('M5','M6');
10    if c > 1 then
11       raise_application_error(-20001,'S1 on both M5 and M6!!');
12    end if;
13 
14    select count(*) into c from (
15    select stuid
16    from mv, sa
17    where sa.moduleid=mv.moduleid
18    group by stuid
19    having sum(credits)>120);
20 
21    if c > 0 then
22       raise_application_error(-20002,'A student cannot have more than 120 credits!!');
23    end if;
24 
25  end;
26  /
Trigger created.
SQL>   select stuid, sum(credits)
  2  from mv, sa
  3  where sa.moduleid=mv.moduleid
  4  group by stuid;
ST SUM(CREDITS)
S3           30
S2           80
S1          100
SQL> insert into sa
  2  values ('S1','M4');
1 row created.
SQL>   select stuid, sum(credits)
  2  from mv, sa
  3  where sa.moduleid=mv.moduleid
  4  group by stuid;
ST SUM(CREDITS)
S3           30
S2           80
S1          120
SQL> insert into sa
  2  values ('S1','M7');
insert into sa
ERROR at line 1:
ORA-20002: A student cannot have more than 120 credits!!
ORA-06512: at "SCOTT.SA_TRG", line 20
ORA-04088: error during execution of trigger 'SCOTT.SA_TRG'Max
http://oracleitalia.wordpress.com

Similar Messages

  • Autonomous Trigger / Mutating Table Problem

    We have a specific problem in one of our applications being developed where by the database needs to enforce a specific business requirement.
    We need to use a database trigger to enforce some data integrity which involves more than one table as such cannot use standard constraint. The integrity has to be maintained in the database as the DML statements may be coming from a Java application or PL/SQL code as such we need the logic all in one place.
    The problem being that within the trigger we need to examine the state of the table the trigger is associated with as well as one other table. Obviously using a trigger on a table that is being affected by DML statements causes the dreaded mutating table problem.
    One suggested solution to this was to make the trigger or the code the trigger called autonomous. This allows the trigger to execute by only showing the trigger the original state of the table before any of the DML statements have affected it.
    The problem is this seems to work for single row DML statements but not for multi row DML statements. In multi row the trigger only sees the original state of the table, not the state of the table plus the changes made by any other actions in the same DML statement.
    Below I have shown an example of what I'm seeing.
    I have grossly simplified the example code below to only refer to a single table and use stupidly simple logic
    I do realise i appear to be implementing uniqueness in my own PL/SQL code, this is purely for the example.
    CREATE TABLE mutate_test
    id INTEGER NOT NULL,
    value VARCHAR2(255) NOT NULL
    ALTER TABLE mutate_test ADD CONSTRAINT pk_mutate_test PRIMARY KEY(id);
    ALTER TABLE mutate_test ADD CONSTRAINT ck_mutate_test CHECK (value = UPPER(value));
    CREATE OR REPLACE FUNCTION duplicate_found(in_value IN mutate_test.value%TYPE) RETURN BOOLEAN IS
    PRAGMA AUTONOMOUS_TRANSACTION;
    v_value_found INTEGER;
    BEGIN
    SELECT COUNT(*)
    INTO v_value_found
    FROM mutate_test
    WHERE value = in_value;
    IF v_value_found > 0 THEN
    RETURN TRUE;
    ELSE
    RETURN FALSE;
    END IF;
    END;
    CREATE OR REPLACE TRIGGER tr_mutate_test BEFORE INSERT OR UPDATE ON mutate_test
    FOR EACH ROW
    BEGIN
    IF duplicate_found(:new.value) = TRUE THEN
    RAISE_APPLICATION_ERROR(-20000,'Duplicate value found');
    END IF;
    END;
    INSERT INTO mutate_test (id,value) VALUES (1,'CLIFF');
    INSERT INTO mutate_test (id,value) VALUES (2,'SULA');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Should fail as row 1 already has a value of CLIFF
    INSERT INTO mutate_test (id,value) VALUES (3,'CLIFF');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Should fail as row 1 is already set to CLIFF
    UPDATE mutate_test SET value = 'CLIFF' WHERE id = 2;
    COMMIT;
    SELECT * FROM mutate_test;
    UPDATE mutate_test SET value = 'CLIFFORD' WHERE id = 1;
    COMMIT;
    SELECT * FROM mutate_test;
    INSERT INTO mutate_test (id,value) VALUES (3,'RONNY');
    INSERT INTO mutate_test (id,value) VALUES (4,'TIM');
    INSERT INTO mutate_test (id,value) VALUES (5,'MONIQUE');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Wanted result would be row 1 would be updated from CLIFFORD to CLIFF
    -- and the others raise errors, or all of them raise errors.
    UPDATE mutate_test SET value = 'CLIFF' WHERE id IN (1,3,4);
    COMMIT;
    SELECT * FROM mutate_test;

    This is all from a University application that deals with eLearning.
    Shell = Mapping from the system to an external eLearning application, ie: unique id of the Blackboard course shell, or WebBoard board.
    Term = Academic term
    Sector = University sector, ie: Higher Education, TAFE, etc..
    Resource = eLearning tool, ie: Blackboard, WebBoard, etc..
    Resource Level = Whether the resource is being offered at a Course or Program level
    Resource Mapping = Association of a resource to shell
    What we are trying to achieve is that shells cannot be used across sector boundaries.
    The real table structure is (grossly simplified again)
    CREATE TABLE sector (sector_pk INTEGER PRIMARY KEY);
    CREATE TABLE sector_pattern (sector_pk INTEGER REFERENCES sector(sector_pk), pattern CHAR(2) NOT NULL UNIQUE CHECK (pattern = UPPER(pattern)));
    CREATE TABLE term (term_pk INTEGER PRIMARY KEY, term CHAR(4) NOT NULL UNIQUE CHECK (term = UPPER(term)));
    CREATE TABLE resource_level (resource_level_pk INTEGER PRIMARY KEY, term_pk INTEGER REFERENCES term(term_pk));
    CREATE TABLE shell_detail (shell_detail_pk INTEGER PRIMARY KEY);
    CREATE TABLE resource_mapping (resource_mapping INTEGER PRIMARY KEY, resource_level_pk INTEGER REFERENCES resource_level(resource_level_pk), shell_detail_pk INTEGER REFERENCES shell_detail(shell_detail_pk));
    Based on the Ask Tom article linked I'd liked to use a MATERIALIZED VIEW on the following query
    SELECT DISTINCT rm.shell_detail_pk,sp.sector_pk
    FROM resource_mapping rm, resource_level rl, term t, sector_pattern sp
    WHERE rm.resource_level_pk = rl.resource_level_pk
    AND rl.term_pk = t.term_pk
    AND SUBSTR(t.term,3,2) = sp.pattern;
    Then apply a UNIQUE constraint on that VIEW.
    But I'm receiving a
    SQL Error: ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
    I'm not sure how to create the MATERIALIZED VIEW LOG entries for the above VIEW.
    Any ideas anyone? ;)
    Need to do some more reading and research but as Tom says
    "I'm asking around about the future of "SQL" as far as enhancments go like that
    (will update when I get some feedback), but -- you are not limited to triggers
    (in fact, I would avoid triggers as it is virtually IMPOSSIBLE to implement
    cross row/cross object constraints with them!!!! at least correctly)"
    So I think i'll give up on the TRIGGER approach as it doesn't meet our requirements.

  • Problem with constraint in a table..help required..

    Hi ,
    i need to create a table which has an attribute year_joined and need to set a constraint that the year_joined should be less than or equal to the current year (year obtained from sysdate (YYYY)) ..
    can any one help me with the create statement required...
    eg: create table test(year_joined number, constraint c_year check(year_joined< = ?));
    i could not use a sub query in the create statement.
    help req..
    thanks,
    sri

    Satyaki,
    I tried but fail. Could you please tell the way how it can be implementaed in CHECK constraint.
    SQL> CREATE TABLE T ( YERR_JOINED NUMBER(4) , CHECK (YERR_JOINED <='2007'));
    Table created.
    SQL> drop table t;
    Table dropped.
    SQL> CREATE TABLE T ( YERR_JOINED NUMBER(4) , CHECK (YERR_JOINED <= TO_CHAR(SYSDATE,'YYYY')));
    CREATE TABLE T ( YERR_JOINED NUMBER(4) , CHECK (YERR_JOINED <= TO_CHAR(SYSDATE,'YYYY')))
    ERROR at line 1:
    ORA-02436: date or system variable wrongly specified in CHECK constraint
    SQL>

  • Table Maintanance Help Required-urgent

    Hi All,
    I generating table maintanance generator for the table zuser_Secobjects. In this table GUID is a primary key and APPLN,APPLN_TYPE,PARTNER_TYPE are the non primary keys.  I am using two screens method here. on both screens i am not showing GUID ( i am hiding this field in screen1 and screen 2) whenvere new record is created for every record guid is going to create. now my reuirement when i click on position(pushbutton) name in screen 1 it has to show APPLN,APPLN_TYPE,PARTNER_TYPE where as these 4 fields are non primary keys . i am getting uniqire record using guid. so i am keeping guid as primary key.i can't keep these 4 fields as primary keys in the table zuser_secobjects.
    anybody can faced this kind of problem if so please let me know whow to approach in this case.
    thanks,
    maheedhar.t

    Hai Maheedhar,
    I have also faced the related problem.
    <b>Please refer the below links.</b>
    <b>It will helps you a lot.</b>
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20implement%20events%20in%20table%20maintenance.doc
    Table Maintenance generator is required to do Manual entries in the Table. If the requirement is to update the table only programmatically and not manually then table maint. generator is not required.
    Manual entries in table can be maintained ( New record can be inserted / existing can be modified ) using transaction SM 30, if the table maintenance for the table is generated.
    <b>Don'forget to activate it.</b>
    How to activate Table maint.
    Goto SE11 and open the table.
    Click UTILITIES -> Table Maint. Generator, Enter the details and click on Save. Then activate the table.
    <b>Please refer the below links.</b>
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20implement%20events%20in%20table%20maintenance.doc
    <b>Reward points if it helps you.</b>
    Regds,
    Rama chary.Pammi

  • Internal table logic - help required

    Hi,
    I am working on BSEG table to determine offsetting line count and amount total for a posting line item and need
    a small logic .
    I have a table of currency fields like below and the table is such ( like BSEG ) that each line item will balance
    itself with other line item . For example
    Item
    10      100
    20      100-
    30      200
    40      250
    50      450-
    60      200-
    70      200
    80      600
    90      100
    100     200
    110     300
    If you see 10 & 20 balance out similarly ( 30,40 will balance with line item 50 ) , ( 60 & 70 balance each other ) ,
    ( 90,100, 110 balance with 80 ).
    My requirement - If I loop on item 50 with amount 450- I need to get the posnr of the two items which balance
    this amount ( which is 30 and 40 ).  If I loop on item 80 with amount 600 then I need to get item 90. 100 and 110.
    Please provide me a logic which will provide me the index of ther required item lines.
    Regards
    Praneeth

    Hi, execute this code.. might be helpful to you
    TYPES: BEGIN OF test,
             a TYPE i,
             b TYPE i,
           END OF test.
    DATA: itab TYPE TABLE OF test,
           wa  TYPE test,
           wa1 TYPE test,
           c   TYPE i,
           d   TYPE i,
           n1  TYPE i,
           n2  TYPE i.
    PARAMETERS :  p TYPE i.
    wa-a = 1.
    wa-b = 20.
    APPEND wa TO itab.
    wa-a = 2.
    wa-b = 30.
    APPEND wa TO itab.
    wa-a = 3.
    wa-b = 10.
    APPEND wa TO itab.
    wa-a = 4.
    wa-b = 10.
    APPEND wa TO itab.
    wa-a = 5.
    wa-b = 20.
    APPEND wa TO itab.
    READ TABLE itab INTO wa WITH KEY a = p.
    c = wa-b.
    LOOP AT itab INTO wa WHERE a GT p.
       n1 = wa-a.
       IF c EQ wa-b.
         EXIT.
       ENDIF.
       LOOP AT itab INTO wa1 WHERE a GT wa-a.
         IF wa-a = wa1-a.
           EXIT.
         ENDIF.
         n2 = wa1-a.
         d  = wa-b + wa1-b.
         IF c EQ d.
           EXIT.
         ENDIF.
       ENDLOOP.
       IF wa-a = wa1-a.
         EXIT.
       ELSEIF c EQ d.
         EXIT.
       ELSE.
         CLEAR: n1, n2.
       ENDIF.
    ENDLOOP.
    WRITE: n1 , n2.

  • Db link problem help required??

    hello friends,
    error occuredjava.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not update; currently locked by user 'admin' on machine 'mysystem-9ZT4OE'.
    i get this error for using preparedstatement call.so i set the permission for the same in my system for my user account.after doin so i get the same error.
    i implemented this in servlet program.
    plz help reg. this issue
    thank you

    Hi Victor,
    the problem is not the db-link. If you execute the statment "select * from table@dblinkname;" in an pl/sql program you get this error too. The user has not the select privelege maybe only a role. Please grant the select priveleg directly to the user.
    Regards,
    Bert.

  • Internal Table Operation Help Required

    Hi
    I have to insert 8 counters p1-p8 in a field BANFN of ITAB1.
    Like this their are 3 more fileds.I have to show the no. for PR released frm JAN-DEC in ALV format.I had doen the calualation,but unable to insert these conters in ITAB1 to do final calculation & display the result.
    Please help me.
    I had used : insert p1 into itab1-banfn where sy-index 1.
    Like this I had tried out many comands,but al in vain.PLZ help me in this regard.
    Regards.
    Vipin

    There are 8 fileds in my internal table,in which 1st one is for MONTH(JAN-DEC).
    The ALV is only suppose to display 12 rows,containing each month per row.
    Now for each month I have to display the PR converted to PO & the avg lead time for each month.So I had calu all the data ,but now I have to insert 12 counters in 4 fields.one for No of PR converted to PO in each month,than one for AVG LEAD TIME for each month.so there has to be 12 + 12 counters for each row.Similar operation I have to perform for the PR pending fo PO.So there has to be 24 more counters for again 2 diff fileds.Now I had calcuated the data,but the problem is this ,,,,,how to insert each ctr in each row.
    EG: insert ctr1 into itab1-banfn where itab1-mmyy = 'January' or sy-index = 1.
          insert ctr2 into itab1-banfn where itab1-mmyy = 'Febuary' or sy-index = 2.
          move crt1 to itab1-banfn where sy-index = 1.
    None of the operation is working.
    Like this i have to insert 48 counters in all rows for these 4 diff fileds.
    Pl help me in thsi regard ,if possible.
    regards.

  • Oracle 8i us7ascii character set problem - help required urgent.

    Hi frnds,
    I have a oracle 8i database server installed on sun solaris os. The database character set is us7ascii. In one of the tables TIFF images are stored in a long column. I m trying to fetch these images using oracle 9i client and visual basic(oracle ODBC drivers). But i m unable to do so. I can not fetch special characters.
    Is it because of the character set problem? but when i run my code on the server itself, i m able to fetch the images. I tried to fetch the images using oracle 8 i client on windows XP machine but could not do so. Are there any special settings that i have to do on the client side?

    Indeed, it's an ODBC issue. Read this statement from Oracle:
    From ODBC 8.1.7.2.0 drivers onwards it's NOT possible any more to
    "disable" Characterset conversion by specifying for the NLS_LANG
    the same characterset as the database characterset. There is now
    ALWAYS a check to see if a codepoint is valid for that characterset.
    Typically you will encounter problems if you upgrade an environment
    that has NO NLS_LANG set on the client (or US7ASCII) and the database
    was also US7ASCII. This incorrect setup allowed you to store characters
    like èçàé in an US7ASCII database, with the new 8i drivers this is not possible
    any more.
    Basic problem is the 'wrong' characterset US7ASCII in the database. As long as no characterset conversion happens (that's the case on the unix server), special characters are no problem.
    Werner

  • Mutating table problem

    We have a problem using the productivity booster "Maintain DB-package to support businees rule implementation". After running the utility we get the message: Kxception; Note that the text for this element may have been corrupted". The package is created, but the code is corrupted indeed.
    We are using Designer6.0 an Headstart 2.1.2, patch11.
    Our problem resembles the problem issued by Hans van Beek on january 11, 2001
    Thanks in advance

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Headstart Team:
    Benno,
    I had this problem myself a while ago and I'm not 100% sure of my solution, but I figured out it had something to do with the add_line procedure in the productivity booster.
    edit package hsu_ccmr.pkb in the hsu\scripts directory and replace the the following lines in procedure add_line:
    l_block(l_number_of_lines) := p_text_line;
    l_number_of_lines := l_number_of_lines + 1;
    with
    l_number_of_lines := l_number_of_lines + 1;
    l_block(l_number_of_lines) := p_text_line;
    So first increment the counter. I'm not sure this is the complete solution I made but give it a try!
    Recreate the package body under the utilites owner schema and run the utility again.
    Regards, Marc<HR></BLOCKQUOTE>
    Marc,
    We have found the solution in the tapi's.
    Whe have deleted the old code and generated table api's. It was a lot of work but it works.
    Thank you for your reply
    null

  • Validation problem, HELP required

    I have the followig HTML form, I have tried validating the values using Javascript but have had no success.
    I am trying to validate the following: "set1ar" "set1aw" "set2ar" "set2aw" "set3ar" "set3aw" "set4ar" "set4aw".
    I have to ensure that only integer values >= 0 are entered in these fields, so no negative numbers or text. Can someone please help me out here. My thanks in advance.
    <HTML><HEAD><TITLE> Validate </TITLE></HEAD>
    <BODY>
    <form>
    <table>
    <tr><td align="center"> <input name = "set1ar" size=3 maxlength=3></td>
    <td align="center"> <input name = "set1aw" size=3 maxlength=3> kg</td></tr>
    <tr><td align="center"> <input name = "set2ar" size=3 maxlength=3></td>
    <td align="center"> <input name = "set2aw" size=3 maxlength=3> kg</td></tr>
    <tr><td align="center"> <input name = "set3ar" size=3 maxlength=3></td>
    <td align="center"> <input name = "set3aw" size=3 maxlength=3> kg</td></tr>
    <tr><td align="center"> <input name = "set4ar" size=3 maxlength=3></td>
    <td align="center"> <input name = "set4aw" size=3 maxlength=3> kg</td></tr>
    </table>
    <input type="submit" value="submit">
    </form>
    </BODY></HTML>

    Hi !
    You can try the following Javascript function . It will not allow the user to enter any character other than between 0-9 .
    function check_key(evt)
              var nbr,chr;
              var bool=0;
              if(window.Event)
                   nbr=evt.which;
              else
                   nbr=event.keyCode;
              if( (nbr>=0 && nbr<=32) || (nbr>=48 && nbr<=57) || (nbr==46) )
                   bool=1;     
              if(bool==0)
                   alert("Invalid Character");
                   return false;     
              else
              if(bool==1)
                   return true;
    Add the following HTML code .
    < input type="text" name="T1" onKeyPress="return check_key(event);">
    Also search for better alternatives .
    Cheers.
    - pranav

  • Live table insertion help required

    I face issue of constraint violation the time when i try to insert record which already exist in table actually the table is getting populated on real basis and the record which i try to upload is around 2.5 million.
    I need a PL/SQL code which perform insertion into live table and don't insert those records which already exists in live table.
    I am new in PL/SQL and need your expert guidence
    Please help
    regards,

    In pl/sql you can trap oracle errors via an exception handler. For instance suppose you want to insert two rows, and the second row already exists (i.e. that row will get an oracle key-constraint error).
    The way to deal with such an error in this case, would be to write a handler for the DUP_VAL_ON_INDEX error.
    begin
      begin
        insert into some_table values(.. some values ..);
        insert into some_table values(.. some other values ..);
      exception when dup_val_on_index
        then null;
      end;
      commit;
    end;Above code will ignore the error for the second row, and will keep the first row inserted (and committed).

  • Table view help required

    hi,
    I've a htmlb tableview which gets the data from an internal table which is a data member of a model. I've two column fields in this view which are editable. What are the steps I need to follow in order to get the internal table updated with the values provided by the user in the editable fields of tableview.
    could someone please provide me with the steps as to how to achieve this?
    Thanks and Regards,
    Vamshi

    Hi Vamshi,
    Try this  sample code,as it helps you considerably.
    local types
    types: itabtype type TABLE OF STD1.
    types: begin of message_struct,
    type type char10,
    text type char100,
    end of message_struct.
    page attributes
    addtab TYPE ITABTYPE
    addtab_row TYPE STD1
    add_flag TYPE FLAG
    deltab TYPE ITABTYE
    deltab_row TYPE STD1
    ITAB TYPE ITABTYPE
    iterator TYPE REF TO IF_HTMLB_TABLEVIEW_ITERATOR
    message TYPE MESSAGE_STRUCT
    STUDENT TYPE STRING
    STATUS TYPE STRING
    <b>layout</b>
    <htmlb:content design="design2003" >
      <htmlb:page title="test1" >
       <htmlb:form>
    <htmlb:tableView id              = "tv1"
                               visibleRowCount = "20"
                               onRowSelection  = "MyEventRowSelection"
                               selectionMode   = "lineEdit"
                               table           = "<%= ITAB %>"
                               iterator        = "<%=iterator %>" />
                  <htmlb:button id      = "save"
                                text    = "Save Changes"
                                onClick = "myEvent" />
    eventhandler OnCreate
    this handler is called once the page is first created (stateful mode)
    it performs a once-off data initialization or object creation
    SELECT * FROM STD1
                INTO CORRESPONDING FIELDS OF TABLE itab.
    CREATE OBJECT iterator TYPE  STD1ITERATOR.
    eventhandler OnInputProcessing
    event handler for checking and processing user input and
    for defining navigation
    DATA: ITAB_WA type Line of  itabtype.
    DATA: event TYPE REF TO cl_htmlb_event.
    event = cl_htmlb_manager=>get_event( runtime->server->request ).
    FIELD-SYMBOLS: <row> type STD1.
    DATA: tv TYPE REF TO cl_htmlb_tableview.
    tv ?= cl_htmlb_manager=>get_data(
                            request      = runtime->server->request
                            name         = 'tableView'
                            id           = 'tv1' ).
    IF tv IS NOT INITIAL.
      DATA: tv_data TYPE REF TO cl_htmlb_event_tableview.
      tv_data = tv->data.
      IF tv_data->prevselectedrowindex IS NOT INITIAL.
       FIELD-SYMBOLS: <row> type LINE OF ITABTYPE .
        READ TABLE ITAB INDEX tv_data->prevselectedrowindex
        ASSIGNING <row>.
        DATA value TYPE string.
      if <row> is assigned.
        value = tv_data->get_cell_id( row_index    =
                     tv_data->prevselectedrowindex
                                       column_index = '1' ).
         DATA: inputfield TYPE REF TO cl_htmlb_inputfield.
        inputfield ?= cl_htmlb_manager=>get_data(
                                request      = request
                                name         = 'inputfield'
                                id           = value ).
        <row>-STUDENT = inputfield->value.
        value = tv_data->get_cell_id( row_index    =
                     tv_data->prevselectedrowindex
                                       column_index = '2' ).
        inputfield ?= cl_htmlb_manager=>get_data(
                                request      = request
                                name         = 'inputfield'
                                id           = value ).
        <row>-STATUS = inputfield->value.
    ENDIF.
    ENDIF.
    WHEN 'add'.
        tv ?= cl_htmlb_manager=>get_data(
                                  request      = runtime->server->request
                                  name         = 'tableView'
                                  id           = 'tv1' ).
        IF tv IS NOT INITIAL.
          tv_data = tv->data.
          IF tv_data->prevselectedrowindex IS NOT INITIAL.
            READ TABLE itab INDEX tv_data->prevselectedrowindex
             ASSIGNING <row>.
          endif.
        endif.
    WHEN 'add'.
        add_flag = 'Y'.
      WHEN 'add_save'.
    ITAB_WA-STATUS = request->get_form_field( 'STUDENT' ).
    ITAB_WA-STATUS = request->get_form_field( 'STATUS' ).
    endcase.

  • Table Control Help required

    Hi,
    Right now I am working in table control.
    I have an internal table that is getting displayed onto the table control,the internal table has the primary key MATNR in it.
    When the user enters an identical MATNR in the second row the validation should throw a message that'Entry already exists' and the entry should get deleted.
    The internal table is filled up from the database table using the WBS Element.Then before saving the new entry ,the database entry for the WBS element is deleted.
    After updating the Internal table the internal table is inserted into the database table.
    Can anyone let me know how to validate the new entry against the entries already existing in the internal table.
    Hope i am able to make the problem clear to you.

    In the PAI Event write the code inside the CHAIN & ENDCHAIN.
    PROCESS AFTER INPUT.
    *pai flow logic for tablecontrol 'MPRN'
      LOOP AT i_mprn.
        CHAIN.
          FIELD:  i_mprn-select,
                  i_mprn-mprn,
                  i_mprn-post_code,
                  i_mprn-dm_ndm
          MODULE validate_mprn.
        ENDCHAIN.
        MODULE tabctrl_modify.
      ENDLOOP.
    MODULE validate_mprn INPUT.
      IF sy-ucomm EQ 'MPSB'.
        PERFORM validate_mprn.
      ENDIF.
    ENDMODULE.                 " validate_mprn  INPUT

  • N86 8GB -persistent problems -help required

    I bought N86 yesterday.this phone hangs/freezes at almost anytime--while setting time, while typing the name of new contact, while renaming a music file,while using maps zoom in and zoom out,camera refuses open for hours together,opening the slide just befor typing something.I don't understand --DOES NOKIA EVER CHECK THE STABILITY OF ITS MODELS BEFORE RELEASING??????????. My old grandpa of nseries -N90 even to this date woks great wiithout a hitch!!!!!!!!!!!!!!!!!!!!!!. Hope does look into this!!!!!!!!!!!!!

    Try to reinstall the firmware through NSU but it will reduce the freezing issue wont wipe out it completely. I am also facing the similar problem on N86 which I bought in Mumbai, India on 11th July. I have reinstalled the firmware which is 10.086 as only this is available in India on NSU. And my freezing problem reduced a lot. But still not completely gone. I am gonna ask for replacement from the distributor for my N86.
    Please click on Kudos at upper right corner, If you think my post is helpful to you.

  • Table Maintanance Help Required

    Hi All,
    I am using two screens in my table maintanace. I am doing all my validations in screen2.After entering the data when i click on save button Ztable will update. this is working fine for single entry. When i am entering multiple entries for example both entries are duplicate then it is giving error message like duplicate entry after this displaying this message when i click on EXIT button unique record is showing in screen 1.
    my two entries are
    1. runrate maheed  a01
    2. runrate maheed a01
    uniure record means single record i.e. runrate maheed a01 is showing on first screen. actually i dont want to display this entry in screen 1. is this possible if not please tell me any other alternate is exist.
    Thanks,
    Maheedahr.T

    Hi ,
    Please check the primary key combination of the z table. it do not allow you to insert 2 records with same primary key fields value.
    regards,
    Tanmay

Maybe you are looking for

  • MISSING: Time, Date, Battery Info

    Since the new update, the Time, Date, Battery Info, etc that is normally in the top right hand corner toolbar is gone. Going into system preferences to click the box for time doesn't work, because it is checked.

  • IPhone synced with another library..."Erase and Sync" question

    I helped someone transfer from an older iPhone to an iPhone 6 and did an encrypted backup on my laptop and then restored that backup to their new phone. When they took the phone home and tried to sync their library with it they got the following mess

  • Trap on a link failure

    does someone know how to enable a snmp trap if an interface link goes down? There are 4 bge interfaces, the IP of the SNMP Manager configured. In the /var/adm/messages can be seen that a link goes down, but no snmp traps/notifications are being sent.

  • How do I charge my iPad in the car?

    I bought a car charger and also hooked up my iPad to my computer, and it doesn't charge either way. Why is that?

  • Authorware exe file to run in Moodle

    Can an authorware exe file run in Moodle, without the users having to download the AW player?  How is this done?