Insert multiple rows into table
Hi,
I want to insert into multiple rows into a table,say 1m rows.
Can somebody help me out...
Thanks
rp0428 wrote:
>
ALTER TABLE t1 NOLOGGING;
insert /*+ append */ into t1 select col1, col2, col3 from source_table;
alter table test_table logging;
>
It's usually standard practice that if you set a table (e.g. 't1' in your example) to NOLOGGING then you should set the same table back to LOGGING after the insert. Setting table 'test_table' to LOGGING isn't really what you intended is it? ;)Ohh yes, It was a Typo. I am so accustomed to Test_table on OTN that I forgot, I had actually used the table T1 in demonstration.
I meant as below
ALTER TABLE t1 NOLOGGING;
insert /*+ append */ into t1 select col1, col2, col3 from source_table;
alter table t1 logging;Thanks for correcting me :)
Similar Messages
-
Inserting Multiple Rows into Database Table using JDBC Adapter - Efficiency
I need to insert multiple rows into a database table using the JDBC adapter (receiver).
I understand the traditional way of repeating the statement multiple times, each having its <access> element. However, I am just wondering whether this might be performance-inefficient, as it might insert records one by one.
Is there a way to ensure that the records are inserted into the table as a block, rather than record-by-record?Hi Bhavesh/Kanwaljit,
If we have multiple ACCESS tags then what happens is that the connection to the database is made only once. But the data is inserted row by row.
Why i am saying this?
If we add the following in JDBC Adapter..logSQLStatement = true. Then incase of multiple inserts we can see that there are multiple
<i>Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','1000')
Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','2000')</i>
Doesnt this mean that rows are inserted one by one?
Correct me if i am wrong.
This does not mean that the transaction is not guaranted. Either all the rows will be inserted or rolled back.
Regards,
Sumit -
Inserting multiple rows into a table (using sequences)
Hi!
I want to insert multiple rows into a db table, but I don't know how.
I know how to insert 1 row using a sequence:
I put all the fields in the jsp form's page and in the submit page I put something like this:
<jbo:Row id="myRow" datasource="ds" action="Update" rowkeyparam="MyRowKey" >
<jbo:SetAttribute dataitem="*" />
</jbo:Row>
But how can I insert multiple rows like this:
Id Name
1 ana
2 monteiro
3 maria
Thanks!Hi Chris,
I think this should give you what you need: Working with a Multiple Select List Item
--Jennifer -
Insert multiple rows into a same table from a single record
Hi All,
I need to insert multiple rows into a same table from a single record. Here is what I am trying to do and I need your expertise. I am using Oracle 11g
DataFile
1,"1001,2001,3001,4001"
2,"1002,2002,3002,4002"
The data needs to be loaded as
Field1 Field2
1 1001
1 2001
1 3001
1 4001
2 1002
2 2002
2 3002
2 4002
ThanksYou could use SQL*Loader to load the data into a staging table with a varray column, then use a SQL insert statement to distribute it to the destination table, as demonstrated below.
SCOTT@orcl> host type test.dat
1,"1001,2001,3001,4001"
2,"1002,2002,3002,4002"
SCOTT@orcl> host type test.ctl
load data
infile test.dat
into table staging
fields terminated by ','
( field1
, numbers varray enclosed by '"' and '"' (x))
SCOTT@orcl> create table staging
2 (field1 number,
3 numbers sys.odcinumberlist)
4 /
Table created.
SCOTT@orcl> host sqlldr scott/tiger control=test.ctl log=test.log
SQL*Loader: Release 11.2.0.1.0 - Production on Wed Dec 18 21:48:09 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 2
SCOTT@orcl> column numbers format a60
SCOTT@orcl> select * from staging
2 /
FIELD1 NUMBERS
1 ODCINUMBERLIST(1001, 2001, 3001, 4001)
2 ODCINUMBERLIST(1002, 2002, 3002, 4002)
2 rows selected.
SCOTT@orcl> create table destination
2 (field1 number,
3 field2 number)
4 /
Table created.
SCOTT@orcl> insert into destination
2 select s.field1, t.column_value
3 from staging s, table (s.numbers) t
4 /
8 rows created.
SCOTT@orcl> select * from destination
2 /
FIELD1 FIELD2
1 1001
1 2001
1 3001
1 4001
2 1002
2 2002
2 3002
2 4002
8 rows selected. -
Inserting multiples rows into a table using function or procedure..
How do i insert multiples rows into a table using function or procedure?
Please provide me query..Use FORALL bulk insert statement...
eg:
procedure generate_test_data as
type cl_itab is table of integer index by pls_integer;
v_cl_itab cl_itab;
type cl_vtab is table of varchar2(25) index by pls_integer;
v_cl_vtab cl_vtab;
type cl_dtab is table of date index by pls_integer;
v_cl_dtab cl_dtab;
begin
for i in 1.. 100 loop
v_cl_itab(i):= dbms_random.value(1,1000);
v_cl_vtab (i):=dbms_random.string('a',20);
v_cl_dtab (i):=to_date(trunc(dbms_random.value(2453737, 2454101)),'j');
end loop;
forall i in v_cl_itab.first .. v_cl_itab.last
execute immediate 'insert into test_order values( :n, :str , :dt ) ' using v_cl_itab(i), v_cl_vtab (i), v_cl_dtab (i);
commit;
end; -
Inserting Multiple Rows into a Table
I am having problems insert multiple rows. I am using Table1.Row1.instanceManger.addInstance(1).
I try adding another line using
Table1.Row2.Cell2.value.#text= "TEST"
and I get an error acessor is unknown. I assume this is an index issue. Can someone tell me if I am doing this wrong and discuss table indexes?The first thing I notice is that your variable, "num," isn't initialized in the FOR loop like I'm used to seeing.. The next thing I would try would be declaring my variables outside of the loop. Something like this maybe.
String query = null;
Statement stmt = null;
int rowsUpdated = 0;
for (int num = 0; num < 10; num++); {
query = "INSERT into apartment (apartmentID,blockID) VALUES ('"+num+"','"+aid+"')";
stmt = con.createStatement();
rowsUpdated += stmt.executeUpdate(query);
}Let me know how it goes.
-Aaron
http://www.WeKnowErrors.com/ A free Wiki for error codes and computer problems. -
Inserting multiple rows into a table using a multiple-select list
I'm trying to figure out how to take the output of a multiple-select list (":" separated list of values) and use that to update a table by inserting multiple rows based on the values. Is there a straight-forward way to do that in APEX?
Thanks.
ChrisHi Chris,
I think this should give you what you need: Working with a Multiple Select List Item
--Jennifer -
Insert Multiple rows into the table from that table data
Hi All,
I have a requirement like to insert mulitple rows into the table from that table data only(I need to replicate the data).
In this table primary key is composite primary key with all foreign keys.primary key also including the Date foreign key.I need to change that date at the of insertion.
INSERT
INTO myschema.Fact_page_performance
time_sk ,
batch_id ,
delta_msec ,
delta_user_msec,
error_code_sk ,
content_errs ,
element_count ,
page_bytes ,
Available ,
date_sk
VALUES
(SELECT time_sk ,
batch_id ,
delta_msec ,
delta_user_msec,
error_code_sk ,
content_errs ,
element_count ,
page_bytes ,
Available
FROM myschema.FACT_PAGE_PERFORMANCE_BACKUP
WHERE date_sk=20090509,20090510
But it is giving the error like missing Expression.
Could anyone please help to me.
Thanks and Regards
Swetha.You can have either VALUES or SELECT not both
INSERT
INTO myschema.Fact_page_performance
time_sk ,
batch_id ,
delta_msec ,
delta_user_msec,
error_code_sk ,
content_errs ,
element_count ,
page_bytes ,
Available ,
date_sk
SELECT time_sk ,
batch_id ,
delta_msec ,
delta_user_msec,
error_code_sk ,
content_errs ,
element_count ,
page_bytes ,
Available
FROM myschema.FACT_PAGE_PERFORMANCE_BACKUP
WHERE date_sk=20090509,20090510; -
Want to insert multiple rows in table using EO
Hi,
I have one requirement where I need to insert multiple rows at once in table lets say Previous Employers.
What I am trying to do is I have created few textinputboxes and getting there values and putting in HashMap.
And manually inserting the rows to EO. I am not getting any error but the data is not populating in Table.
here is the code snap ...please suggest!!
public void updateKoelHrPreEmpVO(HashMap map)
OADBTransaction txn = getOADBTransaction();
//HashMap map = new HashMap();
KoelHrPreEmpVOImpl empVO = getKoelHrPreEmpVO1();
KoelHrPreEmpVORowImpl fetchedRow = null;
int fetchedRowCount = empVO.getFetchedRowCount();
RowSetIterator deleteIter = empVO.createRowSetIterator("deleteIter");
if (fetchedRowCount > 0)
if(txn.isLoggingEnabled(2))
txn.writeDiagnostics(this,"Removing rows from KoelHrPreEmpVO :: Current count :: " + fetchedRowCount ,2);
//System.out.println("Removing rows from KoelHrPreEmpVO :: Current count :: " +fetchedRowCount);
deleteIter.setRangeStart(0);
deleteIter.setRangeSize(fetchedRowCount-1);
for (int i = 0; i < fetchedRowCount; i++)
//System.out.println("Removing Row :: "+i);
if(txn.isLoggingEnabled(2))
txn.writeDiagnostics(this,"Removing row :: " + i ,2);
fetchedRow = (KoelHrPreEmpVORowImpl)deleteIter.getRowAtRangeIndex(i);
fetchedRow.remove();
getTransaction().commit();
deleteIter.closeRowSetIterator();
if(empVO.getRowCount() == 0) {
Row row = null;
KoelHrPreEmpVORowImpl insertRow = null;
empVO.first();
if(txn.isLoggingEnabled(2))
txn.writeDiagnostics(this,"Inserting rows to KoelHrPreEmpVO :: " ,2);
try
for(int i=1; i<=4; i++) {
insertRow = (KoelHrPreEmpVORowImpl)empVO.createRow();
insertRow.setEmployeeNumber(map.get("EmployeeNumber").toString());
insertRow.setPersonId(new Number(map.get("PersonId").toString()));
insertRow.setEmployer(map.get("Employer"+i+"").toString());
insertRow.setStartDate(Date.toDate(map.get("StartDate"+i+"").toString()));
insertRow.setEndDate(Date.toDate(map.get("EndDate"+i+"").toString()));
insertRow.setEmployer(map.get("Designation"+i+"").toString());
empVO.insertRow(insertRow);
insertRow.setNewRowState(Row.STATUS_INITIALIZED);
getTransaction().commit();
catch(SQLException ex)
ex.printStackTrace();
Regards,
Mukesh1. Pls check if the create() methos in EOImpl is in place, setting the primary key.
2. Even though we insert values in this fashion , it only gets inserted if user performs any action, like manipulates some column. Pls check if there is any mechansm to make the row dirty ( as if done by user).
Srikanth -
Insert multiple rows into dB from one dynamic HTML form problem
Hi,
- I have form which has dynamically generated text fields so I don't want to hard code the field names into the servlet
- A user will fill in one or more of the text boxes with a number and submit to the servlet (the name of the field represents an item ID, the value represents a quantity the user wants of that item).
- The servlet needs to insert a new record into a table for each field that is not null.
My question is how!
If I send as an array or string, how will the servlet know that each submitted field needs to be inserted as a new record as opposed to one long record?
I know I'll need to use a loop of somekind; how will I know how long to loop for if the number of 'not null' fields is not static? I need to get a value for the number of 'not null' fields from the form before the loop starts I think but don't know how...
Also, should I call an SQL procedure that has an insert-loop OR should I have the servlet loop a call to a single insert statement? (am I making sense!?)
Anyway, I've seen many examples where a submitted form updates/inserts one record into a table but never any for multiple records at one time. I'm using a Tomcat/Oracle set up, and I'm "New to Java"...
Many thanks in advance.sorry, but I dont' understand very well what do you want to do!
In any case if you want to retrieve all parameters (and you don't know what they are), you can use a general cosde like this:
Enumeration names= request.getParameterNames();
while(names.hasMoreElements()) {
// in 'name' you store the name of the parameter
String name = (String) names.nextElement();
// in 'value' you store it's value
String value = request.getParameter(name);
remember that ALL parameter values can't be null (if they are void their value is "").
The only case that you can get a null value is when you try to access a non existing parameter (like request.getParameter("pwqjsak"));
I hope this helps! Else try to give me more info about your problem -
Parallely Insert Multiple Rows into an Iterator
Hi,
I'm facing a scenario where I have to enter data into multiple rows of an iterator in parallel, where each row is represented as an af:panelFormLayout on the UI, the number of rows being determined at runtime, by user input. I've got a java-based solution with af:forEach and an ArrayList and a HashMap, but I'm wondering, is there any way to do this only with create operation and EL reference(perhaps directly to the row attributes themselves)?
I'd be really grateful for any guidance. I've been stuck with this for the last week now.
Regards,
DebojitHi,
use an editable table if you can. If you can't then a possible solution is to
- create an editable table
- change af:table to af:iterator
- use panelFormLayout to align entry fields (remove columns)
Frank
Ps.: Note that it wont allow you to create multiple new rows (unless you disable required field validation). However, you can create new rows using the createInsert operation -
Inserting multiple rows into DB via SQL insert or stored procedure?
I have successfully created an application where I select a row in an output table view from a Microsoft Access DB SQL data source, and get an Oracle stored procedure to save the row in a new table in our Oracle DB.
This works like a charm when selecting one single row in the table view. What I really need though is for the procedure to save multiple rows at once.
My table is configured with selection mode = 'multiple', and the data mapping line between the table and my procedure has mapping scope = 'selected data rows'.
So, I am able to select multiple rows but still my procedure only stores one of the values sent. Does anyone know if this is related to my procedure not handling multiple parameter entries or if it's related to how VC outputs data to a procedure?
Here is output from runtime flex log where you see the three values: 3, 11 and 9 that is sent to the procedure's IN parameter 'P_ID'.
<Row OWNAPPS_TESTSQL_HYTTER_P_ID="3"/><Row OWNAPPS_TESTSQL_HYTTER_P_ID="11"/><Row OWNAPPS_TESTSQL_HYTTER_P_ID="9"/>
Please help
Henning Strand
I am still very, very interested in hearing if anyone has been successful at passing multiple rows to a stored procedure in one submit action.
Edited by: Henning Strand on Apr 11, 2008 1:58 PMUpdate for all you happy people using Oracle stored procedures with Visual Composer:
When trying to run a simple procedure that accepts arrays as input parameters, the JDBC connector returns an error message saying: 'PLS-00306: wrong number or types of arguments in call ...'
I registered this as a customer message with sap support and got an answer back saying:
Unfotunately our JDBC connector is still not able to work with SP that contain arrays, this is the reason for the behaviour that you're seeing.
This are the bad news, the good news is that with WebServices we don't have this limitation, so you can achieve the same results by using a WS instead of the Store Procedure.
I have asked if and when using stored procedures with arrays will be supported - waiting for answer.
Henning Strand -
Insert Multiple Rows into a Database
Hi,
I've been working on a project that takes an xml document from JMS queue and inserts the data into db. But the problem here is that there can be any number of data sets. I've been using OEPE for my task, but no matter what I do, the data simply isn't inserted. Could any body please help me? Here is a sample message that I'm trying to insert, as well as the XSDs for the JCA and the input documents.
XSD for JMS Message:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.org"
targetNamespace="http://www.example.org"
elementFormDefault="qualified">
<xsd:element name="cannonical">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="orders">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="data" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="rowCode" type="xsd:string"/>
<xsd:element name="productNumber" type="xsd:string"/>
<xsd:element name="attributeType" type="xsd:string"/>
<xsd:element name="attributeCode" type="xsd:string"/>
<xsd:element name="transactionType" type="xsd:string"/>
<xsd:element name="timestamp" type="xsd:dateTime"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
JCA XSD:
<?xml version = '1.0' encoding = 'UTF-8'?>
<xs:schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/top/InsertData" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/top/InsertData" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="OrderDataCollection" type="OrderDataCollection"/>
<xs:complexType name="OrderDataCollection">
<xs:sequence>
<xs:element name="OrderData" type="OrderData" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="OrderData">
<xs:sequence>
<xs:element name="prodnum" type="xs:decimal"/>
<xs:element name="attrtype" minOccurs="0" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="attrcode" minOccurs="0" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="transtype" minOccurs="0" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="ordertime" type="xs:dateTime" minOccurs="0" nillable="true"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Sample Input:
<?xml version="1.0" encoding="windows-1252"?>
<ProductData>
<header>
<rowCode>H</rowCode>
<interfaceCode>H6D9J7</interfaceCode>
<createdOn>
<date>
<year>2011</year>
<month>05</month>
<day>23</day>
</date>
<time>
<hour>02</hour>
<minute>05</minute>
<seconds>11</seconds>
</time>
</createdOn>
<description>Front Shop Item Attributes from FMS to JDA PMM</description>
</header>
<body>
<data>
<rowCode>D</rowCode>
<productNumber>0004567</productNumber>
<attributeType>TTTTTT</attributeType>
<attributeCode>CCCCCCCjjj</attributeCode>
<transactionType>A</transactionType>
<timestamp>
<date>
<year>2011</year>
<month>02</month>
<day>19</day>
</date>
<time>
<hour>02</hour>
<minute>05</minute>
<seconds>11</seconds>
</time>
</timestamp>
</data>
<data>
<rowCode>D</rowCode>
<productNumber>0004567</productNumber>
<attributeType>TTTTTT2</attributeType>
<attributeCode>CCCCCCjjj2</attributeCode>
<transactionType>A</transactionType>
<timestamp>
<date>
<year>2011</year>
<month>02</month>
<day>19</day>
</date>
<time>
<hour>02</hour>
<minute>05</minute>
<seconds>11</seconds>
</time>
</timestamp>
</data>
</body>
<footer>
<rowCode>Z</rowCode>
<interfaceCode>H6D9J7</interfaceCode>
<numberOfRows>000000000002</numberOfRows>
</footer>
</ProductData>
I'll be really grateful if anybody can help me out. Thank you.Check below link it may help you out
how to Insert multiple records using single DB Adapter
Thanks
AJ -
Inserting multiple rows into database using c#
Hi,
I have a web form with a customer id and a few checkboxes with different products (productid) and when a user checks the checkbox he must also enter a date for that product.
I need to basically do the following insert into Customer (customerid,productid, purchasedate) values (1,890,18/12/2003)
insert into Customer (customerid,productid, purchasedate) values (1,56,12/12/2004)
For each product checked I need to insert the details into the database with the same customerid.
The database table looks like this:
Customer Table
CustomerId int
ProductId int
PurchaseDate datetime
What is the correct way to do that? Should I change the database table?
ThanksThis has nothing to do with C#. Ask in the SQL forum for your database product for bulk insertion options.
Visual C++ MVP -
Inserting multiple rows into database table
hi
I have a simple jsp/html page like this:
<h1>Enter Comments</h1>
<select name = "g1">
<option>10</option>
<option>20</option>
<option>30</option>
<option>40</option>
<option>50</option>
<option>60</option>
<option>70</option>
<option>80</option>
<option>90</option>
<option>100</option>
</select> <input name = "comment1" type = "text" size = "60"><p>
<select name = "g1">
<option>10</option>
<option>20</option>
<option>30</option>
<option>40</option>
<option>50</option>
<option>60</option>
<option>70</option>
<option>80</option>
<option>90</option>
<option>100</option>
</select> <input name = "comment1" type = "text" size = "60"><p>but when i say : String fruit=request.getParameter("g1");
String fruit=request.getParameter("comment1");
only one gets written into the table. How would I write them both into seperate rows of the table? e.g.
g1 comment1
g1 comment1
thank you all,change the name of the second select and second text element.
You're only getting one because they're named the same, so the second one is overwriting the values of the first.
HTH.
Maybe you are looking for
-
Writing a function to find whether a value is present in a sql query output
Hi gurus, I would like to write a function to which i will pass a value and a sql query as parameters. Now the function needs to execute that sql query and find whether the given value is present in the output list when the query is executed. If it i
-
When i on my Mac pro there is a folder sign with question mark?
sir when i on my Pac Pro there is appear a folder sign with question mark in white screen .what is the problem tell me pls?
-
How export one table along with data from one location to other location
Hi All, I'm new in export/import practice. Can anyone plz tell the steps along with commands to do the following: 1. I want to export a table with data from one location(computer) to other(computer) that are in same network. 2.Also from one user to a
-
Before installing Elements 12 do I need to uninstall previous versions?
Do I need to uninstall Elements 10 before installing Elements 12?
-
J2SE 1.5.02 not working
To whomever may help with my problem: I have been trying to logon to sites and visit many webpages and I get "Click here to get the plugin" message with a light blue puzzle piece above the message. Then I follow that link to the download center, (whi