NOOB: Simple button to insert a new row...

I have a two column database table.
It is displayed on an interactive report in two columns.
I want to create a new row via button with the values of "new" "new" in the two fields.
I was thinking this should be pretty simple however have not found the right example online to how to achieve this.
Thanks
Rob
Edited by: bostonmacosx on Jun 8, 2012 1:40 PM

Normally you would add a "New" button to the IA report and redirect to a form page in which you can add a new record.
So steps are :
1. Create a form on this table so you can add and edit records on this table
2. Create a "New" button on your IA report which redirects to this page.
Regards,
Bas

Similar Messages

  • 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...

  • To insert a new row in a table control without affecting the other rows

    Halo experts,
    I have a Table control TCTRL in a program .
    The lt_tab contains two cols A and B
    In change mode of the transaction Col A is in display mode and Col B is in change mode
    When i press the + button to insert a new blank entry .I need a blank row with both col A and col B input enabled w/o affecting the display of above and below rows of table control
    In PBO module of subscreen 101
    LOOP AT lt_tab  WITH CONTROL tctrl.
    MODULE tctrl_status.
    endloop.
    In the user command of 0101
    i am writn
    When 'INS'.
    INSERT INITIAL LINE INTO itab.
    Inside MODULE tctrl_status.
    IF lt_tab IS INITIAL.
        LOOP AT SCREEN.
          IF screen-name = 'COLA'.
          screen-input = 1.
      ENDIF.
        ENDLOOP.
          MODIFY SCREEN.
    endif.
    but the problem here is still the Col A is in display mode and Col B is in change mode after output
    .Here modify statement is happening but it does not update the TCTRL-COLS-Screen structure for the col A ( which I have set statically while designing the screen ).I dont want to make the entire row in edit mode only the inserted row ( for both Col A and Col B) and the rest shud remain as it is
    Thanks
    Kallu

    hi Naveen
    I have made my tctrl input disabled for both the columsn and
    I have a module before the PBO loop where I set the like
    module set_tctrl_status.
    IF gv_ok_code NE gc_disp.
        LOOP AT tctrl-cols INTO gs_cols.
          IF gs_cols-screen-name = 'ColB'.
            gs_cols-screen-input = 1.
            MODIFY tctrl-cols FROM gs_cols INDEX sy-tabix.
          ENDIF.
        ENDLOOP.
    This is just to set the Col B in edit mode when in change and create status.
    But if i press the INS button for that change i am coding inside the loop endloop of the pBO like
    if itab is initial.
    LOOP AT tctrl-cols INTO gs_cols.
    gs_cols-screen-input = 1.
    MODIFY tctrl-cols FROM gs_cols INDEX sy-tabix.
    endloop.
    But the problems i it is setting the enite rows as input enabled . I want tos et only that row inpur enabled

  • 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

  • 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

  • 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

  • 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").

  • 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)

  • 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.

  • 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 .

  • 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.

  • How to insert a new Row in a table? - Need help

    Hi everyone,
    I'm using JDeveloper 10.1.2, UIX pages and STRUTS.
    This is my situation: When I navigate from page one to page two, I have in my page2 one table and I need to create a new row with some values by default, but I don't want to commit this line except the user decides to complete this line.
    Can anyone help me? This is very important.
    Thanks,
    Atena

    Hi Sascha,
    thanks very much for your replay.
    My project changed and I have another question about this. My page1 has a table (table1) and when I select one line from table1 and press a button, I go to page 2.
    I have an action in the Struts-Config.xml like this in page2 (S2PopUpObstaculos):
    <action path="/S2PopUpObstaculos" type="oracle.jheadstart.controller.strutsadf.action.JhsDataActionSaveObstaculos" className="oracle.jheadstart.controller.strutsadf.action.JhsDataActionMapping" parameter="/WEB-INF/page/S2PopUpObstaculos.uix" name="DataForm">
    <set-property property="modelReference" value="S2AltaSociais2UIModel"/>
    <set-property property="bindParams" value="S2DominiosLevel1Iterator=${data.S2AltaSociais2UIModel.Obstaculo},${data.S2AltaSociais2UIModel.AlsEpsPsId},${data.S2AltaSociais2UIModel.AlsEpsId},${data.S2AltaSociais2UIModel.Obstaculo}"/>
    </action>
    But now, the problem is, if I don't select one Row from table1 and press the button to go to page2, I need to pass diferent parameters to page 2, like this:
    <set-property property="bindParams" value="S2DominiosLevel1Iterator=0,${data.S2AltaSociais2UIModel.AlsEpsPsId},${data.S2AltaSociais2UIModel.AlsEpsId},0"/>
    </action>
    Do you have any ideia how to do this? Can you help me?
    Thanks,
    Atena

Maybe you are looking for