How to insert a set of rows at a time from another table
Hello!
I have a table1 and table 2 - i want to insert a set of rows at a time from table1 to table 2. Then do a COMMIT. Then continue inserting another set of rows and so on.... say i want to insert into table 2 i million records at a time and then do a commit. then continue with the next 1 million and do a commit and so on..until there are no more records in table 1
Any ideas please!!!!!!!!!!
may be this will help
declare
cursor c1
select * from table1
i_counter binary_integer := 1;
begin
for c1_rec in c1
insert into table2
values(c1_rec.,..);
if i_counter = 1000? then
commit;
i_counter = 1;
end if;
i_counter := i_counter+1;
end loop
end;
Similar Messages
-
Insert/select one million rows at a time from source to target table
Hi,
Oracle 10.2.0.4.0
I am trying to insert around 10 million rows into table target from source as follows:
INSERT /*+ APPEND NOLOGGING */ INTO target
SELECT *
FROM source f
WHERE
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.col2 and f.col2 = m.col2);There is a unique index on target table on col1,col2
I was having issues with undo and now I am getting the follwing error with temp space
ORA-01652: unable to extend temp segment by 64 in tablespace TEMPI believce it would be easier if I did bulk insert one million rows at a time and commit.
I appriciate any advice on this please.
Thanks,
Ashok902986 wrote:
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.col2 and f.col2 = m.col2);
I don't know if it has any bearing on the case, but is that WHERE clause on purpose or a typo? Should it be:
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.COL1 and f.col2 = m.col2);Anyway - how much of your data already exists in target compared to source?
Do you have 10 million in source and very few in target, so most of source will be inserted into target?
Or do you have 9 million already in target, so most of source will be filtered away and only few records inserted?
And what is the explain plan for your statement?
INSERT /*+ APPEND NOLOGGING */ INTO target
SELECT *
FROM source f
WHERE
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.col2 and f.col2 = m.col2);As your error has to do with TEMP, your statement might possibly try to do a lot of work in temp to materialize the resultset or parts of it to maybe use in a hash join before inserting.
So perhaps you can work towards an explain plan that allows the database to do the inserts "along the way" rather than calculate the whole thing in temp first.
That probably will go much slower (for example using nested loops for each row to check the exists), but that's a tradeoff - if you can't have sufficient TEMP then you may have to optimize for less usage of that resource at the expense of another resource ;-)
Alternatively ask your DBA to allocate more room in TEMP tablespace. Or have the DBA check if there are other sessions using a lot of TEMP in which case maybe you just have to make sure your session is the only one using lots of TEMP at the time you execute. -
Set Default Value based on Field from another table for a custom object
I'm trying to set the default value on a custom object field to the value of an account field. I have tried the syntax 50 different ways, and just am getting no where. The account field label displays as DBA, the integration tag is ltDBA_ACCT, and it shows up in reporting fx area as Account.Text_22.
The custom object field I'm triying to update is also called DBA, which was originally the "NAME" required field. Does the table name, Account, have to be included? Do I need a function in front of the field?
I have been updating the external ID using the row ID with syntex <ID> (Less than ID greater than) so I know it is possible to set the Default Value, but <DBA>, <ltDBA_ACCT>, "Account"."DBA", and so on just don't not work.
If anyone knows how to enter this I'd really appreciate the help.Ok, so if you want to default a field to the value from another object, you have to use the JoinFieldValue function. I think you understand that, based on your original post, but I want to be sure that you do.
Next, this will only work as a default if the record is created from the object that you wish to join on because a default works at record creation and the ID needs to be available for it to work properly. It will not work if you choose the related object record after the custom object record is created. You could set the value as a post-default, but that does not seem to meet your requirements.
The syntax for the Default Value would be as follows: JoinFieldValue(ref_record_type, foreign_key, field_name).
In your case, ref_record_type is '<Account>', foreign_key is [<AccountId>], and field_name is '<YourFieldName>'. The best way to determine what the field name is would be to create a new workflow for Account and use the Workflow Rule Condition expression builder to pick your field ("DBA") from the list. The value that is returned by the expression builder should be placed in the field_name variable in the JoinFieldValue function (minus the brackets and in single quotes).
Give this a shot and let me know how you do.
Thom -
Insert missing rows from another table
Hi
I need to insert rows from another table if there is gaps in my transaction table. For each ärendenr there should be 5 Id status rows (1-5). Except for the fact that the inserted rows never should have higher IdStatus number then the highest value from
the transaction for each Ärendenr. See my example below that illustrates my transaction table, Stages master and the desired result.
Is there some t sql code that could handle this problem?
Best regards
Arne
So far i have tried to solve this with the code below but it doesnt work.
I have copied the transaction file information to the TempLogTransTimes
and then insert into LogTransTimes
IF OBJECT_ID('dbo.TempLogTransTimes', 'U') IS NOT NULL --Här raderas den tillfälliga tabellen
DROP TABLE dbo.TempLogTransTimes;
SELECT *
INTO TempLogTransTimes
FROM LogTransTimes
DECLARE @TopÄrende INT
WHILE EXISTS(SELECT * FROM TempLogTransTimes)
BEGIN
SET @TopÄrende = (SELECT TOP(1) Ärendenr FROM TempLogTransTimes ORDER BY Ärendenr)
INSERT INTO LogTransTimes(Ärendenr, IdStatus, StatusNamn, SourceId)
SELECT @TopÄrende, SM.IdStatus, SM.StatusNamn, 'Beräkning'
FROM Statusmall SM
FULL JOIN TempLogTransTimes LT ON SM.IdStatus = LT.IdStatus
WHERE LT.IdStatus IS NULL
DELETE TempLogTransTimes WHERE Ärendenr = @TopÄrende
END
Arne OlssonHi Arne Olsson, try this..
DECLARE @Transactions TABLE
Id1 INT,
IdStatus INT,
StatusName VARCHAR(10)
DECLARE @Stages TABLE
IdStatus INT,
StatusName VARCHAR(10)
INSERT INTO @Transactions VALUES(1,1,'AA'), (1,3,'CC'), (1,5,'EE'), (2,1,'AA'), (2,3,'CC')
INSERT INTO @Stages VALUES (1,'AA'), (2,'BB'), (3,'CC'), (4,'DD'), (5,'EE')
;WITH CTE AS(SELECT DISTINCT Id1 FROM @Transactions)
SELECT Id1, IdStatus, StatusName FROM CTE, @Stages
EXCEPT
SELECT Id1, IdStatus, StatusName FROM @Transactions
Please mark as answer, if this has helped you solve the issue.
Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles. -
How to populate a table based on a row selection from another table.
Hi, i just started to use ADF BC and Faces. Could some one help me or point me a solution on the following scenario .
By using a search component , a table is being displayed as a search result. If i select any row in the resulted table , i need to populate an another table at the bottom of the same page from another view. These two tables are related by primary key . May i know how to populate a table based on a row selection from another table. Thanks
ganeshI understand your requirement and the tutorial doesn't talk about Association between the views so that you can create a Master-Detail or in DB parlance, a Parent-Child relationship.
I will assume that we are dealing with two entities here: Department and Employees where a particular Department has many Employees and hence a Parent-Child relationship.
Firstly, you need to create an Association between the two Entities - Department and Employees. You can do that by right clicking on the model's entity and then associating the two entities with the appropriate key say, DepartmentId.
Once you have done that, you need to link the two entities in the View section with this Association that you created. Then go to AppModule and make sure that in the Available View Objects: 'EmployeesView' appears under 'DepartmentView' as "EmployeesView via <link you created>". Shuttle the 'DepartmentView' to the right, Data Model and then shuttle
"EmployeesView via <link you created>" to the right, Data Model under 'DepartmentView'.
This will then be reflected in your Data Controls. After that, you simply would have to drag this View into your page as a Master-Detail form...and then when you run this page, any row selected in the Master table, would display the data in the Detail table.
Also, refer to this link: [Master-Detail|http://baigsorcl.blogspot.com/2010/03/creating-master-detail-form-in-adf.html]
Hope this helps. -
INSERTING INTO A TABLE FROM ANOTHER TABLE
Hi,
I am having a table called emp in which 5 columns are there, I want to insert some rows from another table called employees, only into three columns of emp table through a sub query.
Is this scenario is possible, I tried so many queries but it is not working out.
Can any body help me out.
The columns in emp table is
empno, ename, doj, designation, salary, deptno, mgrid
The columns in employees table is
empno, name, hiredate, post, salary, commission, deptno, mgr
I want to insert into empno, ename, doj, designation columns of emp table from the employees table empno, name, hiredate, post columns.
Ramesh.It looks like your EMP table has 7 columns, not 5, and you want to insert into 4 columns, not 3.
insert into emp
(empno, ename, doj, designation)
select empno, name, hiredate, post
from employees; -
My Wife got an iPhone at work. IT set it up the first time on another machine, they finally install iTunes on her machine but I don't know if she can sync without loosing Photos, SMS, and other things. She had six months of stuff on that phone?
The problem is she can't update to new software until she connect to iTunes, but she don't want to loose all that info.
My question is:
If she register her apple ID on that new computer, and sync the phone, will she loose everything? or iTunes will back up first (because apple id match) and then sync.
Otherwise, how can I do it? The closest apple store is 3 hours away. thanks!Before you connect to a new PC, make sure that autosync is disabled in Edit/Preferences/Devices, otherwise her phone will be wiped during the following sync.
If she has data on the phone she wants to save, back up manually:
Disable autosync in iTunes, connect your phone to her new computer and right click on it in the device list and choose backup. iTunes will backup your phone without syncing. Transfer the purchases the same way, choosing "transfer purchases" this time.
When you connect your phone for the first time, all media content will be erased. But you can restore your settings and app data from your manual backup afterwards.
Don't forget to set up at least one contact and event on your new computer to be able to merge calendars and contacts when you sync the phone for the first time.
About backups and what's saved:http://support.apple.com/kb/HT1766
How to back up and restore:http://support.apple.com/kb/HT1414
How to download apps for free again:http://support.apple.com/kb/HT2519
Transferring data is also covered here: http://support.apple.com/kb/HT4137 -
I would like to share a tip about how to play a playlist one song at a time from iTunes on a computer. The tip I am sharing is simple, but I was not able to find it in the iTunes Help. After searching on the internet I found the idea for this solution in a discussion in which this was presented as a frustrating problem rather than a desired behavior. This tip relies on the checkbox for each song in iTunes. For a song in a playlist to play automatically, the checkbox must be checked. To keep a song from playing in a playlist, simply uncheck it. Therefore, to keep all songs from playing automatically in a playlist, simply uncheck them all. Now you have a list of desired songs in a desired order but none of them will play automatically. You can play each one when you want to play it without having to search for the next song and without having to be at the computer to stop the playing after each song.
Step by step:
1. Create the playlist.
2. Uncheck all of the check boxes in the playlist (In iTunes for Windows, ctrl click one of the check marks to uncheck all of the checkboxes at once)
3. Now double click (or select and press spacebar) a song to play it. It will stop when finished because there is no other song checked to be played next.
4. If you want to change back to normal sequential play, ctrl click one of the check marks again to change all of the checkboxes back to the checked status.
Based on some discussions I found while looking for a solution (including at least one in which the questioner got bashed about why anybody would ever want to do such a thing and in which the proposed solutions were things like creating one song playlists or simply press stop after each song), some may not understand why this would ever be desired. Here's why I wanted to do it:
I was responsible for playing a series of songs at a dance. I needed to stop after each song to have a transition time to allow me to introduce the next song and to give new dancers time to get onto the floor and other dancers an opportunity to leave the floor. Furthermore, I was also dancing and didn't want to have to spend time searching for the next song (which is why I wanted to create a playlist in advance with just the songs I wanted to play in the order I wanted to play them) and I wanted each song to stop after playing since I was not at the computer to press stop.
I hope this will help others who have a similar need.Thank you! I put some self help hypnosis tracks to listen to on my iPod. I did not want to go to the next track automatically, I wanted to listen to them individually, one at a time. (If I fell asleep, I did not want to 'wake up' in the middle of a different track.) Your information helps me understand that I need to re-load this playlist onto my iPod from my Mac computer, only first, I need to UNCHECK the boxes in front of each track so the iPod will STOP each time after playing the selected track. It is too bad that so many functions are not availabvle within the iPod, but that is probably why they can make it so compact.
-
How to use for all entires clause while fetching data from archived tables
How to use for all entires clause while fetching data from archived tables using the FM
/PBS/SELECT_INTO_TABLE' .
I need to fetch data from an Archived table for all the entries in an internal table.
Kindly provide some inputs for the same.
thanks n Regards
RameshHi Ramesh,
I have a query regarding accessing archived data through PBS.
I have archived SAP FI data ( Object FI_DOCUMNT) using SAP standard process through TCODE : SARA.
Now please tell me can I acees this archived data through the PBS add on FM : '/PBS/SELECT_INTO_TABLE'.
Do I need to do something else to access data archived through SAP standard process ot not ? If yes, then please tell me as I am not able to get the data using the above FM.
The call to the above FM is as follows :
CALL FUNCTION '/PBS/SELECT_INTO_TABLE'
EXPORTING
archiv = 'CFI'
OPTION = ''
tabname = 'BKPF'
SCHL1_NAME = 'BELNR'
SCHL1_VON = belnr-low
SCHL1_BIS = belnr-low
SCHL2_NAME = 'GJAHR'
SCHL2_VON = GJAHR-LOW
SCHL2_BIS = GJAHR-LOW
SCHL3_NAME = 'BUKRS'
SCHL3_VON = bukrs-low
SCHL3_BIS = bukrs-low
SCHL4_NAME =
SCHL4_VON =
SCHL4_BIS =
CLR_ITAB = 'X'
MAX_ZAHL =
tables
i_tabelle = t_bkpf
SCHL1_IN =
SCHL2_IN =
SCHL3_IN =
SCHL4_IN =
EXCEPTIONS
EOF = 1
OTHERS = 2
OTHERS = 3
It gives me the following error :
Index for table not supported ! BKPF BELNR.
Please help ASAP.
Thnaks and Regards
Gurpreet Singh -
HT204053 can i set up iCloud for my laptop from another device
I have had my laptop stolen and havent set up icloud on it. Is there a way of using another device to set up icloud on my laptop from another device so I can search for it.
No, unfortunately you cannot set up iCloud on a device from another device.
-
Hi ,
I have a table with 20 records and 10 columns.I want to add columns from another table with out cross join.As others have said, you need to have some sort of join condition otherwise it is a cross join.
SQL> ed
Wrote file afiedt.buf
1 with T1 as (select 'e' as c1, 2 as c2 from dual union all
2 select 'd', 3 from dual)
3 ,T2 as (select 'x' as c3, 5 as c4 from dual union all
4 select 'y', 6 from dual union all
5 select 'z', 2 from dual)
6 --
7 select T2.c3, T2.c4, T1.c1, T1.c2
8 FROM (select c1, c2, row_number() over (order by c1) as rn from T1) T1
9 FULL OUTER JOIN
10 (select c3, c4, row_number() over (order by c3) as rn from T2) T2
11* ON (T1.rn = T2.rn)
SQL> /
C C4 C C2
x 5 d 3
y 6 e 2
z 2
SQL>This example assigns a row number to each row within each table and then joins using that row number.
(I've assumed the row number should be generated based on the order of the first column of each table, but you can change that as required).
What is the point of your requirement? -
How can I to control any element of my GUI from another class?
How can I to control any element of my GUI from another class?
For that, you need the external class to have the reference to your element.. If your idea is to change basic properties like width, height etc.. then you can have the constructor of the external class to take the object of the parent of your class as the parameter and modify ..
However, if the properties to be altered/accessed are custom to your element, then you will have to have the class accept an object of your class as the parameter. No other option..
What exactly is your requirement? -
How to Insert more than one record at a time- with fixed set of values in one field
Can someone guide as to how to insert multiple records at a time using ASP VBScript in Dreamweaver CS4 or ADDT.
If someone can guide then the exact problem is given below.
I have a MS access database with one table. The table has three fields. The first field is an autonumber field for ID number.
The second field contains string values- One out of 7 predefined values. One set of records consists of 7 records containing all the seven types of predefined values in fields no 1.
The third field is a numeric field and can contain integers.
I want that the user can enter data for the table using an ASP form in such a way that he enters one set of records at a time in one single screen. This way he will not have to remember that he has /has not entered all the seven set of values for the field no 1.
I am not creating fields with the 7 types of field1value as their names as it will increase the number of fields drastically.
Please help for dreamweaver ASP VBScript.I have successfully inserted seven records in one form submit operation by looping through the command object execute method.
However, the data that is being inserted by the command object is repetition of the first record and the command object is not taking any data from the text boxes for the second record onwards. In this I had used the isert record behavious generated by DW CS4 and modified it to suit my requirement. However, the data inserted in the first row is getting repeated in all the seven rows.
Please help.
Also advise if there are any free dreamweaver server side validation extensions available. -
How to Insert more than one record at a time
How to insert multiple records at a time?
If someone can advise on this, then the actual problem is described below:
I have a MS access database with one table. The table has three fields. The
first field is an autonumber field for ID number.
The second field contains string values- One out of 7 predefined values. One
set of records consists of 7 records containing all the seven types of
predefined values in fields no 1.
The third field is a numeric field and can contain integers.
I want that the user can enter data for the table using an ASP form in such
a way that he enters one set of records at a time in one single screen. This
way he will not have to remember that he has /has not entered all the seven
set of values for the field no 1.
I am not creating fields with the 7 types of field1value as their names as
it will increase the number of fields drastically.
Please help with inserting multiple records at a time.I have successfully inserted seven records in one form submit operation by looping through the command object execute method.
However, the data that is being inserted by the command object is repetition of the first record and the command object is not taking any data from the text boxes for the second record onwards. In this I had used the isert record behavious generated by DW CS4 and modified it to suit my requirement. However, the data inserted in the first row is getting repeated in all the seven rows.
Please help.
Also advise if there are any free dreamweaver server side validation extensions available. -
How to show a row has been "removed" from a table
We maintain rows in a table with a version number which will determine the current set of accounts for a version. I need to be able to show the changes between the versions - when a row was ADDED, REMOVED or there was NO CHANGE. I can work out ADDED and NO_CHANGE without any problem, but I'm not sure how I can determine that a row has been REMOVED when it no longer exists in the next version.
I have provided an example piece of SQL below:
with w_acct1 as
(select 'A1' acct, 0 vers from dual
union all
select 'A2' acct, 0 vers from dual
union all
select 'A3' acct, 0 vers from dual
union all
select 'A1' acct, 1 vers from dual
union all
select 'A2' acct, 1 vers from dual
union all
select 'A1' acct, 2 vers from dual
union all
select 'A4' acct, 2 vers from dual)
select a.*,
nvl(lead(acct) over (partition by acct order by vers desc),'NULL') ld,
case when lead(acct) over (partition by acct order by vers desc) is null then
'ADDED'
when lead(acct) over (partition by acct order by vers desc) = acct then
'NO_CHANGE'
else
'REMOVED'
end add_remove
from w_acct1 a
order by vers,acctWhich gives me the following result:
ACCT VERS LD ADD_REMOVE
A1 0 NULL NEW
A2 0 NULL NEW
A3 0 NULL NEW
A1 1 A1 NO_CHANGE
A2 1 A2 NO_CHANGE
A1 2 A1 NO_CHANGE
A4 2 NULL NEW
The result I want is:
ACCT VERS LD ADD_REMOVE
A1 0 NULL NEW
A2 0 NULL NEW
A3 0 NULL NEW
A1 1 A1 NO_CHANGE
A2 1 A2 NO_CHANGE
A3 1 NULL REMOVED
A1 2 A1 NO_CHANGE
A2 2 NULL REMOVED
A4 2 NULL NEW
Note the REMOVED rows associated with the version even though they don't exist in the dataset for that version number.
Can this be done with analytic functions or some other cool Oracle feature I'm missing?
Regards
RichardYou can't know about a row being removed unless you have a record of that row somewhere, either as a copy of your old data (see example below) or you've recorded the information using delete triggers etc.
SQL> ed
Wrote file afiedt.buf
1 with old_data as (select 1 as id, 'A' as dta from dual union all
2 select 2, 'B' from dual union all
3 select 3, 'C' from dual)
4 ,new_data as (select 1 as id, 'A' as dta from dual union all
5 select 3, 'X' from dual union all
6 select 4, 'Y' from dual)
7 --
8 ,ins_upd as (select * from new_data minus select * from old_data)
9 ,del_upd as (select * from old_data minus select * from new_data)
10 ,upd as (select id from ins_upd intersect select id from del_upd)
11 ,ins as (select id from ins_upd minus select id from upd)
12 ,del as (select id from del_upd minus select id from upd)
13 --
14 select 'Inserted' as action, null as old_id, null as old_dta, new_data.id as new_id, new_data.dta as new_dta
15 from new_data join ins on (ins.id = new_data.id)
16 union all
17 select 'Updated', old_data.id, old_data.dta, new_data.id, new_data.dta
18 from old_data join new_data on (old_data.id = new_data.id)
19 join upd on (upd.id = new_data.id)
20 union all
21 select 'Deleted', old_data.id as old_id, old_data.dta as old_dta, null as new_id, null as new_dta
22 from old_data join del on (del.id = old_data.id)
23 union all
24 select 'No Change' as action, new_data.id as old_id, new_data.dta as old_dta, new_data.id as new_id, new_data.dta as new_dta
25 from new_data where id not in (select id from ins_upd union all
26* select id from del_upd)
SQL> /
ACTION OLD_ID O NEW_ID N
Inserted 4 Y
Updated 3 C 3 X
Deleted 2 B
No Change 1 A 1 A
SQL>
Maybe you are looking for
-
Keyboard/Trackpad not working in BootCamp
I installed Windows XP SP2 on a BootCamp partition, but the keyboard and trackpad on the laptop doesn't work. Only external, USB keyboard/mice work. Any ideas how to get the keyboard and trackpad to work?
-
my brother hooked my phone up to his computer and now it asks me to sign into his apple id when i try to download an app, how do i change it to mine? i have already signed out and back in but it wil not work
-
Cannot scan with HP LaserJet M1005 MFP
I updated to Snow Leopard 10.6.3 yesterday. Big mistake as I cannot now scan with my HP LaserJet M1005 MFP. I have been unable to find a solution here or via Google. Does anyone know if this is possible? I realize this device has never been "Mac frie
-
Graphic card problem maybe? Since when I have changed the hard drive to my macbook pro and I installed all the new softwares, my mac is very slow and the screen gives crazy pictures,could maybe be the graphic card, does anybody have experienced this?
-
Scalability Issues - Too Many Active Sessions?
Hello, I'm having an issue with an application I built for one of the campuses at the college I work at. The application is a queuing system where there are stations for students to check in, admin stations where staff can see these students and "cal