Implementing Conditional Insert

I use tips in the article "Implementing Conditional Insert, Update, and Delete Allows for View Objects" from "Steve Muench's Radio Weblog".
At the start all it's ok, but I found this problem:
1. I have two views (V1 and V2) over the same entity (E1)
2. V1 permit insert, delete, update, and select.
3. V2 overwrite method create and don't allow insert.
4. If you use V1 and try to insert a record all go ok.
5. If you use V2 and try to insert a record get an exception "It's not allow insert into V2", It's Ok.
6. If you use V1 again and try to insert a record you get an exception, that say "It's not allow insert into V2".
I'm investigate the case, and found that when you insert a record in E1 throw V1, the framework (BC4) try to create the record in the views that are instantiated over the entity E1, for this call method "create" on views.
Do you know some workaround ?
thank in advice...

Hi, again, I have question about this...
I post it in the forum...
If I use "isAssociationConsistent()" I have to know all views that depend of same entity, and its privileges. I have problem with that because if I add a view a have to remember to put this in the code.
I need to confirm: is return of method "this.getEntity(0).isInCache()" true when record was inserting in other entity ?
May I modify your sample like this:
public class CustomViewRowImpl extends ViewRowImpl {
protected void create(AttributeList nvp) {
if ( this.getEntity(0).isInCache() || getVO().isInsertAllowed()) {
super.create(nvp);
else {
throw new JboException("Insert not allowed in this view");
thank a lot

Similar Messages

  • Implementing Conditional Insert, Update, and Delete Allows for View Objects

    Steve,
    Thanks for the info in this article it was very helpful. I have one question as I created a test case that used dept & emp tables as master and detail.
    Placing code in the emp detail ViewRowImpl that also tests to see if the master is updateable and it all works fine but I noticed that when you run it in the tester the dept master fields are grayed out but not the emp details and if you bring up the emp detail with out the view link then they are grayed out.
    Just wondering is this just a fact of the detail being shown in a table in the master detail and not a form or is there more to it then that??

    yes as follows:
    isMasterUpdateable checks the Dept table to see if it is updateable before allowing emp to be updated.
    public boolean isAttributeUpdateable(int index)
    if ( isMasterUpdateable() == true )
    return ( super.isAttributeUpdateable(index) );
    return(false);
    When I run this in the tester the results are correct except for the visual where the form is grayed out but the detail in the table is not. Should the table gray out also or is this effect something that must be coded in all Jtables that i may implement? If it needs to be coded to get the effect where does Jtable check for isAttributeUpdateable ?
    thanks,

  • How to Implement Condition-Based Tax Calculation in R/3 for Mexico

    Is there a manual, or some type of guide to implementing condition-based tax calculation in R/3 for Mexico?
    Kind regards,
    Mark Walker

    Hey Mark,
    Check the following link for mexico taxes, may be helpful to you..
    http://help.sap.com/printdocu/core/Print46c/EN/data/pdf/CAINTMX/CAINTMX.pdf
    Thanks
    Prasada

  • How to Implement basic Insert ,Update and delete Actions

    Hi all,
              i want to implement 1)INSERT 2)UPDATE 3)DELETE actions in webdynpro application means i have to add a new record to my R/3 backend and update and delete records from my database
    can anyone tell me how to do these actions
    Regards
    Padma N

    Hi Murtuza ,
                           I have 2 views in my application.In the first view i enterd some purchaseorder number and clicked serarch button.The items regarding that purchaseorder gets populated in the table which is in second view.All the data is in R/3 backend system.
    the code i used to get the details of that particular purchaseorder is
    try {
    wdcontext.currentZ_Matrls_For_Inputlement().modelObiect.execte();
    catch(RFCException e){
    /* Catch the Exception Here */
    Here now i want to delete one record of that particular purchaseorder from the database.So Wat should be the code to delete record from R/3 Model
    Regards
    Padma N

  • MERGE w/ conditional Insert clause

    Hi--
    Sum Up:Is it possible to run Merge syntax with update and a conditional Insert clauses ?
    Question Details
    Have a base table Emp and staging table New_Emp with a common identifier Emp_id.
    The ideal would be to merge the 2 tables and update Emp using New_Emp values and
    insert only some new emp, not all records.
    Any ideas ? Thks
    Lamine

    Absolutely. See the docs. Use the WHEN and WHERE clauses.
    Tom Best

  • How to Implement Toggle Insert/Replace Mode

    I have to implement Toggle Insert/Replace Mode in Oracle 10 g forms Text Items . for that I have tried the following methods but it is not working. could you please help me?
    In fmrweb.res file , I have add teh following line and tried with same combination in keyboard.
    65 : 1 : "Shift+A" : 25 : "Toggle Insert/Replace Mode"

    You can use a pluggable Java Component to do this and there is an example in the Forms 9i demos.

  • Conditional Insert within Merge???

    can we use conditional insert within the merge statement????
    thanks a lot..
    nantha

    NanthaKumarAR wrote:
    is there is any possible way to do so????
    thanks a alot ....
    nanthaHmmm let's look at the conversation so far...
    You: "is this possible?????"
    Me: "No."
    You: "is there is any possible way to do so????"
    I'm now wondering which part of "No" you failed to understand.
    You cannot perform multiple/conditional inserts within a MERGE statement. The purpose of a MERGE statement is to take data and MERGE it into a single table.
    The only messy way I can think of would be to merge into an intermediate table with triggers on it, that takes the merged data and splits it out into the seperate tables. Messy and not likely the best solution to the initial problem, which would probably be better solved by avoiding the use of MERGE in the first place (though we don't know what problem you are actually trying to solve).

  • Conditional Insert

    Hi,
    Is it possible to do a conditional insert? e.g.
    IF :P2_NAME != (SELECT name from hk.appname where name = :P2_NAME) then
    INSERT....
    END IF;So if the value of :P2_NAME doesn't exist within the table then it will be inserted...its to be an addition to a currently existing APEX process (checks that field values aren't null then enters a record into a different table than hk.appname).
    Thanks for any help.
    Mike

    Dird wrote:
    PLS-00405: subquery not allowed in this context As I said:
    IF :P6_NEW_PROJ IS NOT NULL THEN
    proj := lower(:P6_NEW_PROJ);
    ELSE
    proj := :P6_PROJECT;
    END IF;
    insert into hkadm.applic@XXX (appl_name) select proj from dual
    where 0 = (select count(*) from hkadm.applic@XXX where appl_name = proj and rownum = 1);SY.

  • Conditional Insertion in table based on Field

    Hi all,
      I am having 3 text input fields in my page, Empno, Ename, Sal
      After inserting data in the fields, commission column has to be populate automatically, based on conditions.
      Conditions are : If the salary is less than 5000 the commission 500 has to be insert, salary is greater than 5000 commission 1000 has to be inserted.
    how can I achieve this, and where I have to implement the logic, please help me out.
    Thanks in Advance
    Jagadish

    Hi,
    You can apply PPR on salary field. Then catch the event and based on condition, set the value of commission field.
    Also, you can check this link for PPR:
    http://sushantsharmaa.blogspot.in/2012/12/11-ppr-partial-page-rendering-in-oaf.html
    --Sushant

  • Implement Conditional Read-Only of Column Across Two Tables

    Hello,
    I would like to implement a "conditional read-only" mechanism on a column in a table with two tables in total being involved in this situation.
    I have a demo/proof of concept of this and things are working as expected in the tests I have performed; however, I would like any input as to whether there is a better way, etc.
    Here's a contrived demo but which illustrates the key ingredients nevertheless. Oracle version 10.2.0.4 64-bit on Windows Server 2008 Release 2 64-bit.
    - Table DDL and small sample data
    create table band(
      band_id   number primary key,
      band_name varchar2(20),
      status    varchar2(20)
    create table band_member(
      band_id references band,
      member_name varchar2(20)
    insert into band values(3, 'The Rutles', 'prefab4');
    insert into band values(4, 'The Beatles', 'established');
    commit;
    insert into band_member values(3, 'Ron Nasty');
    insert into band_member values(3, 'Dirk McQuickly');
    insert into band_member values(3, 'Stig O''Hara');
    insert into band_member values(3, 'Barrington Womble');
    commit;
    insert into band_member values(4, 'John Lennon');
    insert into band_member values(4, 'Paul McCartney');
    insert into band_member values(4, 'George Harrison');
    insert into band_member values(4, 'Ringo Starr');
    commit;- The rules regarding the conditional read-only goal
    1. Not permitted to update band.band_name when band.status='prefab4'
    2. Not permitted to insert/update/delete any rows in band_member when the parent row has band.status='prefab4'
    - Triggers used to implement the goal (current solution)
    create or replace trigger t1
    before update of band_name on band
    for each row
    when (old.status = 'prefab4' or new.status = 'prefab4')
    begin
      raise_application_error(-20010,
        'can not update band_name when status=''prefab4''');
    end;
    create or replace trigger t2
    before insert or update or delete on band_member
    for each row
    declare
      l_status band.status%type;
      l_band_id band_member.band_id%type;
      cursor l_cursor (p_band_id number) is
      select status from band
      where band_id = p_band_id
      for update;
    begin
      if updating or inserting then
        l_band_id := :new.band_id;
      else
        l_band_id := :old.band_id;
      end if;
      open l_cursor(l_band_id);
      fetch l_cursor into l_status;
      close l_cursor;
      if l_status = 'prefab4' then
        raise_application_error(-20011,
          'can not update child when parent status=''prefab4''');
      end if;
    end;
    /- Quick sample test for each condition
    update band
    set    band_name = 'THE RUTLES'
    where  band_id = 3;
    update band
    ERROR at line 1:
    ORA-20010: can not update band_name when status='prefab4'
    ORA-06512: at "DEMO.T1", line 2
    ORA-04088: error during execution of trigger 'DEMO.T1'
    update band_member
    set    member_name = 'RON NASTY'
    where  member_name = 'Ron Nasty';
    update band_member
    ERROR at line 1:
    ORA-20011: can not update child when parent status='prefab4'
    ORA-06512: at "DEMO.T2", line 18
    ORA-04088: error during execution of trigger 'DEMO.T2'As I say, whilst my simple tests look to show the correct results, I'm left wondering if there might be a better way to implement said functionality.
    I've attempted to provide the required information, but if I've managed to omit anything, please let me know.
    Cheers,
    Chalfont

    Hi, Chalfont,
    user13146957 wrote:
    I went the cursor route to add the "for update" clause to force serialisation on the row - i.e. the idea was to avoid the case where another session might have wanted to update the status an instant after my fetch but before the remainder of the code completed. Does that make sense?No not really. The trigger on band prevents anyone from ever changing status from 'prefab4' to anything else (or vice-versa).
    Even aside from that, you're putting in some effor to prevent something that will be allowed a split second later (or maybe the other way around). What's so significant about that split second?
    I've been thinking of other ideas rather than the trigger approach, but have come up empty, as it were, thus far. I'm open to using other approaches and making some schema changes is not off the table either.FGA (Fine Grained Access), or its older sibling VPD (Virtual Private Database) can also do what you want, but, instead of raising an error, they just ignore the illegal action. This may be an advantage or a disadvantage, depending on your requirements.
    Another approach is for the owner of the table not to grant INSERT, UPDATE or DELETE privileges to anyone: all DML must be done through a procedure (or procedures) owned by the table owner, who grants EXECUTE privileges instead of the other privileges.

  • Conditionally inserting tiles

    Hello All,
    I am using tiles with JSF. In my jsf page, i have the below logic but still the tiles get inserted...
    <% if(false){ %>
    <tiles:insert definition="NonMember" flush="false"/>
    <% } %>
    I am not sure whats happening.. does anyone know whats happening here...
    Basically,i want to check a condition and if the condition is false, i dont want to insert the tiles..

    Make sure nonMember definition is accessible via the jsp page:
    <f:verbatim>
    <%
    String nonMember = ...
    if(false)
    %>
    <tiles:insert name="<%=nonMember%>" flush="false" />
    <%
    %>
    </f:verbatim>
    Hope this may help.
    BaTien
    DBGROUPS

  • Conditional insert in plsql

    Hi friends,
    I am a beginner in Oracle PLSQL. I need to insert a row into a table based on a condition. The condition is to check if the value is already there in another table.
    i.e, If the username is already present in the users table then the username should not be added to username table. I have written a stored procedure to insert into the username table but need i do not know how to check for the condition.
    Could you please let me know how to get this. I tried a lot but getting compilation errors.
    Regards,
    Padeep

    Use Control Statements
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/controlstatements.htm
    Such as: IF-THEN-ELSE or CASE
    That documentation is for 11.2. Your Oracle version may be different, but since IF statements have been around for a long time, this will do.
    Alternatively, consider a unique index on the field.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17120/indexes003.htm#ADMIN11724
    Or even consider using a MERGE statement:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_9016.htm#SQLRF01606

  • Receiver jdbc adapter:how to implement the insert or update action in a sql

    Hi,gurus:
    I'm using receiver jdbc adapter now.
    You know, we have to gave the action the value 'update' or 'insert',but in our case,the action is variant--update or insert.It decides whether the record exists in the outer database.
    Can stored procedure do this?If I use stored procedure,then must I create a stored procedure in the outer database?
    Or some other ways to solute my issue?
    THanks in advance.

    Hi
    Use Action UPDATE_INSERT .
    This action check if a record exist with same key value then update that record. In case no record with key value found in database then record inserted to database.
    look receiver structure
    http://help.sap.com/saphelp_nw2004s/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm

  • Conditional Insert into staging table by using sqlloader

    Hi,
    In Oracle apps I'm submitting a concurrent program programmatically which will call sqlloader and insert into a staging a table.
    This table consists of 30 columns.Program has one input parameter.If parameter value = REQUIRED Then it should insert into first three columns of staging table.If it's APPROVED then it should insert into first 10 columns of the same table.
    Data file is pipe delimited file which may or may not have all possible values :For Required,I many not have all three column values

    >
    I think you understood the thinks wrongly. OP marked UTL_FILE as the correct answer, which is again a server side solution.
    >
    Perhaps you failed to notice that the answer now marked correct was posted AFTER mine. I'm not clairvoyant and OP did not state whether a server side or client side solution was appropriate.
    I stand by my comments. Using an external table is an alternative to sql loader but, as I said, simply using an external table instead of sql loader doesn't address OPs problem.
    >
    And IMO, external table will be faster than UTL_FILE
    >
    I'd be more concerned with why OP wants to write a procedure to parse flat files, deal with data conversion errors and perform table inserts when Oracle already provides that functionality using either external tables or sql loader.
    I would suggest loading the file into a new staging table that can hold all of the columns that might be contained in the flat file. Then the appropriate data can be moved to OPs staging table according to the required business rules.
    Sounds like we each think OP should reconsider the architecture.

  • Conditional insertion into a table

    Hello:
    I've a base table into which records are inserted from results returned by a query. The query always runs on the current date every hour. There are some preconditions before insertion:
    1) The backdated records will remain as it is;
    2) If query finds a new Number it will be inserted in the table;
    3) If query finds a same number but Count is more, it will also inserted in the table.
    TABLE1-
    Number|PDATE|CATEGORY|MARKED|COUNT
    1|29-APR-2012|C1|Y|2
    3|30-APR-2012|C1|Y|1
    4|30-APR-2012|C1|Y|1
    5|30-APR-2012|C1|Y|3
    Query Result-
    Number|TDATE|COUNT
    1|30-APR-2012|1
    2|30-APR-2012|5
    3|30-APR-2012|1
    4|30-APR-2012|9
    5|30-APR-2012|3
    Output: (Updated Table-1)
    Number|PDATE|CATEGORY|MARKED|COUNT
    1|29-APR-2012|C1|Y|2
    1|30-APR-2012|C1|N|1
    2|30-APR-2012|C1|N|5
    3|30-APR-2012|C1|Y|1
    4|30-APR-2012|C1|Y|1
    4|30-APR-2012|C1|N|9
    5|30-APR-2012|C1|Y|3
    Explain Output: The query is running on 30-Apr-2012
    1|29-APR-2012|C1|Y|2: This is a backdated record. So, remained unchanged.
    1|30-APR-2012|C1|N|1: 1 of today was not in the table. So, it is inserted with Status 'N'
    2|30-APR-2012|C1|N|5: 2 of today was not in the table. So, it is inserted with Status 'N'
    3|30-APR-2012|C1|Y|1: 3 is already in the table. So, unchanged.
    4|30-APR-2012|C1|N|9: 4 will be inserted cause count (9) is more than previous (1). So, it is inserted with Status 'N'
    5|30-APR-2012|C1|Y|3: 5 is already in the table. So, unchanged.
    Can anyone help me with query?
    Thanks/Razin

    Hope below helps you
    CREATE TABLE T
    (  NUM      NUMBER,
       PDATE    DATE,
       CATEGORY VARCHAR2(2),
       MARKED   VARCHAR2(1),
       COUNT    NUMBER
    INSERT INTO T VALUES (1,'29-APR-2012','C1','Y',2);
    INSERT INTO T VALUES (3,'30-APR-2012','C1','Y',1);
    INSERT INTO T VALUES (4,'30-APR-2012','C1','Y',1);
    INSERT INTO T VALUES (5,'30-APR-2012','C1','Y',3);
    INSERT INTO T(NUM, PDATE, CATEGORY, MARKED, COUNT )
    WITH QUERY_RESULT AS
    ( SELECT 1 NUM , TO_DATE('30-APR-2012','DD-MON-YYYY') PDATE,1 CNT FROM DUAL UNION ALL
      SELECT 2     , TO_DATE('30-APR-2012','DD-MON-YYYY'),5 FROM DUAL UNION ALL
      SELECT 3     , TO_DATE('30-APR-2012','DD-MON-YYYY'),1 FROM DUAL UNION ALL
      SELECT 4     , TO_DATE('30-APR-2012','DD-MON-YYYY'),9 FROM DUAL UNION ALL
      SELECT 5     , TO_DATE('30-APR-2012','DD-MON-YYYY'),3 FROM DUAL
    SELECT R.NUM, R.PDATE, 'C1','N', R.CNT
    FROM QUERY_RESULT R
    WHERE NOT EXISTS ( SELECT NULL
                       FROM T
                       WHERE R.NUM = T.NUM AND ( R.PDATE < T.PDATE OR (R.PDATE = T.PDATE AND R.CNT <= T.COUNT ))
    SELECT * FROM T
           NUM PDATE     CATEGORY   MARKED          COUNT
             1 29-APR-12 C1         Y                   2
             1 30-APR-12 C1         N                   1
             2 30-APR-12 C1         N                   5
             3 30-APR-12 C1         Y                   1
             4 30-APR-12 C1         Y                   1
             4 30-APR-12 C1         N                   9
             5 30-APR-12 C1         Y                   3
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Could not load file or assembly 'log4net, Version=1.2.10.0

    Server Error in '/' Application. Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The located assembly's manifest definition does not match the assembly referenc

  • MM automatic account assignment for MIGO (additional accounting lines)

    Hi MM Experts! I created a PO (only 1 material in it), and after that I did a GR goods receipt in MIGO for this. Movement type: 101 When I did this the accounting lines looks like that: Itm PK Account    Account short text   Assignment...............

  • Function used in web dynpro java application

    Hi I am creating some application in web dynpro java by using ABAP function module and table. I am trying to put data to table and update data in table and delete data in table in my application by using ABAP function by using RFC. And this is the AB

  • I want my WS app. executes only from a browser link

    I am planning to write a game in java and instead of using an applet, I am considering to use Web Start technology. However, there's one thing that I have been trying to find out in the last couple of hours is that, is it possible to restrict my app'

  • 6230i help plz pzl :(

    i Have a 6230i i have connected it to my pc but i need a MMC to explore the fetures i havnt got a MMc is there any other way i can connect whtih my computer p.s ashamed but truth is i dont now what sync is so can u say full information plz thx alot H