Loading data into multiple tables using sqlloader
Hi,
I am using sql loader to load the data from flat file into the data base
my file structure is as below
====================
101,john,mobile@@fax@@home@@office@@email,1234@@3425@@1232@@2345@@[email protected],1234.40
102,smith,mobile@@fax@@home,1234@@345@@234,123.40
103,adams,fax@@mobile@@office@@others,1234@@1233@@1234@@3456,2345.40
in file first columns are empno,ename,comm_mode(multiple values terminated by '@@'),comm_no_txt(multiple values terminated by '@@'), sal
the comm_mode and comm_no_text needs to be inserted into the separate table (emp_comm) like below
emp
empno ename sal
101 john 1234.40
102 smith 123.40
103 adams 2345.40
emp_comm
empno comm_mode comm_no_text
101 mobile 1234
101 fax 3425
101 home 1232
101 office 2345
101 email [email protected]
102 mobile 1234
102 fax 345
102 home 234
103 fax 1234
like this needs to insert the data using sql loader
my table structures
===============
emp
empno number(5)
ename varchar2(15)
sal number(10,2)
emp_comm
empno number(5) reference the empno of the emp table
comm_mode varchar2(10)
Comm_no_text varchar2(35)
now i want insert the file data into the specified structues
please help me out to achieve this using sql loader
(we are not using external tables for this)
Thanks & Regards.
Bala Sake
Edited by: 954925 on Aug 25, 2012 12:24 AM
Pl post OS and database details
You will need to split up the datafile in order to load into separate tables. The process is documented
http://docs.oracle.com/cd/E11882_01/server.112/e22490/ldr_control_file.htm#autoId72
HTH
Srini
Similar Messages
-
Unable to load data in to table using sqlloader
Hi,
Oracle Version :10.2.0.1
Operating system:windows Xp
I was unable to load the data in to table from csv file .Can any one please help me .
Here is the output of my log file
SQL*Loader: Release 10.2.0.1.0 - Production on Thu Jun 3 12:43:22 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: ach_staging.ctl
Data File: E:\SQL LOADER\ACH_STAGING.csv
Bad File: E:\SQL LOADER\load_bad.bad
Discard File: E:\SQl LOADER\emp.dsc
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table ACH_STAGING, loaded from every logical record.
Insert option in effect for this table: INSERT
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
ACH_CODE FIRST * , O(") CHARACTER
LOAN_CODE NEXT * , O(") CHARACTER
LOAN_TYPE NEXT * , O(") CHARACTER
TRAN_ID NEXT * , O(") CHARACTER
BO_CODE NEXT * , O(") CHARACTER
BO_NAME NEXT * , O(") CHARACTER
ST_CODE NEXT * , O(") CHARACTER
ACH_TYPE NEXT * , O(") CHARACTER
ACH_EFFECTIVE_DATE NEXT * , O(") CHARACTER
AMT NEXT * , O(") CHARACTER
CHECK_ACCNT_NO NEXT * , O(") CHARACTER
ABA_CODE NEXT * , O(") CHARACTER
ACH_STATUS NEXT * , O(") CHARACTER
TRAN_STATUS NEXT * , O(") CHARACTER
IS_HOLD NEXT * , O(") CHARACTER
IS_CANCELLED NEXT * , O(") CHARACTER
COMMENTS NEXT * , O(") CHARACTER
UPDATED_BY NEXT * , O(") CHARACTER
DATE_UPDATED NEXT * , O(") CHARACTER
CREATED_BY NEXT * , O(") CHARACTER
DATE_CREATED NEXT * , O(") CHARACTER
LOAN_TRAN_CODE NEXT * , O(") CHARACTER
ACH_AUTH NEXT * , O(") CHARACTER
REBATE_AMT NEXT * , O(") CHARACTER
PROMOTION_AMT NEXT * , O(") CHARACTER
TDC_ACH_NO NEXT * , O(") CHARACTER
INST_NUM NEXT * , O(") CHARACTER
DISABLE_ACH NEXT * , O(") CHARACTER
STMT_NO NEXT * , O(") CHARACTER
NEW_LOAN_TRAN_CODE NEXT * , O(") CHARACTER
REVOKED_BY NEXT * , O(") CHARACTER
REVOKED_DATE NEXT * , O(") CHARACTER
CHECK_STATUS NEXT * , O(") CHARACTER
value used for ROWS parameter changed from 64 to 30
Record 1: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 2: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 3: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 4: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 5: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 6: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 7: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 8: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 9: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 10: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 11: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 12: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 13: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 14: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 15: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 16: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 17: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 18: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 19: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 20: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 21: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 22: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 23: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 24: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 25: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 26: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 27: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 28: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 29: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 30: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 31: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 32: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 33: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 34: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 35: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 36: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 37: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 38: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 39: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 40: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 41: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 42: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 43: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 44: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 45: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 46: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 47: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 48: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 49: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 50: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
Record 51: Rejected - Error on table ACH_STAGING, column ACH_EFFECTIVE_DATE.
ORA-01830: date format picture ends before converting entire input string
MAXIMUM ERROR COUNT EXCEEDED - Above statistics reflect partial run.
Table ACH_STAGING:
0 Rows successfully loaded.
51 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 255420 bytes(30 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 60
Total logical records rejected: 51
Total logical records discarded: 0
Run began on Thu Jun 03 12:43:22 2010
Run ended on Thu Jun 03 12:43:23 2010
Elapsed time was: 00:00:00.17
CPU time was: 00:00:00.10
{code}
and the data from the CSV file is
{code}
1767641 7537506 ILP ADV 506703 MICHELLE WHITE -40 CRE 07-NOV-08 01.36.04.000000000 PM 650 INP PRO N N 54564 06-NOV-08 06.06.28.000000000 PM 54562 06-NOV-08 01.36.04.000000000 PM 2060997 PPD 0 0 0 N 1 ACH
1767642 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 01-DEC-08 12.00.00.000000000 AM 76.5 INP PRO N N Updated During EOD PAY : ACH 1 28-NOV-08 09.00.17.000000000 PM 54562 06-NOV-08 01.36.04.000000000 PM 2061201 PPD 0 0 1 N 1 ACH
1767643 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 16-DEC-08 12.00.00.000000000 AM 76.5 INP PRO N N Updated During EOD PAY : ACH 1 15-DEC-08 09.00.16.000000000 PM 54562 06-NOV-08 01.36.04.000000000 PM 2061614 PPD 0 0 2 N 1 ACH
1767644 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 02-JAN-09 12.00.00.000000000 AM 76.5 INP PRO N N Updated During EOD PAY : ACH 1 31-DEC-08 09.00.55.000000000 PM 54562 06-NOV-08 01.36.04.000000000 PM 2063375 PPD 0 0 3 N 1 ACH
1767645 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 16-JAN-09 12.00.00.000000000 AM 76.5 INP PRO N N Updated During EOD PAY : ACH 1 15-JAN-09 09.01.10.000000000 PM 54562 06-NOV-08 01.36.04.000000000 PM 2064023 PPD 0 0 4 N 1 ACH
1767646 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 02-FEB-09 12.00.00.000000000 AM 76.5 INP PRO N N Updated During EOD PAY : ACH 1 30-JAN-09 09.00.22.000000000 PM 54562 06-NOV-08 01.36.04.000000000 PM 2064639 PPD 0 0 5 N 1 ACH
1767647 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 17-FEB-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 6 N 1 ACH
1767648 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 02-MAR-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 7 N 1 ACH
1767649 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 16-MAR-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 8 N 1 ACH
1767650 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 01-APR-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 9 N 1 ACH
1767651 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 16-APR-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 10 N 1 ACH
1767652 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 01-MAY-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 11 N 1 ACH
1767653 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 18-MAY-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 12 N 1 ACH
1767654 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 01-JUN-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 13 N 1 ACH
1767655 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 16-JUN-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 14 N 1 ACH
1767656 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 01-JUL-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 15 N 1 ACH
1767657 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 16-JUL-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 16 N 1 ACH
1767658 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 03-AUG-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 17 N 1 ACH
1767659 7537506 ILP PAY 506703 MICHELLE WHITE -40 DEB 17-AUG-09 12.00.00.000000000 AM 76.5 NOP NOP N Y Cancelled during Payment By -> BUY : ACH 54605 13-FEB-09 09.03.23.000000000 AM 54562 06-NOV-08 01.36.04.000000000 PM 1778544 PPD 0 0 18 N 1 ACH
{CODE}
Thanks & Regards,
Poorna Prasad.Hi,
At last i was able to insert the data into the table but here i am facing another problem i the csv file i am having some null values in the data because of that only few records was inserted and remaining data was not inserted.
Here is the syntax what i am using to insert even null values are present
ACH_EFFECTIVE_DATE "to_timestamp(:ACH_EFFECTIVE_DATE,'DD-MON-RR HH.MI.SSXFF AM')" NULLIF ACH_EFFECTIVE_DATE=BLANKSand the error what i am getting is
E:\SQL LOADER>sqlldr userid=rr/rr control=ach_staging.ctl log=ss1.log
SQL*Loader: Release 10.2.0.1.0 - Production on Fri Jun 4 12:24:32 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL*Loader-350: Syntax error at line 16.
Expecting "," or ")", found keyword nullif.
EFFECTIVE_DATE,'DD-MON-RR HH.MI.SSXFF AM')" NULLIF ACH_EFFECTIVE_DATE=
^
{code}
can any one please help me what is the correct syntax i need to user here .
Thanks & Regards,
Poorna Prasad. -
How to load data into user tables using DIAPIs?
Hi,
I have created an user table using UserTablesMD object.
But I don't have know how to load data into this user table. I guess I have to use UserTable object for that. But I still don't know how to put some data in particular column.
Can somebody please help me with this?
I would appreciate if somebody can share their code in this regard.
Thank you,
SudhaYou can try this code:
Dim lRetCode As Long
Dim userTable As SAPbobsCOM.UserTable
userTable = pCompany.UserTables.Item("My_Table")
'First row in the @My_Table table
userTable.Code = "A1"
userTable.Name = "A.1"
userTable.UserFields.Fields.Item("U_1stF").Value = "First row value"
userTable.Add()
'Second row in the @My_Table table
userTable.Code = "A2"
userTable.Name = "A.2"
userTable.UserFields.Fields.Item("U_1stF").Value = "Second row value"
userTable.Add()
This way I have added 2 lines in my table.
Hope it helps
Trinidad. -
Loading data into multiple tables - Bulk collect or regular Fetch
I have a procedure to load data from one source table into eight different destination tables. The 8 tables have some of the columns of the source table with a common key.
I have run into a couple of problems and have a few questions where I would like to seek advice:
1.) Procedure with and without the BULK COLLECT clause took the same time for 100,000 records. I thought I would see improvement in performance when I include BULK COLLECT with LIMIT.
2.) Updating the Load_Flag in source_table happens only for few records and not all. I had expected all records to be updated
3.) Are there other suggestions to improve the performance? or could you provide links to other posts or articles on the web that will help me improve the code?
Notes:
1.) 8 Destination tables have at least 2 Million records each, have multiple indexes and are accessed by application in Production
2.) There is an initial load of 1 Million rows with a subsequent daily load of 10,000 rows. Daily load will have updates for existing rows (not shown in code structure below)
The structure of the procedure is as follows
Declare
dest_type is table of source_table%ROWTYPE;
dest_tab dest_type ;
iCount NUMBER;
cursor source_cur is select * from source_table FOR UPDATE OF load_flag;
BEGIN
OPEN source_cur;
LOOP
FETCH source_cur -- BULK COLLECT
INTO dest_tab -- LIMIT 1000
EXIT WHEN source_cur%NOTFOUND;
FOR i in dest_tab.FIRST .. dest_tab.LAST LOOP
<Insert into app_tab1 values key, col12, col23, col34 ;>
<Insert into app_tab2 values key, col15, col29, col31 ;>
<Insert into app_tab3 values key, col52, col93, col56 ;>
UPDATE source_table SET load_flag = 'Y' WHERE CURRENT OF source_cur ;
iCount := iCount + 1 ;
IF iCount = 1000 THEN
COMMIT ;
iCount := 0 ;
END IF;
END LOOP;
END LOOP ;
COMMIT ;
END ;
Edited by: user11368240 on Jul 14, 2009 11:08 AMAssuming you are on 10g or later, the PL/SQL compiler generates the bulk fetch for you automatically, so your code is the same as (untested):
DECLARE
iCount NUMBER;
CURSOR source_cur is select * from source_table FOR UPDATE OF load_flag;
BEGIN
OPEN source_cur;
FOR r IN source_cur
LOOP
<Insert into app_tab1 values key, col12, col23, col34 ;>
<Insert into app_tab2 values key, col15, col29, col31 ;>
<Insert into app_tab3 values key, col52, col93, col56 ;>
UPDATE source_table SET load_flag = 'Y' WHERE CURRENT OF source_cur ;
iCount := iCount + 1 ;
IF iCount = 1000 THEN
COMMIT ;
iCount := 0 ;
END IF;
END LOOP;
COMMIT ;
END ;However most of the benefit of bulk fetching would come from using the array with a FORALL expression, which the PL/SQL compiler can't automate for you.
If you are fetching 1000 rows at a time, purely from a code simplification point of view you could lose iCount and the IF...COMMIT...END IF and just commit each time after looping through the 1000-row array.
However I'm not sure how committing every 1000 rows helps restartability, even if your real code has a WHERE clause in the cursor so that it only selects rows with load_flag = 'N' or whatever. If you are worried that it will roll back all your hard work on failure, why not just commit in your exception handler? -
Loading data into multiple tables from an excel
Can we load data in to multiple tables at a time from an excel through Utilities? If yes how? Please help me
Regards,
PallaviI would imagine that the utilities allow you to insert data from a spreadsheet into 1 and only 1 table.
You may have to write your own custom data upload using External Tables and a PL/SQL procedure to insert data from 1 spreadsheet into more than 1 table.
If you need any guidance on doing this let me know and I will happily point you in the right direction.
Regards
Duncan -
Insert data into multiple tables
Hi all,
I've a requirement where i need to insert data into multiple tables using PL/SQL procedure
Procedure should have two parameters
1. Table Name (parameter1)
2. Data (parameter2)
Based on these two parameters i need to insert data into table (parameter1) using data (parameter2)
ex:
Procedure insert_data (p_table IN VARCHAR2
,p_data IN -- what should be the datatype?
IS
l_statement VARCHAR2(2000);
BEGIN
-- insert data into tables
INSERT INTO p_table
values (....);
END insert_data;Thanks in advance!!BEDE wrote:
Amen to that!
So, I believe a better approach would be the following...
Suppose you have N datafiles with the same structure, and you wish to insert into the database the data from all those files.
For that, you should have a single table, named, say incoming_file_data, which should be structured more or less like below:
create table incoming_file_data (
filename varchar2(250) not null -- name of the file inserted from
,file_time timestamp -- timestamp when the data was inserted
,... -- the columns of meaningful data contained in the lines of those files
);And you will insert the data from all those files in this table, having normally one transaction for each file processed, for otherwise, when shit happens, some file may only get to be partially inserted into the table...
Maybe one good approach would be to create dynamically an external table for the file to be loaded, and then execute dynamically insert select into the table I said, so that you will have only one insert select for one file instead of using utl_file... RTM on that.If the file structures are the same, and it's just the filename that's changing, I would have a single external table definition, and use the alter table ... location ... statement (through execute immediate) to change the filename(s) as appropriate before querying the data. Of course that's not scalable if there are multiple users intenting to use this, but generally when we talk about importing multiple files, it's a one-user/one-off/once-a-day type of scenario, so multi-user isn't a consideration. -
Hi,
Iam new to the xml,
can u please anyone help me how to write procedure to load the data into a table using xml as input parameter to a procedure and xml file is as shown below which is input to me.
<?xml version="1.0"?>
<DiseaseCodes>
<Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
</DiseaseCodes>.
Regards,
vikram.here is the your XML parse in 11g :
select *
from xmltable('//Entity' passing xmltype
'<?xml version="1.0"?>
<DiseaseCodes>
<Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
</DiseaseCodes>
') columns
"dcode" varchar2(4000) path '/Entity/dcode',
"ddesc" varchar2(4000) path '/Entity/ddesc',
"reauthflag" varchar2(4000) path '/Entity/reauthflag'
dcode ddesc reauthflag
0 (I87)Other disorders of veins - postphlebitic syndrome 0
0 (J04)Acute laryngitis and tracheitis 0
0 (J17*)Pneumonia in other diseases - whooping cough 0
SQL>
Using this parser you can create procedure as
SQL> create or replace procedure myXMLParse(x clob) as
2 begin
3 insert into MyXmlTable
4 select *
5 from xmltable('//Entity' passing xmltype(x) columns "dcode"
6 varchar2(4000) path '/Entity/dcode',
7 "ddesc" varchar2(4000) path '/Entity/ddesc',
8 "reauthflag" varchar2(4000) path '/Entity/reauthflag');
9 commit;
10 end;
11
12 /
Procedure created
SQL>
SQL>
SQL> exec myXMLParse('<?xml version="1.0"?><DiseaseCodes><Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity></DiseaseCodes>');
PL/SQL procedure successfully completed
SQL> select * from MYXMLTABLE;
dcode ddesc reauthflag
0 (I87)Other disorders of veins - postphlebitic syndrome 0
0 (J04)Acute laryngitis and tracheitis 0
0 (J17*)Pneumonia in other diseases - whooping cough 0
SQL>
SQL>
Ramin Hashimzade -
How to insert one table data into multiple tables by using procedure?
How to insert one table data into multiple tables by using procedure?
Below is the simple procedure. Try the below
CREATE OR REPLACE PROCEDURE test_proc
AS
BEGIN
INSERT ALL
INTO emp_test1
INTO emp_test2
SELECT * FROM emp;
END;
If you want more examples you can refer below link
multi-table inserts in oracle 9i
Message was edited by: 000000 -
Adding data to multiple tables using one form in Access 2010?
Hi All,
I have a access database with two tables and I want to create a single form to enter data into that tables.
How to adding data to multiple tables using one form in Access 2010?
I don't have to much knowledge of access database?
Please help me
Thanks
BalajiYou really don't enter identical data into 2 tables. You enter dat into one single table, and then you have an unique identifier that maps to another table (you have a unique relationship between two tables).
Maybe you need to read this.
http://office.microsoft.com/en-001/access-help/database-design-basics-HA001224247.aspx
Think about it this way... What is you update data in 2 tables, and then the data in one of those tables changes, but the data in the other table does NOT change. WHOOPS!! Now, you've got a BIG problem. For instance, you have a customer
named Bill Gates. In one Table you update Bill's address to 1835 73rd Ave NE, Medina, WA 98039 and in the other table you accidentally update Bill's address to 183 73rd Ave NE, Medina, WA 98039. Now you have 2 addresses for Bill. Why would
you want that??? Which is right? No one knows. If you have one address, you just have to update one address and if there is a mistake, you just have to update one address, but you don't have to waste time trying to figure out which is right
and which is wong...and then update the one that is wrong.
Post back with specific questions.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
Inserting data into multiple tables in jdbc
I am doing on file to jdbc. Now I got a requirement to insert data into multiple tables on the receiver side. How can I do this ?
Hi,
you are going to insert data into 4 tables in a sequence one after another , I see three options.
1) Stored procedure and 2) creating 4 statement data structure (one for each table)
The third option is writing a SQL with join for the 4 tables and use action command = SQL_DML. Example as follows....
Write SQL code and place it in access tag. Pass values for the columns using key tag...
<stmt>
<Customers action="SQL_DML">
<access> UPDATE Customers SET CompanyName=u2019$NAME$u2019, Address=u2019$ADDRESS$' WHERE CustomerID='$KEYFIELD$u2019
</access>
<key>
<NAME>name</NAME>
<ADDRESS>add </ADDRESS>
<KEYFIELD>1</KEYFIELD>
</key>
</Customers>
</stmt>
Refer this http://help.sap.com/saphelp_nwpi71/helpdata/en/44/7b7855fde93673e10000000a114a6b/content.htm
Hope this helps .... -
I am loading data into a table I created which includes a column "Description" with a data type VARCHAR2(1000). When I go to load the data which is less than 1000 characters I receive the following error message:
Record 38: Rejected - Error on table SSW_INPUTS, column DESCRIPTION.
Field in data file exceeds maximum length
I have increased the size of the column but that does not seem to fix the error. Does anyone know what this error means? Another thought is that I have created the "Description" column to large...which can't be true because I should receive the error when I create the table. Plus I already inputted data into a similar table with similar data and had no problems!
Someone please help...
Thank you,
April.Note that I'm assuming Oracle8(i) behavior. Oracle9 may treat Unicode differently.
Are you inserting Unicode data into the table? Declaring a variable as varchar2(1000) indicates that Oracle should reserve 1000 bytes for data. If you're inserting UTF-8 encoded data, each character may take up to 3 bytes to store. Thus, 334 characters of data could theoretically overflow a varchar2(1000) variable.
Note that UTF-8 is designed so that the most commonly used characters are stored in 1 byte, less commonly used characters are stored in 2 bytes, and the remainder is stored in 3 bytes. On average, this will require less space than the more familiar UCS-2 encoding which stores every character as 2 bytes of data.
Justin -
How to load data into html:select using Struts ?
How to load data into <html:select> using Struts ?
I can not load an array or collection (static or dynamic data) into drop down list control by <html:select /> Struts.
please use:
<html:select >
<html:options />
</html:select >
Please help me. please detail it. thanks a lot.
Message was edited by:
tranminhmanIn order to load a collection or array of data you can use <html:select> with <html: options collection="" name=""/>
here collection attribute refers to the Arraylist or Array of data and name is the name of the Form bean.
Hope this helps...
Chaitanya V -
Loading data from multiple tables to multiple sheets of excel using SSIS
I have a requirement in which I want to load data from 13 tables to 13 respective sheets of single excel file using SSIS.
Can anyone know SSIS logic for developing package for this?see similar example here
http://visakhm.blogspot.in/2013/09/exporting-sqlserver-data-to-multiple.html
In your case you need to use loop to iterate through tables
First get list of tables in a object variable created in SSIS using INFORMATION_SCHEMA.TABLES view
Then add a for each loop based on ADO.NET variable enumerator to iterate through tables and inside loop follow method as in the above link to create the sheet first and populate it.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Error while loading data into External table from the flat files
HI ,
We have a data load in our project which feeds the oracle external tables with the data from the Flat Files(.bcp files) in unix.
While loading the data, we are encountering the following error.
Error occured (Error Code : -29913 and Error Message : ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04063: un) while loading data into table_ext
Please let us know what needs to be done in this case to solve this problem.
Thanks,
KartheekKartheek,
I used Google (mine still works).... please check those links:
http://oraclequirks.blogspot.com/2008/07/ora-29400-data-cartridge-error.html
http://jonathanlewis.wordpress.com/2011/02/15/ora-29913/
HTH,
Thierry -
INSERTION OF XML DATA INTO THE TABLE USING XMLDOM
hello,
i am using XMLDOM to insert the data into the table
i am using different function of it.
but i am facing the problem to retrive the the multiple entry.
like in my example i have two entry of the ' po number '
& i am using the function
dbms_xmldom.item(l_nodelist, 0)
i which i have to pass index no.
& through this i am getting only single entry according to the index no.
Example on which i am working is
declare
l_xml_data CLOB;
l_xml_doc dbms_xmldom.domdocument;
l_nodelist dbms_xmldom.DOMNodeList;
l_node dbms_xmldom.domnode;
l_xmltype XMLTYPE;
l_po_num VARCHAR2(30);
l_cust_ord VARCHAR2(30);
l_item_code VARCHAR2(30);
begin
l_xml_data := '<?xml version="1.0" encoding="UTF-8"?>
<!--DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd"-->
<MobileInventoryResponse>
<message>
<message-header>
<message-id>16244182</message-id>
<transaction-name>ship-advice</transaction-name>
<partner-name>cbeyond</partner-name>
<source-url>http://www.brightpoint.com</source-url>
<create-timestamp>20080826150709</create-timestamp>
<response-request>1</response-request>
</message-header>
<ship-advice>
<header>
<customer-id>297859</customer-id>
<shipment-information>
<ship-first-name>RA_13Aug_1</ship-first-name>
<ship-last-name>MIND</ship-last-name>
<ship-address1>test</ship-address1>
<ship-city>test</ship-city>
<ship-state>VA</ship-state>
<ship-post-code>22102-4931</ship-post-code>
<ship-country-code>US</ship-country-code>
<ship-phone1>0040726335068</ship-phone1>
<ship-email>[email protected]</ship-email>
<ship-via>FX01</ship-via>
<ship-request-date>20080826</ship-request-date>
<ship-request-warehouse>CBY1</ship-request-warehouse>
</shipment-information>
<purchase-order-information>
<purchase-order-number>380928</purchase-order-number>
<purchase-order-number>380929</purchase-order-number> ----modi by Ananda Dubey
<account-description/>
<purchase-order-amount>0.0</purchase-order-amount>
<currency-code>USD</currency-code>
</purchase-order-information>
<order-header>
<customer-order-number>0002759</customer-order-number>
<customer-order-date>20080826</customer-order-date>
<order-sub-total>19.0</order-sub-total>
<order-discount>0.0</order-discount>
<order-tax1>0.0</order-tax1>
<order-tax2>0.0</order-tax2>
<order-tax3>0.0</order-tax3>
<order-shipment-charge>18.0</order-shipment-charge>
<order-total-net>0.0</order-total-net>
<order-status>Completed</order-status>
<order-type/>
<brightpoint-order-number>35028788</brightpoint-order-number>
<warehouse-id>CBY1</warehouse-id>
<ship-date>20080826</ship-date>
</order-header>
</header>
<detail>
<line-item>
<line-no>1</line-no>
<item-code>SKU1</item-code>
<universal-product-code>0</universal-product-code>
<ship-quantity>1.0</ship-quantity>
<unit-of-measure>EA</unit-of-measure>
<serial-list>
<serial-numbers>
<esn>TIMI000013</esn>
</serial-numbers>
</serial-list>
<line-status/>
<base-price>0.0</base-price>
<line-discount>0.0</line-discount>
<line-tax1>0.0</line-tax1>
<line-tax2>0.0</line-tax2>
<line-tax3>0.0</line-tax3>
<bill-of-lading>929406733828</bill-of-lading>
<scac>FX01</scac>
</line-item>
</detail>
</ship-advice>
<transactionInfo>
<eventID>16244182</eventID>
</transactionInfo>
</message>
</MobileInventoryResponse>';
l_xml_doc := dbms_xmldom.newDomDocument(l_xml_data);
-- Method 1 to get data
l_nodelist := dbms_xmldom.getelementsbytagname(l_xml_doc, 'purchase-order-number');
l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from list
l_po_num := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
dbms_output.put_line(l_po_num);
l_nodelist := dbms_xslprocessor.selectnodes(dbms_xmldom.makenode(l_xml_doc),
'/MobileInventoryResponse/message/ship-advice/detail/line-item/item-code');
l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from list
l_item_code := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
dbms_output.put_line(l_item_code);
l_xmltype := XMLTYPE(l_xml_data);
l_cust_ord := l_xmltype.extract('/MobileInventoryResponse/message/ship-advice/header/order-header/customer-order-number/text()').getStringVal();
dbms_output.put_line(l_cust_ord);
dbms_xmldom.freeDocument(l_xml_doc);
end;
/In the following code
l_nodelist := dbms_xmldom.getelementsbytagname(l_xml_doc, 'purchase-order-number');
l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from listYou need to understand what the second parm on the .item call does. See [dbms_xmldom.item|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_xmldom.htm#i1126138]
The nodelist is a 0 based array of information and you are only requesting to pull the node info in the first array position. So to get the info in the second array position, you need to use ", 1)". You can also use .getLength and a loop to parse through everything in the node list.
Maybe you are looking for
-
SUM problem in SSRS 2005 report
I don't know how best to explain this but will try. In my SSRS 2005 report, i have one group in my table. In that group, I have a field that for each company record in my dataset, this field value is repeated for each record. This is a transactions
-
How to convert a pdf file to html, while retaining the exact formatting?
I have a pdf file, need to convert it into html. while I do so, all the formatting is lost. Is there any other way?
-
X240 with 2 ThinkPad Pro Docks not detecting screens
Hello all I have a Lenovo x240 with 2 ThinkPad Pro Docks one for the office and one home In office I have, a screen connected to dock via DVI port and its working fine In home, i have a screen connected to dock via vga port and this one is not wor
-
DSC EPICS connection to remote network
I am using the DSC module from LabVIEW 8.6 and 2009. I am in California, and there is an EPICS server in New Mexico to which I want to connect. I can read and write using command-line EPICS so I know that there are no firewall or hardware connectivit
-
Probelm with the access key not shown on menu item
Hi I have created a Menu and used setMnemonic for the menu items. But, I dont see the letter underlined when I set the look and feel as the following code try { UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName()); } catch