How to stop insert of new row in tabular form if it's also being deleted

Suppose you have a tabular form, and one of the fields is a not-null column. A user checks a button to "add additional row", which adds a new row to the form, defaulting that not-null column to null. Assume it's a name or something, so there is no reasonable non-null default value that can be entered here to keep it from being null.
Now suppose the user makes a series of changes on the page, but then decides they don't want that row they just added, so they mark it for deletion, then click on "Delete Checked Rows". The not-null column was left blank.
The page is constructed in such a way that the ApplyMRD process runs first, then the ApplyMRU process. (I do this so that the user doesn't lose all their updates if they want to delete a row. I've had a few people complain when they tried to combine both operations, and unexpectedly lost their updates when they hit delete instead of submit.)
What happens? The page errors out because the ApplyMRU process is trying to insert a row with a null value in a not-null column. The ApplyMRD process ran fine, but because the row marked for deletion didn't exist in the database to begin with, it effectively did nothing. But ApplyMRU still tries to add the row, even though it was marked for deletion.
Is there any way to prevent this scenario from happening, without requiring the user to Cancel instead of deleting the blank row, which would cause all other changes on the page to be lost? I'd also like to avoid losing the ApplyMRU process when the user clicks "Delete", since it's more effective to combine operations and this will address the UI complaints I'd received otherwise.
(This is on ApEx 4.0, if it matters.)
Thanks,
Keith

Thinking about this some more, doing the delete and update together may not be an easy thing to accomplish after all.
Consider the above scenario, but the user puts a dummy value like "ignore-me" into the not-null text field, so the error doesn't come up with ApplyMRU is fired. But if ApplyMRD runs before ApplyMRU, it still doesn't do anything because there is no row in the database with the value "ignore-me". Then ApplyMRU runs and it adds that row, even though it was marked for deletion.
So you probably need to always run ApplyMRU before ApplyMRD. But then you wind up inserting a row before you delete it, and that may have unintended side effects, if the user really never wanted to add it in the first place.
Right now, the only workaround I can think of is to:
1) put ApplyMRU before ApplyMRD
2) add a pre-commit validation that checks to see if a row is blank AND checked, and if so, put a dummy value into the not-null field
3) let that row get added and then deleted, and make sure there are no side effects from this (for example, there is an audit table that tracks updates to the base table -- I can add a trigger that does nothing if presented with this dummy value)
Hopefully, though, there is an easier and more "built-in" way to achieve what I'm aiming for.

Similar Messages

  • How to add a new row in Tabular Form based on a table

    Hi
    I have tabular form based on a table.
    I want the table to have an empty row when there is no data
    in the table so that I can enter data directly.
    But right now whenever the page is launched, its showing a no data found message and I have to press the 'Add Row' button to enter data.
    Can anyone help me out on this?
    Thanks

    Hi Leo
    Your suggestion works fine in the APEX 2.1
    But in 3.0.1 it gives this error :
    Error in add row internal routine: ORA-01476: divisor is equal to zero
    Error Unable to add rows.
    I am not sure why this happens.

  • Dynamic Action on new row in Tabular Form

    Hi Guys,
    APEX version is 4.1
    I created a dynamic action on change of a select list, if changed then disable the related fields on the same row.
    This is working fine for all EXISTING rows on the tabular form.
    However, if I click on ADD ROW button, a new row is added to the page, but the change event on select list is
    not triggerred from the dynamic action.
    Is there any thoughts or workaround on this interesting problem?
    Thanks in advance,
    Frank

    I got it working by adding a onchange event which is triggering js function on the page.

  • Inserting a new row in a child table referencing an already existing parent

    I have two tables PARENT & CHILD (one to many), both of which are populated at different times.
    In our toplink mappings, parent contains a collection of child Domain Objects, & and child Domain object contains a one - one to parent.
    How can I insert a new row in a child table with reference to an already existing row in parent?
    When I fetch the parent Domain object and try to set it in the child Domain Object and use the unitOfWork.registerObject() it goes into a circular loop of selecting from 2 other tables.
    Please suggest.

    Odd, have you disabled caching and indirection? (NoIdentityMap, dontUseIndirection, or alwaysRefresh/disableCacheHits). If so, then this could be the issue.
    Otherwise please include the sample code you use to perform this, and verify that you do not have any unusual code in your set/get methods or in descriptor events. Also turn TopLink logging on and include a sample. Also ensure that you do not modify your objects until after registering them in the unit of work, and only modify the unit of work clones.

  • How to insert a new row in the middle of an set of rows

    Hi
    How to insert a new  row in the middle of an set of rows ? and How to Reset the line id after the new row added ?
    Regards,
    Sudhir B.

    Hai,
    just try this,
    Instead of using omatrix.Addrow(1,-1) use like
    omatrix.AddRow( RowCount , Position)
    RowCount
    The number of rows to add (default is 1)
    Position
    The position of the new rows (0-based; default is -1, meaning append row to the end)
    After adding rows in matrix For, sno.
    for i=1 to omatrix.visualrowcount
    otext=omatrix.getcellspecific("columnid",i)  '--where columnid is the unique id of the sno column
    otext.value=i
    next i
    Hope this helps you.
    Thanks & Regards,
    Parvatha Solai.N

  • How to insert the new row after current row in RowIterator - Steve Muench

    Hi,
    Our client wants the new row to be added after current row on the front end instead of before current row.
    we were using "new JUActionBinding(this,iterBinding,JUActionBinding.ACTION_CREATE_INSERT_ROW);" this code inserts the new row after current row.
    I tried a lot to insert the new row after current row. Used new JUActionBinding(this,iterBinding,JUActionBinding.ACTION_LAST to move the cursor to last row in rowiterator and the used .ACTION_CREATE_INSERT_ROW but this thing inserts the new row as the second last row.
    Could somebody plesae help ?
    Message was edited by:
    user556161

    I am using JDeveloper 9.0.4.2.0 (Build 1459)

  • How to Insert the New Row in the  Workbook (b/w the Records)

    Hi All,
    In my workbook, I have 10 records.
    So my requirement is after 5 Records I want to Insert a New Row( ex: Total(1st Column) : SUM (2nd Column)of first five records )
    And remaining records should display the same after inserted row.
    For that what i did, Inserted a new row and put the sum for the first five records and save the workbook.
    Problem is when I refresh the workbook, The inserted row is disappearing.
    Please let me know can we do the aboue requirment or not?
    Regards
    Josu

    Hello joji,
    Please check this thread for changing working book template...
    check the last post by Bhanu..
    Re: Web Template creation .

  • BAPI to insert a new row in the MCHA table

    Hi all,
    I am in search of a BAPI to insert a new row in the MCHA table... with the fields of the materail, plant and batch values.
    Any inputs on this..is highly appreciable...
    thanks in advance...
    regards..
    prathima.

    explore BAPI_BATCH_CREATE

  • BAPI to insert a new row in the AUSP table

    Hi all,
    I am in search of a BAPI to insert a new row in the AUSP table... with the fields of the object and
    characteristic values.
    Any inputs on this..is highly appreciable...
    thanks in advance...
    regards..
    prathima.

    hi,
    from best of my knowledge  here is list of bapi through you can insert ausp table.
    check it.
    CLSE_SELECT_AUSP
    CLVF_INSERT_AUSP
    BAPI_CLASS_CREATE
    C14K_AUSP_CHANGE_VALUE
    CLSE_SELECT_AUSP
    CLVF_UPDATE_AUSP
    C14K_AUSP_ADD_UPD
    BAPI_CLASS_CREATE
    regards,
    vipul

  • Query regarding inserting a new row at first row data table

    hi all,
    I have a doubt regarding the insertion of new row in data table.I am now using the following code
    if (skillDataProvider.canAppendRow()){
    RowKey rowkey = skillDataProvider.appendRow();
    skillDataProvider.setCursorRow(rowkey);
    String skillID=getSkilID();
    skillDataProvider.setValue("Skill.SkillID", rowkey, skillID);
    int rowID=Integer.parseInt(rowkey.getRowId());
    tableRowGroup1.setFirst(rowID);
    Its working fine.But this code gives me provision to add the data at the last of the table.I need it to be at the first row.I tried
    RowKey rowkey=skillDataProvider.insertRow(skillDataProvider.getRowKey(String.valueOf(0)));
    but it shows some null pointer exception.Can anyone help me?
    Thanks in advance
    Sree

    I think AChervov has the right idea here.
    CachedRowSetDataProvider.canInsertRow(beforeRow) returns false, so you cannot insertRow().
    Therefore, you'll need to control the sort order yourself. I'd add a sort field to the database. Then use TableRowGroup.setSortCrtieria() to control the table display order. Or commit the append to the database immediately and reselect (refresh) the provider (assuming the provider has the desired "order by").

  • Update statement inserts a new row instead of updating

    My code should just update a single specific row in the table. I used a simple procedure to update a record in the current application as well and it runs without any problem except this case. Every time the query runs, it actually inserts a new row instead
    of just updating an existing:
    So here is my c# code:
    try
    command.Parameters.Clear();
    command.Parameters.AddRange(vars);
    command.CommandText = "Update" + tableName;
    conn.Open();
    command.ExecuteNonQuery();
    conn.Close();
    this.GetData(tableName);
    catch
    throw;
    And here is my SQL code (please ingore 'Alter Procedure' statement, I just wanted to get the core script of the procedure):
    ALTER procedure [dbo].[UpdateExpenditureItems]
    (@ID int,
    @Name nvarchar(50),
    @IsGroup bit,
    @Parent nvarchar(50),
    @Description nvarchar(50)
    AS
    Begin
    --a new inserted row seems to be a result of running IF statement rather than ELSE
    if @Parent is not null
    begin
    declare @ParentID int
    set @ParentID = (select ID from ExpenditureItems where Name=@Parent);
    UPDATE ExpenditureItems SET Name =@Name, Parent =@ParentID, [Description] =@Description, IsGroup = @IsGroup WHERE ID=@ID;
    end
    else
    begin
    UPDATE ExpenditureItems SET Name =@Name, [Description] =@Description WHERE ID=@ID
    end
    end
    I ran the query itself from sql management studio and it works fine. The problem seems to be in c# code, but there's nothing unusual. Same code for operations with the databse works fine in other parts of the software... I appreciate your help!
    Thanks in advance!

    Please can you post your full C# code for this function? Also the code you sent is not calling an SP? so why do we need to validate against the SP?
    Fouad Roumieh
    So here is my code:
    //Update is called on OK button click
    private void okBut_Click(object sender, EventArgs e)
    //edit code runs here
    SqlParameter[] pars = new SqlParameter[5];
    pars[0] = new SqlParameter("@ID", int.Parse(idTB.Text));
    pars[0].SqlDbType = SqlDbType.Int;
    pars[1] = new SqlParameter("@Name", itemTB.Text);
    pars[1].SqlDbType = SqlDbType.NVarChar;
    pars[2] = new SqlParameter("@IsGroup", true);
    pars[2].SqlDbType = SqlDbType.Bit;
    pars[3] = new SqlParameter("@Parent", DBNull.Value);
    pars[3].SqlDbType = SqlDbType.Int;
    pars[4] = new SqlParameter("@Description", descTB.Text);
    pars[4].SqlDbType = SqlDbType.NVarChar;
    try
    DAL dal = new DAL();
    dal.UpdateData("ExpenditureItems", pars); //Update is called here
    catch (Exception ex)
    StaticValues.WriteEventLogXML(ex, this.Text);
    switch (StaticValues.user.Language)
    case "English":
    MessageBox.Show("Database error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    break;
    default:
    break;
    finally
    this.DialogResult = System.Windows.Forms.DialogResult.OK;
    StaticValues.currentNode = itemTB.Text;
    public void UpdateData(string tableNameString, SqlParameter[] vars)
    string tableName = tableNameString.Replace(" ", string.Empty);
    try
    command.Parameters.Clear();
    command.Parameters.AddRange(vars);
    command.CommandText = "Update" + tableName;
    conn.Open();
    command.ExecuteNonQuery();
    conn.Close();
    this.GetData(tableName);
    catch
    throw;
    And here is GetData procedure:
    public void GetData(string tableNameString)
    string tableName = tableNameString.Replace(" ", string.Empty);
    command.CommandText = "Get" + tableName;
    command.Parameters.Clear();
    if (!StaticValues.dataSet.Tables.Contains(tableName))
    StaticValues.dataSet.Tables.Add(tableName);
    else
    StaticValues.dataSet.Tables[tableName].Clear();
    try
    adapter.SelectCommand = command;
    conn.ConnectionString = DAL.ConnectionString;
    command.Connection = conn;
    conn.Open();
    adapter.Fill(StaticValues.dataSet.Tables[tableName]);
    conn.Close();
    catch
    throw;
    And this is my complete code for sql procedure:
    USE [ISWM project]
    GO
    /****** Object: StoredProcedure [dbo].[UpdateExpenditureItems] Script Date: 13.04.2015 9:09:36 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER procedure [dbo].[UpdateExpenditureItems]
    (@ID int,
    @Name nvarchar(50),
    @Parent nvarchar(50),
    @Description nvarchar(50),
    @IsGroup bit
    AS
    Begin
    if @Parent IS NOT null
    begin
    declare @ParentID int
    set @ParentID = (select ID from ExpenditureItems where Name=@Parent);
    UPDATE ExpenditureItems SET Name =@Name, Parent =@ParentID, [Description] =@Description, IsGroup = @IsGroup WHERE ID=@ID;
    end
    else
    begin
    UPDATE ExpenditureItems SET Name =@Name, [Description] =@Description WHERE ID=@ID
    end
    end
    The codes posted above work great in other similar parts of the application where select, insert, delete and update is required.
    Concerning my current problem - I ran the procedure itself in SQL Server Management Studio, and it works well. I would say that there's something wrong with my c# code, but it can't be wrong because it's quite simple and works in other place in my application...
    I really don't get what's missing...

  • Generate a surregate key only when insert a new row - (SCD1)

    Hi all,
    I´m starting with OWB (10gR2) and I'm creating a simple template dimension with SDC type 1 with one source, one target and a sequence do generate the surrogate key.
    The main properties configurations are:
    - Target property: Loading type = INSERT/UPDATE.
    - Only match the natural key between source and target.
    - Only use the sequence.nextval when inserting a new row.
    - Mapping: Set based.
    The generated code was something like this:
    {color:#000080}+MERGE INTO DIM_DEFAULT+{color}
    {color:#000080}+USING SCR_TABLE+{color}
    {color:#000080}+ON(SCR_TABLE.NATURALKEY=DIM_DEFAULT.NATURALKEY)+{color}
    {color:#000080}+WHEN MATCHED THEN+{color}
    {color:#000080}+UPDATE SET NAME=SCR_TABLE.NAME+{color}
    {color:#000080}+WHEN NOT MATCHED THEN+{color}
    {color:#000080}+INSERT(SK_DEFAULT,NATURALKEY,NAME)+ {color}
    {color:#000080}+VALUES(SQ_DIM_DEFAULT.NEXTVAL,SCR_TABLE.NATURALKEY,SCR_TABLE.NAME)+{color}
    Ok, it works fine! But the merge statement generates a new SK for each merged row even if the action is update! What I want is a new SK only when the process inserts a new row. Hard-coding, I possible solve this problem creating a function to return the nextval from a sequence and put it on the insert clause like this:
    {color:#000080}+MERGE INTO DIM_DEFAULT+{color}
    {color:#000080}+USING SCR_TABLE+{color}
    {color:#000080}+ON(SCR_TABLE.NATURALKEY=DIM_DEFAULT.NATURALKEY)+{color}
    {color:#000080}+WHEN MATCHED THEN+{color}
    {color:#000080}+UPDATE SET NAME=SCR_TABLE.NAME+{color}
    {color:#000080}+WHEN NOT MATCHED THEN+{color}
    {color:#000080}+INSERT(SK_DEFAULT,NATURALKEY,NAME)+ {color}
    {color:#000080}+VALUES(FN_SQC_NEXTVAL('SQ_DIM_DEFAULT'),SCR_TABLE.NATURALKEY,SCR_TABLE.NAME)+{color}
    Hard-coded it works fine as I need and that´s the point that I want to know:
    It´s possible perform this solution using OWB?
    I tried to use Constants but this solution doesn´t work then I tried an expression calling my sequence.nextval function but the result was:
    {color:#000080}+MERGE INTO DIM_DEFAULT+{color}
    {color:#000080}+USING (SELECT FN_SQC_NEXTVAL('SQ_DIM_DEFAULT') AS SK_DEFAULT_0,NATURALKEY,NAME FROM SCR_TABLE) AS SCR_TABLE+{color}
    {color:#000080}+ON(SCR_TABLE.NATURALKEY=DIM_DEFAULT.NATURALKEY)+{color}
    {color:#000080}+WHEN MATCHED THEN+{color}
    {color:#000080}+UPDATE SET NAME=SCR_TABLE.NAME+{color}
    {color:#000080}+WHEN NOT MATCHED THEN+{color}
    {color:#000080}+INSERT(SK_DEFAULT,NATURALKEY,NAME)+ {color}
    {color:#000080}+VALUES(SK_DEFAULT_0,SCR_TABLE.NATURALKEY,SCR_TABLE.NAME)+{color}
    It´s the same of merge the row using the SEQUENCE.NEXTVAL direct.
    Does anyone have a workaround to solve this situation?

    Hi,
    Perhaps this comes a bit late but...
    Have you tried to change attribute properties in the mapping? For simple example you have a source table in sa-stage which have to fields: code (varchar2(2), natural key) and description (varchar2(50)). You want to map those fields to target table where you have 3 fields: id (NUMBER(10), surrogate id, nextval from sequence when new row inserted), code (as from the source, natural key, the field to determine if the coming row is new or one to be merged) and description as in source table. Fields and datatypes are just for an example.
    When you have source and target tables in your mapping (and fields mapped), drag the sequence operator to the mapping and map the nextval to target table's surrogate id field.
    - Change target table operator properties:
    * loading type = UPDATE/INSERT
    * Match by constraint = no constraint
    - Change target table attribute properties for:
    * surrogate id field: Load column when updating row = no; match column when updating row = no; load column when inserting row = yes
    * natural key field(s): Load column when updating row = no; match column when updating row = yes; load column when inserting row = yes
    * all the regular fields: Load column when updating row = yes; match column when updating row = no; load column when inserting row = yes
    - change the deleting rules as you want them to be
    - Validate your mapping. If the green light is shown, the settings in field properties are suitable for merge.
    Hope this is what you wanted to get. I think this kind of solution works fine. Trigger in the table that holds and where one inserts millions of rows sounds scary...
    Regards,
    jk
    Added text: sorry about false alarm. I think that was what you did. The solution above steals the nextvals from sequence. Perhaps no-native-english-reader should be more careful when reading questions ;-)
    Edited by: jkoski on 5.11.2008 1:30

  • Textarea - space when inserting a new row !!!

    when I insert a new row with the editcurrent record, I get a space in each textarea.
    I don't understand why you write this like:...
    if(obj == null)
    sText = createMultilineTextField(sAttribute , " ");
    else
    The Db now contain a space caracter.
    Jean-Nokl WALLEZ
    [email protected]

    Hi, your code is right. So, replaces your blank space by the character 255 (ALT+255) and the blank space will be shown in your table.
    if(obj == null)
    sText = createMultilineTextField(sAttribute , " ");
    else
    Pakitwo.

  • I'm trying to insert a new row, but not a whole row  on  a spreadsheet, but all i can seem to do is insert a full complete row? iPad Air Wi-Fi

    I'm trying to insert a new row, but not a whole row  on  a  pages app spreadsheet, but all i can seem to do is insert a full complete row?

    What exactly are you trying to do? As I stated in your other thread, there is no such thing as a partial row.

  • Inserting a db row from a form with a value passed in from another page

    We have a report (P1) on a table (T1). P1 has a link column (C), and C is the PK on T1. Clicking on a link (i.e., a row) in report P1, takes us to form (P2). P2 is used to allow the user to insert a new row into T1, with the constraint that one of the columns (X) in T1 must have the same value as X had in the linked row on P1. Also, X is a NOT NULL attribute.
    What we are doing is:
    First, passing C to P2 by setting the link name=P2_X_C and the link value=#C#
    Second, in P2, we are setting form element P2_C via a SQL statement:
    SELECT X
    FROM T1
    WHERE C = :P2_X_C
    P2 displays nicely. We set P2_C to display only, and allow the user to enter values for the other columns. The value displayed for X is not NULL and correctly matches the value from P1. However, when we hit the CREATE button on P2, we get error: ORA-01400: cannot insert NULL into "T1"."X". Unable to process row of table T1.
    APEX seems to have an "issue" with having a value in a form "set" and transmitted to the DB on INSERT.
    Any help would be greatly appreciated.

    Hi,
    1 For "Display Only" items that you are not populating directly from a database column, if you want to save the value, you have to ensure that Save Session State is set to Yes and these items are not actually submitted with the page. The same sort of thing would apply to Disabled or Read-Only items as browsers do not submit these items - though these are more tricky to deal.
    2 Passing the PK value is the most common way of identifying which record contains the values you need. Passing other values is also typical - eg, for applying filters for calendars or searches or for setting flags.
    3 For database columns, which should be based on the underlying table's data, you can use the Default Value settings - though be aware that these values do not exist in session state until the page is submitted. That's ok if you don't need to use the value anywhere else on your page
    Andy

Maybe you are looking for

  • Jquery scrollTop not working correctly?

    Hi, I am trying to get a scroll function to work without 100% luck. I have a a few links that are position:fixed on my side for easy nav to a particular section. I want it to work so when user clicks it the page with auto scroll to the particular div

  • Facing problem in sales order

    Hi Friends, While selling trading goods, the requirement type is coming as 011 in sales order.And schedule line as CP. But if  I want to requirement type as 011 and schedule line as CN. Kindlty guide me Thanks in advance Shailesh

  • Permissions all_tab_columns

    Hello to everybody, I've got a small problem. I have got a function which compairs the tables and colums of two schemas of the same data base. this function is defined in one of the two schemas. The function has two querys : select count(*) from all_

  • Itunes 10 error after updating

    Recently i decided to update to the new itunes 10 and upon that the new GUI is lovely and sweet but when i try burning my new CD's I have this error problem of the music data not being on the disk. I tried a few times and the update just is corrupted

  • Using Attribute views in Script based Calculation views

    I am trying to create a view for analysis on a fact table which has measure name as a dimension as opposed to having multiple measures. Here is an example of what the data looks like. #Customer, Product, Measure, Data Customer1, Product1, ASP, 4.2 Cu