Multi Row Inserts

Is there any way of providing Multi Row Inserts in a single region.
I am looking for a way to add several records at once in a table format, much like the multi row update functionalty.
Is this possible?

Can you use an OUTPUT clause? See examples
MERGE INTO dbo.Customers AS TGT
USING dbo.CustomersStage AS SRC
  ON TGT.custid = SRC.custid
WHEN MATCHED THEN
  UPDATE SET
    TGT.companyname = SRC.companyname,
    TGT.phone = SRC.phone,
    TGT.address = SRC.address
WHEN NOT MATCHED THEN 
  INSERT (custid, companyname, phone, address)
  VALUES (SRC.custid, SRC.companyname, SRC.phone, SRC.address)
WHEN NOT MATCHED BY SOURCE THEN
  DELETE
OUTPUT 
  $action AS the_action, deleted.custid AS del_custid, inserted.custid AS ins_custid;
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • Multi-row insert in master-detail tables

    Hi, I'm using jdev 10.1.3.2 with jheadstart and my problem is:
    I hava a master-detail structure, both are tables and my goal is that I want multi insert (exactly 3) in master and detail table when user makes new order(some business scenario). I cannot create rows in master or detail VO by overriding create() method because its entities have complex primary keys and some part of this key is populated by the user with lov. So I set in jhs new rows to 3 and checked multi-row insert allowed but the problem is that overall I can only create rows in master table after I submit form. I want to create row in master table and fill rows in detail table, and after that I want to have opportunity to create second (or even third) row in master table and fill rows in detail table.
    thanks for help.
    Piotr

    See JHS DevGuide: 3.2.1. Review Database Design:
    If you are in the position to create or modify the database design, make sure all
    tables have a non-updateable primary key, preferably consisting of only one
    column. If you have updateable and/or composite primary keys, introduce a
    surrogate primary key by adding an ID column that is automatically populated.
    See section 3.2.4 Generating Primary Key Values for more info. Although ADF
    Business Components can handle composite and updateable primary keys, this
    will cause problems in ADF Faces pages. For example, an ADF Faces table
    manages its rows using the key of the underlying row. If this key changes,
    unexpected behavior can occur in your ADF Faces page. In addition, if you want
    to provide a drop down list on a lookup tables to populate a foreign key, the
    foreign key can only consists of one column, which in turn means the referenced
    table must have a single primary key column.
    Groeten,
    HJH

  • Issues in Table with Multi-Row Insert

    I have created a master detail screens using jheadstart on 2 separate pages, Master in the Form layout and detail in the Table Layout with multi-row insert, update and delete flags ON. Have set the New Rows count = 2.
    Issue 1
    If I try to delete any existing rows, it gives error for new rows saying value is required for the mandatory fields. It should just ignore the new rows if I have not updated any values for any attributes in the those row(As it does for non Master-Detail Table layout). I guess this might be happening because the jheadstart code is setting the foreign key for new rows the detail, but not resetting the status of the rows back to INITIALIZED.
    I also noticed that the create() of underlying EO is getting called for those blank rows when I click on 'Save' button, even if I have not changed any data in those rows.
    Issue 2
    When I try to select the new rows also for deletion, I am getting a '500 Internal Server Error' with following stack trace... This is also happening for normal (non Master-Detail) Table layout.
    java.lang.IllegalStateException: AdfFacesContext was already released or had never been attached.     at oracle.adf.view.faces.context.AdfFacesContext.release(AdfFacesContext.java:342)     at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:253)     at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
    Issue 3
    I have put some validation code in the validate() method in the MyEntityImpl.java class.
    The validate method seems tobe getting called lots of times, in my case 20 times, where the new rows are just 2.
    Environment:
    Jdeveloper 10.1.3, JHeadStart 10.1.3 build 78, Windows XP
    thanks

    Thanks for the reply.
    Issue 1:
    What I have observed that in case of multi-row select enabled tables, the blank rows do not have any data. This is because the EO's create() method is called only when we post the data using 'Save' button. Thus the Foreign Keys are also not setup. This is a correct behavior since create() and FK setups etc should get done only if the user has inputted any value in the new rows and thus intend to insert new data into the table.
    I am able to find the exact cause of this issue. It is happening because in the details table, I have a column which needs tobe shown as checkbox. Since we can only bind checkbox to an Boolean attribute in VO, I have created a transient attribute of type Boolean, which basically calls the getter/setter of actual attribute doing the String "Y"/"N" to true/false conversion. Here is code for the transient attribute getter/setter
    public Boolean getDisplayOnWebBoolean() {
    return "Y".equals(getDisplayOnWeb()) ? Boolean.TRUE : Boolean.FALSE;
    public void setDisplayOnWebBoolean(Boolean value) {
    if(Boolean.TRUE.equals(value))
    setDisplayOnWeb("Y");
    else
    setDisplayOnWeb("N");
    Now when I click on the "Save" button, the setter for the boolean field is getting called with the value = false and this is resulting into the row being maked as dirty and thus the validation for the required attributes is getting executed and failing.
    Issue 2:
    Confirmed that correct filter-mapping entries are present in the web.xml.
    Now when I select the new blank rows for deletion and click save, following exception is thrown:
    java.lang.ClassCastException: oracle.jheadstart.controller.jsf.bean.NewTableRowBean at oracle.jheadstart.controller.jsf.bean.JhsCollectionModel.getRowsToRemove(JhsCollectionModel.java:412) at oracle.jheadstart.controller.jsf.bean.JhsCollectionModel.doModelUpdate(JhsCollectionModel.java:604) at oracle.jheadstart.controller.jsf.lifecycle.JhsPageLifecycle.processModelUpdaters(JhsPageLifecycle.java:541) at oracle.jheadstart.controller.jsf.lifecycle.JhsPageLifecycle.validateModelUpdates(JhsPageLifecycle.java:571)
    thanks - rutwik

  • Master-Detail Multi-Row Insert

    Im still using Oracle forms 6i. How do we create here in ADF for the transaction in master-detail operation specially in inserting multi-row in detail. In forms we can use key-next item trigger next_record for new record transaction for drugs or we can use bar code scanning to insert new records & automatically go to next records waiting for another input...
    pls help me i want to upgrade & pls sorry for my english...
    just want this adf behave like forms in terms of master-detail transaction entry...
    i appreciate if someone can help me or give me demo file to download & play with it...
    Edited by: user8983555 on Nov 10, 2010 10:30 AM

    tnx for the fast reply..
    im new with jdeveloper and no knowledge in java or html. im concentrated in pl/sql , forms 6i.We still using this until now in character base in unix environment but some module in gui mode.im working in hospital which is complete informations sytem (stock,pharm..etc...gl...) which in bulk transactions specially patients outclinic & inpatients charges.now we have also this reservations system for out clinics thats the reason im like to develop for in a web that a patient can reserve on line and i dont like running our application in different front end (forms 6i &jdeveloper).
    (now currently checking form10g & just set up AS10g which is working.can deploy and connect,LAN). but im very interested in ADF when i see the demo on Oracle website.
    now our company pplanning to change our application to power builder whiich is not good in performance regarding in hadling big databases (slow query,needs burst AS...) thru to the demonstration of the
    apllication vendors.
    im very glad if you can help. can you post a links or demo file to do this as you said....(You can replicate the code in the button in some other event on your page, for example when the value of the last field in the row is changed.
    It all comes down to the question of when you actually want to create a new row, and in that event you call the createInsert method.)
    this is my only problem now to make this master-detail multi-row insert like ora form.
    again sorry for my english...

  • Sqlite multi-row insert

    In php & mysql I am used to being able to do multi row inserts into a table using;
    INSERT INTO table (column1,column2) VALUES (val1,val2),(val3,val4)
    Is there any Sqlite equivalent? I need to populate around 100 rows on first run of a mobile application.
    Thanks,
    Pete

    If what _spoboyle recommends doesn't work in AIR and if you haven't already, look into the SQLConnection.begin() and commit().  It seems at least you can group your SQL transactions.

  • Multi Row Insert

    I have read a few posts that mention a multi-row-insert but I can't find it.
    There is a multi row update and a multi row delete.
    I am using html db 1.6. We will be upgrading after we get this version of our app up and running, but don't want to take time out for the upgrade right now.
    Is multi_row_insert new to Application Express 2.0?
    Thanks,
    Gregory

    No, the multi row insert is not new to 2.0
    The builtin MRU processes handle multi-row updates and multi-row inserts. However, the default Add Rows process that the wizard creates on a tabular form does create only 1 blank row when you click the Add Row button. To increase this, just open the Add Rows process page and change 1 to a different number.

  • Multi row insert with checkboxes and textfield

    i'm trying to build a multi row insert on tabular form.
    i have checkboxed to choose the rows which i want to insert.
    in this row i have to insert a value into the textfield.
    but when i'm looping my checkec checkoxes my prcedure always takes the first textfields in my report.
    what's going wrong?
    select apex_item.checkbox(30,ar_id, 'class="checkThis"') as ar_id
    ,apex_item.display_and_save(31,ar_nr) as ar_nr
    ,ar_name
    ,apex_item.text(32,null) as Menge
    from ar
    FOR i IN 1.. APEX_APPLICATION.G_F30.COUNT LOOP
    insert blabla (st_profil_id, ar_id,menge)
    values(:P5_st_profil_id,APEX_APPLICATION.G_F30(i),APEX_APPLICATION.G_F32(i));
    end loop;

    Hi,
    Please read the following
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_app.htm#CHDGJBAB
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_item.htm#CHDDCHAF , especially the Creating an On-Submit Process.
    Cheers,

  • Multi row insert or Batch execute via OLE DB?

    Hi all,
    This is my first posting and thanks for answering my questions.
    I would like to know if there is a way to do multiple row insert to an oracle table via OLE DB or .NET technology. Currently, we are using the JDBC connection and that technology has a very handy method called: PrepareStatement which allows us to execute a batch of insert in one go.
    However, we have to switch to the OLE DB camp but I could not find the PrepareStatement equivalent method in OLE DB that allows me to execute a batch of command. My understanding is, in OLE DB, I can create a ADO.command object and assign it with an Insert Statement and then assign parameters which are the input values. However, it looks like I have to exeucte the command one at a time instead of adding them into a batch command like what PrepareStatement does.
    I am fairly new to OLE DB. Can you tell me if there is a way to execute a batch of insert command in a more efficient manner? Or is there a way in .NET or ODP.NET or ADO.NET? Either OLE DB or .NET route is good for us.
    Thanks for the input.
    Michael
    P.S. I am using Oracle 10g with OraOLEDB.Oracle as the OLE DB data provider

    Hi,
    See the site http://www.geocities.com/oledbpro/docs/examples/multiprocs.htm I think it is better to use parameterized insert/update statement to complete the work for the fastest speed.
    Yuancai (Charlie) Ye
    See 30 OLEDB samples
    Use of free SocketPro for creating super client and server applications
    www.udaparts.com

  • Multi-Row insert/update/delete not working via db-link

    App. Version: 2.0.0.00.49
    DB: Oracle 9i, not sure about the build
    Problem: Multirow Update/Insert/Delete doesn't work via db-link.
    Error received: ....ORA-1460: unimplemented or unreasonable conversion requested....
    Where: Tabular Form generated via Wizard
    Side note: It's working properly when local table(s) is/are used, it's not working via db-link or view.
    I've encountered this error with single update/insert/delete operations before, but was able to fix it via using temp-variables (v_xyz := :Px_xyz; as the proposed v('Px_xyz') was really slow with my scripts)...but with the automated DML-action I don't see a way to edit it accordingly.
    Workaround found:
    1a) Use local* collection on HTML-DB-Server, then write single row updates/deletes/inserts to the remote DB via DB-Link
    1b) Use local* table on HTML-DB-Server, then write single row updates/deletes/inserts to the remote DB via DB-Link
    * Local = on the same server that HTML-DB is running on...
    So,...to my questions:
    1. Can someone confirm that this is a "known feature" (aka bug)?
    2. Can someone tell me if this "known feature" has been eliminated in the newer version of HTML-DB/APEX (> 2.0.0.00.49)?
    Thanks.
    Ingo

    Hi,
    Do you have a small test case program that demonstrates this? A JDeveloper project showing what exactly is the problem when trying to use the BDB SQL JDBC driver to insert data into the BDB SQL database? What do you mean by "not working", do you get any errors, you do not get errors but you do not see the data in the database etc?
    What are the versions of Java, JDeveloper, ADF and BDB SQL you are using, and on what OS?
    Regards,
    Andrei

  • How can I do a multi-row insert based on a value in a field on my form?

    My Form contains these fields (for the purpose of inserting rows into my 'Ports' table)
    ..Number_of_Ports
    ..Device_Name
    ..Router_Name
    ..Router_Slot_Number
    ..Router_Port_Number
    ..Vlan_Number
    Based on the value entered for 'Number_of_Ports'
    I would like to insert 'X' number of rows into my 'Ports' Table
    with the values which are contained in:
    ..Device_Name
    ..Router_Name
    ..Router_Slot_Number
    ..Router_Port_Number
    ..Vlan_Number
    Can someone help me with this,
    Or should I post this on another forum?
    Thanks in advance- Gary

    Gary,
    You can accomplish this with a PL/SQL process using a FOR LOOP. For the following example, I am going to use fields that would have been generated for Page 1 of an application:
    Begin
    FOR i IN 1..:P1_NUMBER_OF_PORTS LOOP
    INSERT INTO tablename(port_number, device_name, router_name, router_slot_number_vlan_number)
    VALUES(i, :P1_DEVICE_NAME, :P1_ROUTER_NAME, :P1_ROUTER_SLOT_NUMBER, :P1_ROUTER_PORT_NUMBER, :P1_VLAN_NUMBER);
    End Loop;
    End;
    Hope this helps.
    Mike

  • Multi Row Madness: Insert?

    Hey Guys,
    I've been hitting my head against a cobbled wall trying to figure this one out.
    I'm creating a form that needs to support versioning - so instead of ever using an update the form always inserts a copy of the data into the database with an incremented version number.
    Frustratingly enough the form requires a dynamic amount of parts - best editting and represented but a tabular form. But MRU and MRD.... where is Multi-Row Insert?
    I've tried everything i can to load the information and then change the version - but doing this will result in a ORA-20001: Error in MRU as the data in database is different and cannot "update" the row for old records (when i just want it to copy with a new version number).
    The tables work with a header table that had id and version attributes making a combined pk, and the parts table with id and version which references the header table, and a parts_id to uniquely identify itself.
    Is there any suggestions on this issue? I was thinking about adding an extra value and adding a trigger to do the inserting instead - but i fear this approach may change the information in the current version (i'm not that familiar with oracle databases... so prefer to try to find a solution in apex).
    I'm using 2.2.
    cheers,
    Alex

    But MRU and MRD.... where is Multi-Row Insert?
    The MRU process does an update for existing rows and insert for new rows (that were added using the Add Row button)
    I was thinking about adding an extra value and adding a trigger to do the inserting instead
    Yes, a row-level trigger on the underlying table would be the best way to approach this problem. Let the APEX MRU and MRD processes do their job and your row-level trigger can keep inserting rows into a separate audit/history table with structure identical to the main table (plus sequence generated version number).
    Something like
    create table mytable_hist as select 'U' dml_action, 1 version_no,a.* from mytable a where 1=2;
    create or replace trigger mytrig
    after insert or update or delete on mytable
    for each row
    declare
    l_action varchar2(1);
    begin
      if inserting then l_action := 'I';
      elsif updating then l_action := 'U';
      elsif deleting then l_action := 'D';
      end if;
      insert into mytable_hist
      values
      l_action,
      version_no_seq.nextval,
      nvl(:new.col1,:old.col1), 
      nvl(:new.col2,:old.col2), 
      nvl(:new.col3,:old.col3), 
    end;
    /

  • Fill multi row before insert

    hello guys I want to fill a block with multiple rows before inserting the rows data are from 2 blocks in the form I tried to use next_record , down but they are all restricted here an example of what I want to do
    I have block1 , block2 and block3 and I want to fill block3 with the first row of each block before inserting the data in the block3
    what should I do?
    Thanks in advance guys

    But MRU and MRD.... where is Multi-Row Insert?
    The MRU process does an update for existing rows and insert for new rows (that were added using the Add Row button)
    I was thinking about adding an extra value and adding a trigger to do the inserting instead
    Yes, a row-level trigger on the underlying table would be the best way to approach this problem. Let the APEX MRU and MRD processes do their job and your row-level trigger can keep inserting rows into a separate audit/history table with structure identical to the main table (plus sequence generated version number).
    Something like
    create table mytable_hist as select 'U' dml_action, 1 version_no,a.* from mytable a where 1=2;
    create or replace trigger mytrig
    after insert or update or delete on mytable
    for each row
    declare
    l_action varchar2(1);
    begin
      if inserting then l_action := 'I';
      elsif updating then l_action := 'U';
      elsif deleting then l_action := 'D';
      end if;
      insert into mytable_hist
      values
      l_action,
      version_no_seq.nextval,
      nvl(:new.col1,:old.col1), 
      nvl(:new.col2,:old.col2), 
      nvl(:new.col3,:old.col3), 
    end;
    /

  • Multi Row Update

    I have a tabular form for multi row inserts, updates and deletes on one table.
    I have a trigger that inserts the user name and sysdate when a new line is inserted. I am trying to do the same when a line is updated, but all lines are being updated.
    Any pointers
    Gus

    Gus,
    you will need to retrieve the primary key as a hidden field in your tabular form. you then use this promary key in your update triggers where clause to restrict to the current row.

  • Master/Detail in create mode with single row insert

    Hi,
    My jheadstart version is 10.1.3.2.52
    I want to insert master and detail together on same page in create mode.
    I have these settings:
    - Master Layout: Form
    - Detail Layout: Table
    -"Single-Row Insert Allow" (Checked)
    -"Single-Row Update Allow" (Checked)
    -"Single-Row Delete Allow" (Checked)
    -"Multi-Row Insert Allow" (unchecked)
    -"Multi-Row Update Allow" (unchecked)
    -"Multi-Row Delete Allow" (unchecked)
    -"Show Add Row Button" (Checked)
    When I Generate and run Application and click New Button, my detail table don't have any New Button.
    Then I set "New Rows" to 1 for detail table and generate and run again, but problem still there!
    Can you help me?
    Thanks

    Hi,
    Thanks for your reply.
    But I don't want multi-insert row be enabled(because of some logical reasons that forced by my scenario).
    If I enable multi-insert row, even without "new row button" and just set "new row = 1", when user insert first row and click save button, one more empty row automatically add to detail table. I don't want this behavior. I want only one empty row for my detail table in create mode.
    thanks again.

  • ADF Editable Table : CANNOT Insert Multi Rows , Please hellppppssss

    Hi All,
    Our customer requirement is being able to insert Multi Rows in an Editable Table and submit ALL of them with just one Click ?
    Is it Really Possible ?
    I have tried, even I can insert three Empty Rows and Fill them all with values, when I press Submit ONLY one row will be submitted, the other TWO will become BLANK again, is this my code is wrong ?
    Or this is limitation of ADF Editable Table ?
    Here is my codes, I have tried two ways, all same problem :
    (1) public String create_action() {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    bindings.getOperationBinding("Create");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    public String myCreate_action() {
    create_action();
    create_action();
    create_action();
    return null;
    (2) public String createMultiRows() {
    DCBindingContainer dcbc = (DCBindingContainer)getBindings();
    //get iterator binding
    DCIteratorBinding ib = (DCIteratorBinding)dcbc.get("DeptView1Iterator");
    // get viewobject
    ViewObject vo = ib.getViewObject();
    System.out.println(vo.getCurrentRowIndex());
    vo.clearCache();
    int currentRowIndex = vo.getRowCount() -1;
    Row row1 = vo.createRow();
    row1.setNewRowState(Row.STATUS_NEW);
    vo.insertRowAtRangeIndex(++currentRowIndex, row1);
    Row row2 = vo.createRow();
    row2.setNewRowState(Row.STATUS_NEW);
    vo.insertRow(row2);
    Row row3 = vo.createRow();
    row3.setNewRowState(Row.STATUS_NEW);
    vo.insertRow(row3);
    return null;
    Please help... I am stuck ...
    Thank you very much,
    xtanto

    Xtanto,
    Could you try changing
    bindings.getOperationBinding("Create");to
    bindings.getOperationBinding("CreateInsert");in your first example to see if it fixes your problem?
    Regards,
    John

Maybe you are looking for

  • Error while running Business Rules and Calc scripts

    We are trying to run calc script in a report and we received the error saying that " An error occured while running the specified cacl script.Check the log for details", we received the similar error when working with Business rules. This started whe

  • Migrated from Lightroom to Aperture: TIFF's in LAB mode don't work

    I migrated from Lightroom to Aperture and I noticed many TIFF's were black, or strangely colored (reddish, greenish). I couldn't figure it out, but I think I know what is the problem. I used to work in LAB-mode in Photoshop for quite some time, and I

  • Logic board replaced...asking me to reinstall OS X Lion, but stuck on "loading installation information" for 4 hours. What to do?

    I had to have the logic board in my 7 month old iMac replaced due to the fact that my now exboyfriend put a firmware password on my iMac remotely and I couldn't get into my computer. I took it to the Genius Bar and they replaced the logic board so I

  • Need a new external HD

    just purchased a 17' MBpro for field work with FCP. i have an old maxtor one-touch 2 external HD, but want to upgrade. does anyone have any good suggestions for an external HD that i can use as my FCP scratch disk to free up space on my internal driv

  • Delete apps from launchpad

    Cannot remove applications from "launchpad" that can not run on their own ie. must be called from a parent application (Canon: Raw Image Task must be called from Canon Image Browser); not sure how they got int "launchpad" in the first place. Any thou