Inserting Multiple Records into two table
I want to insert records from a ADF swing form into two tables. In the first table the primary key is generated by a trigger and then I need to retrieve the primary id generated and then insert multiple records in another table using the primarykey obtained from the first table as foreign key.
How to do this ?
User,
If you're using ADF Business components, have a read on the DBSequence data type. If you have two VO's linked by a view link, and the FK is a DBSequence type, all this happens for you out-of-the-box.
Hope this helps,
john
Similar Messages
-
Insert multiple records into a table(Oracle 9i) from a single PHP statement
How can I insert multiple records into a table(Oracle 9i) from a single PHP statement?
From what all I've found, the statement below would work if I were using MySQL:
insert into scen
(indx,share,expire,pitch,curve,surface,call)
values
(81202, 28, 171, .27, 0, 0, 'C' ),
(81204, 28, 501, .25, 0, 0, 'C' ),
(81203, 17, 35, .222, 0, 0, 'C' ),
(81202, 28, 171, .27, 2, 0, 'C' ),
(81204, 28, 501, .20, 0, 1, 'C' ),
(81203, 28, 135, .22, 1, 0, 'C' )
The amount of records varies into the multiple-dozens. My aim is to utilize the power of Oracle while avoiding the i/o of dozens of single-record inserts.
Thank you,
WillYou could look at the INSERT ALL statement found in the documentation here:
http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_913a.htm#2133161
My personal opinion is that you probably won't see any benefit because under the hood I think Oracle will still be doing single row inserts. I could be wrong though.
The only way to confirm was if you did a test of multiple inserts vs an INSERT ALL, that is if the INSERT ALL met your requirements.
HTH. -
How to insert multiple records into a table?
hi all
i have a table that name is : TiketsItem
now i want to 100 records insert my table
for example : TicketsHeaderRef=52000
Active=False
TicketsItemId=45000 to 45100
how to insert TicketsItemId 45000 to 45100 in my table
thanks all
Name of Allah, Most Gracious, Most Merciful and He created the humanSo, you just want to insert the serialized data into the table, without useDate or WKRef? I'm assuming these values will be updated later?
Try something like this:
DECLARE @TicketsHeader TABLE (TicketsItemID BIGINT, ticketsHeaderRef BIGINT, active BIT, useDate DATETIME, WKRef SMALLINT)
DECLARE @startInt BIGINT = 45000
WHILE @startInt <= 45100
BEGIN
INSERT INTO @TicketsHeader (TicketsItemID, ticketsHeaderRef, active)
VALUES (52000, @startInt, 0)
SET @startInt = @startInt + 1
END
SELECT *
FROM @TicketsHeader
thanks
i edited your codes:
DECLARE @TicketsItem TABLE (TicketsItemID BIGINT, ticketsHeaderRef BIGINT, active BIT, useDate DATETIME, WKRef SMALLINT)
DECLARE @startInt BIGINT = 45000
WHILE @startInt <= 45100
BEGIN
INSERT INTO @TicketsItem (TicketsItemID, ticketsHeaderRef, active)
VALUES (@startInt,52000 , 0)
SET @startInt = @startInt + 1
END
when i execute:
SELECT * FROM TiketsItem
i do not see any records inserted in TiketsItem
how to solve it?
Name of Allah, Most Gracious, Most Merciful and He created the human -
Inserting multiple records into a database from a table
I have a dynamic table with rows upto 10. i am trying to insert all the records in these rows into a database ( msaccess)
table name: Table1 ( in my form )
Database table : movies_comments ( as posted in stefan's forums ).
table columns: username, movieid, comments
i am using the following code.
Database.ExecSQL() function is as posted in stefcamerons forums.
var tlength = xfa.resolveNode("form1.#subform[0].Table1.Row1[*]").length;
xfa.host.messageBox("tlength is :" +tlength);
for ( var i = 1; i <= tlength; i++)
var username = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].user_name").rawValue;
var movieID = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].movie_id").rawValue;
var commentS = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].comment_").rawValue;
Database.ExecSQL("INSERT INTO movie_comments (username, movieId, comment) VALUES ('username','movieID', 'commentS');");
i am trying to insert multiple records using the code above. But i am getting error
GeneralError: Operation failed.
XFAObject.resolveNode:1:XFA:form1[0]:#subform[0]:Button1[0]:click
SOM expression returned list when single result was expected
suggest me an alternate way to insert multiple records from a table into a database.
thank Qfigured it out. I changed the ...OR (alternative names = colname) in the recordset to ...OR (alternative names LIKE %colname%). Works like a charm now- the result of a good night's sleep.
-
Insert multiple records into database through internal table
Hi
please help me how to insert multiple records into database through internal tableHi,
Welcome to SCN.
Press F1 on INSERT statement and you will teh syntax as well the docu for the same. -
Insert multiple records into Oracle using Java
Hi,
Has anyone tried to insert multiple records into an Oracle table from Java? I have my data in a Java collection.Can I send a Java Collection to an Oracle Package as a PL/SQL Table Type? My problem is I dont want to instantiate a CallableStatement object everytime I do an insert. Instead I want to do that only once and then insert multiple records in one operation.
Any suggestions will be appreciated,
Thanks,
AlexHi Mensa,
I went thru the code example in your book in chapter 8 (downloaded it from OTN). It looks like the java code for "public class myPLSQLIndexTab" might be a java stored procedure stored in the oracle database?
Pardon my ignorance because I've never worked on java code in the oracle database itself but how would I call such a program outside the oracle database? For example say I have a batch job that downloads data from a webservice and that batch job is written in java and its sitting on a batch server somewhere on the network. But the java program that inserts data into the database is sitting in the oracle database (also somewhere in the same network). How can the java code sitting on the batch server talk to the java code sitting on the oracle server? Is it the same as calling a pl/sql package using CallableStatement?
Thanks
Alex -
Insert the data into two tables at a time.
Hi ,
i have these two tables
create table [dbo].[test1](
[test1_id] [int] identity(1,1) primary key,
[test2_id] [int] not null
create table [dbo].[test2](
[test2_id] [int] identity(1,1) primary key,
[test1_id] [int] not null
alter table [dbo].[test1]
add constraint [fk_test1_test2_id] foreign key([test2_id])
references [dbo].[test2] ([test2_id])
alter table [dbo].[test2] add constraint [fk_test2_test2_id] foreign key([test1_id])
references [dbo].[test1] ([test1_id])
I want to insert the data into two tables in one insert statement. How can i do this using T-SQL ?
Thanks in advance.You can INSERT into both tables within one Transaction but not in one statement. By the way, you would need to alter your dbo.Test1 table to allow null for first INSERT test2_id column
See sample code below:
CREATE TABLE #test1(test1_ID INT IDENTITY(1,1),test2_id INT NULL)
CREATE TABLE #test2(test2_ID INT IDENTITY(1,1),test1_ID INT)
DECLARE @Test1dentity INT
DECLARE @Test2dentity INT
BEGIN TRAN
-- Insert NULL as test2_ID value is unknown
INSERT INTO #test1(test2_ID)
SELECT NULL;
-- get inserted identity value
SET @Test1dentity = SCOPE_IDENTITY();
INSERT INTO #test2(test1_ID)
SELECT @Test1dentity;
-- get inserted identity value
SET @Test2dentity = SCOPE_IDENTITY();
-- Update test1 table
UPDATE #test1
SET test2_ID = @Test2dentity
WHERE test1_ID = @Test1dentity;
COMMIT
SELECT * FROM #test1;
SELECT * FROM #test2;
-- Drop temp tables
IF OBJECT_ID('tempdb..#test1') IS NOT NULL
BEGIN
DROP TABLE #test1
END
IF OBJECT_ID('tempdb..#test2') IS NOT NULL
BEGIN
DROP TABLE #test2
END
web: www.ronnierahman.com -
Inserting new records into database table at runtime
Hi all ,
How to insert new records into database table at runtime on click update?
Thanks.Hi Sasikala,
Just for your understanding am giving a sample code snippet which you can use to read the contents of your Table UI element & save the data on to your database. Suppose you have a button up on pressing which you want to read the data from your screens table & save on to the database then you can proceed as shown below:
1) Obtain the reference of your context node.
2) Fetch all the data present in your table into an internal table using methods of if_wd_context_node
3) Use your normal ABAP logic to update the database table with the data from your internal table
In my example I have a node by name SFLIGHT_NODE and under this I have the desired attributes from SFLIGHT. Am displaying these in an editable table & the user would press up on a push button after making the necessary changes to the tables data. I would then need to obtain the tables information & save on to the database.
data: node_sflight type ref to if_wd_context_node,
elem_sflight type ref to if_wd_context_element,
lt_elements type WDR_CONTEXT_ELEMENT_SET,
stru_sflight type if_main=>element_sflight_node,
it_flights type if_main=>elements_sflight_node.
" navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
node_sflight_node = wd_context->get_child_node( name = 'SFLIGHT_NODE' ).
lt_elements = node_sflight->get_elements( ).
" Get all the rows from the table for saving on to the database
loop at lt_elements into elem_sflight.
elem_sflight->get_static_attributes( importing static_attributes = stru_sflight ).
append stru_sflight to it_flights.
endloop.
" Finally save the entries on to the database
modify ZSFLIGHT99 from table it_flights.
if sy-subrc eq 0.
endif.
However a word of caution here.... SAP doesn't ever recommend directly modifying the database through an SQL query. You would preferably make use of a BAPI for the same. Try go through Thomas Jung's comments in [here|modify the data base table which is comming dynamiclly;.
Regards,
Uday -
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; -
Can you use ESB to insert multiple records into a Database
We have an XML file that has a Parent/Child relationship.
In situation 1 we have a single parent record in the xml file. We can insert the record into the database successfully.
In situation 2 we have a parent and a an associated child record. By using a filter expression to identify the existence of the child record we can route to the first DB Adapter to insert the parent then to the second DB Adapter to insert the child.
Is this final scenario logical and also possible.
Situation 3 we have multiple child records associated to a single parent. So we would first insert the parent record then insert all the child records.
ThanksI use PL/SQL for this if you are using Oracle.
Have a look at this post, it is for AQ but the concept can be used for PL/SQL
Re: Can I pass a pl/sql table as a parameter from a database adaptor
I will send you an example
cheers
James -
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 -
Insert Multiple Records into Multiple ZTABLEs inside the BAPI
Hi,
I have a requirement to Insert or Update Multiple Records into a ZTABLE inside the BAPI. Is there any special approach inside the BAPI to insert or update ZTABLEs with multiple records. It looks like the simple INSERT Statement is not working. Can you please suggest me a Suitable solution for this req?
Thanks and Regards,
KannanHi,
INSERT ZTABLE FROM TABLE ITAB.
The itab structure should be of the structure ZTABLE..
Same for MODIFY and update.
MODIFY ZTABLE FROM TABLE ITAB..
Thanks,
Naren -
Different methods involved in insertion of records into the table
hi all,
i am using Forms [32 Bit] Version 6.0.8.24.1 (Production)
Oracle Database 10g Release 10.2.0.1.0 - Production
i have parameters like emp_code(optional) and year(mandatory field-four digit year).
Based on the parameter i have to get the details from one table and those records should be inserted into other table along with additions columns(by hardcoding the additional columns).
To acheive this i am planning to get a cursor by selecting the necessay fields from the table passing the parameters in the where clause of the cursor.
by looping through the cursor i will insert the records into the other table.
here the thing is the data is going to be huge (since year is the parameter).
so is my approach leads to the performance issue.
i heard that there are different method of insetions,
can anybody suggest me the better way(peformance wise) other than what i have mentioned (if you are aware of)..
Thanks..This is not really a Forms issue, so you'd better go to the sql and pl/sql forum. Here, this question has been asked many times: how do I insert large volumes of data in a table?
insert into ...
select ....
or CTAS (create table as select ....)
by looping through the cursor i will insert the records into the other table.That is really the worst idea. If you can do it in sql (insert into ... select ...) DON'T do it in pl/sql. -
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 -
Inserting multiple checkboxes into a table cell
Hi all, new to Livecycle so I could use a little advice.
I'm trying to insert multiple checkboxes into a single table cell, but as far as I can tell that seems impossible as one checkbox fills the entire cell. Now how do I go about splitting the table cell into 2 rows so that I can insert both of the checkboxes?
I've also got to add a button to create new rows for the table on click so I don't know if that will factor into the answer.
| Header | Header2 | Header3 |
| | |__________________|
| | | |
I hope this crappy ascii drawing comes out right, but that's what I need to happen.
Thanks!Hi Chris,
I think this should give you what you need: Working with a Multiple Select List Item
--Jennifer
Maybe you are looking for
-
Missing data in few fields when activated data in DSO
Hi, I have loaded data into a DSO. Before activating the DSO i can see the values for Sales Organization, Distribution channel and Division fields. But after activation these values disappear. These values are maintained through CONSTANT in transform
-
Internet sales R/3 -- Web shop creation
Dear friends, I am creating a new web shop in internet sales web shop maintenance portal. Also I have created a product catalog in R/3 & assigned the same in the new web shop. Product catalog is replicated to trex server through ISA_CATALOG_REPLICA
-
How to display field Functional Location Field in Asset Master Data
Dear Experts, I really appreciate for your advices on how to display Functional Location Field in Asset Master data. I have checked the configuration on path IMG:\Financial Accounting->Asset Accounting->Master Data->Screen Layout->Define Screen Layou
-
Cannot add a place even connected to the web
When I want to add a place the sytem tells me that the map cannot be displayed as there is no web connection. My web connection works and is active. How to force the system to recognize the connection ? I am using PSE 11 thanks
-
We have been asked to design a third party sales interface for a set of countries. Provider also uses SAP and there are a few prereqs: 1. Goods will be received directly by provider 2. We will have to invoice provider based on their sales 3. A lot of