SQL Loader and Insert Into Performance Difference
Hello All,
Im in a situation to measure performance difference between SQL Loader and Insert into. Say there 10000 records in a flat file and I want to load it into a staging table.
I know that if I use PL/SQL UTL_FILE to do this job performance will degrade(dont ask me why im going for UTL_FILE instead of SQL Loader). But I dont know how much. Can anybody tell me the performance difference in % (like 20% will decrease) in case of 10000 records.
Thanks,
Kannan.
Kannan B wrote:
Do not confuse the topic, as I told im not going to use External tables. This post is to speak the performance difference between SQL Loader and Simple Insert Statement.I don't think people are confusing the topic.
External tables are a superior means of reading a file as it doesn't require any command line calls or external control files to be set up. All that is needed is a single external table definition created in a similar way to creating any other table (just with the additional external table information obviously). It also eliminates the need to have a 'staging' table on the database to load the data into as the data can just be queried as needed directly from the file, and if the file changes, so does the data seen through the external table automatically without the need to re-run any SQL*Loader process again.
Who told you not to use External Tables? Do they know what they are talking about? Can they give a valid reason why external tables are not to be used?
IMO, if you're considering SQL*Loader, you should be considering External tables as a better alternative.
Similar Messages
-
I have problem and your help to solve it would be very much appreciated.
I am uploading a text file with SQL Loader into a table. Since I used APPEND option in the Loader, I don't want records to be duplicated. So, I wrote a "BEFORE INSERT .. FOR EACH ROW" trigger to check whether that row already exists or not.
For example, let us consider a table TEST as follows.
Fld1 NUMBER(2);
Fld2 VARCHAR2(10);
Fld3 VARCHAR2(10);
I have a trigger on this table.
CREATE OR REPLACE TRIGGER Trg_Bef_Insert_Test
BEFORE INSERT ON Test FOR EACH ROW
DECLARE
vCount NUMBER(2);
DuplicateRow EXCEPTION;
BEGIN
SELECT Count(*) INTO vCount FROM Test
WHERE fld1 || fld2 || fld3 = :new.fld1 || :new.fld2 || :new.fld3;
IF vCount > 0 THEN
RAISE DuplicateRow;
END IF;
EXCEPTION
WHEN DuplicateRow THEN
Raise_Application_Error (-20001,'Record already exists');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR : ' || SQLCODE || '; ' || SUBSTR(SQLERRM, 1, 150));
END;
Please refer to the following SQL statements which I executed in the SQL Plus.
SQL> insert into test values (1,'one','first');
1 row created.
SQL> insert into test values (1,'one','first');
insert into test values (1,'one','first')
ERROR at line 1:
ORA-20001: Record already exists
ORA-06512: at "CAMELLIA.TRG_TEST", line 13
ORA-04088: error during execution of trigger 'CAMELLIA.TRG_TEST'
Would anyone tell me why do errors -6512 and -4088 occur ?
Also, if you have any other suggestion to handle this situation, please let me know.
By the way, I am using Oracle 8.1.7.
Thank you.There are a few things wrong here, but you should really use a unique constraint for this.
SQL> create table t (a number, b number, c number,
2 constraint uk unique (a, b, c));
Table created.Here's an example data file with 12 records three of which are duplicates.
1,2,3
3,4,5
6,7,8
3,2,1
5,5,5
3,4,5
3,2,1
1,1,1
2,2,2
6,7,8
8,8,8
9,9,9And a control file
load data
infile 'in.dat'
append
into table t
fields terminated by ',' optionally enclosed by '"'
(a, b, c)Running it with sql loader, inserts the nine records, outputs the three duplicates to a .bad file and logs all the errors in the .log file. No need for triggers or any code.
$ sqlldr control=in.ctl
Username:xxx
Password:
SQL*Loader: Release 9.2.0.1.0 - Production on Mon Apr 21 23:16:44 2003
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Commit point reached - logical record count 12
$ cat in.bad
3,4,5
3,2,1
6,7,8
SQL> select * from t;
A B C
1 2 3
3 4 5
6 7 8
3 2 1
5 5 5
1 1 1
2 2 2
8 8 8
9 9 9
9 rows selected. -
How to Select from Oracle 8i database and insert into Sql Server 2005 datab
Hi how to Select from Oracle 8i and insert into Sql Server 2005.
Source db as Oracle 8i
Target db as Sql Server 2005.
I need to select one table data from Oracle 8i & insert into Sql Server 2005
ThanksThanks Khan..
Is there is any query (OPENQUERY) available for that?
Regards.. -
Is there any difference in Oracle 9i SQL Loader and Oracle 10g SQL Loader
Hi
Can anyone tell me whether is there any difference in Oracle 9i SQL Loader and Oracle 10g SQL Loader?
I am upgrading the 9i db to 10g and wanted to run the 9i SQL Loader control files on upgraded 10g db. So please let me know is there any difference which I need to consider any modifications in the control files..
Thank you in advance
Adianswered
-
SQL *Loader and External Table
Hi,
Can anyone tell me the difference between SQL* Loader and External table?
What are the conditions under we can use SQL * Loader and External Table.
ThanxExternal tables are accessible from SQL, which generally simplifies life if the data files are physically located on the database server since you don't have to coordinate a call to an external SQL*Loader script with other PL/SQL processing. Under the covers, external tables are normally just invoking SQL*Loader.
SQL*Loader is more appropriate if the data files are on a different server or if it is easier to call an executable rather than calling PL/SQL (i.e. if you have a batch file that runs on a server other than the database server that wants to FTP a data file from a FTP server and then load the data into Oracle).
Justin -
I am having a problem updating a large partitioned table through it's appropriate view. Here is the loader file
LOAD DATA
INSERT INTO TABLE test.example
( PROGRAM POSITION(1:4) CHAR,
DWING_NUMBER POSITION(6:32) CHAR,
LAST_ISSUED_REVISION POSITION(34:35) CHAR,
TEMP_NUMBER POSITION(37:43) CHAR,
CONFIGURATION_ITEM POSITION(45:45) CHAR,
LOCATION_CODE POSITION(47:47) CHAR
It generates this error:
SQL*Loader-951: Error calling once/load initialization
ORA-26018: Column PROGRAM in table test.example does not exist
There are a few considerations that go along with this, and I am developing a strong disdain for the 2 dba's that are involved. First, this view accesses a large partitioned table, all according to "PROGRAM". Secondly, PROGRAM is called PROG_ID in the main table. I didn't think this was an issue at first, but it seems like it might be part of the problem I'm having. We're running Oracle 9.2.0 here. Any helpful replies will be greatly appreciated. Thanks.This is what the view looks like:
Column / Data Type / Null? / Updatable
PROGRAM VARCHAR(10) N y
DWING_NUMBER VARCHAR(28) N y
LAST_ISSUED_REVISION VARCHAR(2) Y y
TEMP_NUMBER VARCHAR(7) Y y
CONFIGURATION_ITEM VARCHAR(1) Y y
LOCATION_CODE VARCHAR(1) Y y
The main table that this view grabs data from is identical, except for the fact that PROGAM is PROG_ID. I'm fairly new to doing database work, so if the answer is trivial please spare my self esteem.
formatting sucks
vagrantgringo -
Using SQL Loader to insert data based on conditionally statements
I would like to use sql loader to insert records from a single text file into an Oracle database table. Sounds easy but the problem is that I need to check the existence of data in another table (Table A) before data can be loaded into Table B.
Table A has two columns: dept_no (primary key value) and dept_name (char)
Table B has five columns: emp_no (primary key value), dept_no (foreign key value to Table A), employee (char), job_title (char) and salary (number)
Text File looks like this:
Finance Jones President 10000
HR Smith Admin 2000
HelpDesk Jenkins Technician 3000
Problem:
1. I need sql loader to insert records into Table B by first checking if the first field in the file is in Table A.
2. If value exists get it's dept_no value.
3. If value doesn't exist discard record ( I might want to have sql loader insert a new record for this into Table A)
4. Using value from #2, insert the value in Table B for dept_no column.
5. Also assign a sequence value for the emp_no value in Table B.
Any guidance is greatly appreciated.
Thanks,Hello,
I am not sure this is possible with SQL loader. I would rather use an external table based on your file.
Then, I would use SQL to load your data into your table, based on your conditions.
Your request is not very complicated, writing the SQL to do that will be really more simple than trying to do it with SQL loader.
Hope it will help.
Regards,
Sylvie -
Reg: read excel column and insert into table.
hi Friends,
i wanted to read the data from Excel and insert into in my oracle tables.
can you provide the link or example script.
how to read the column value from excel and insert into table.
please help.< unnecessary reference to personal blog removed by moderator >
Here are the steps:
1) First create a directory and grant read , write , execute to the user from where you want to access the flat files and load it.
2) Write a generic function to load PIPE delimited flat files:
CREATE OR REPLACE FUNCTION TABLE_LOAD ( p_table in varchar2,
p_dir in varchar2 DEFAULT ‘YOUR_DIRECTORY_NAME’,
P_FILENAME in varchar2,
p_ignore_headerlines IN INTEGER DEFAULT 1,
p_delimiter in varchar2 default ‘|’,
p_optional_enclosed in varchar2 default ‘”‘ )
return number
is
– FUNCTION TABLE_LOAD
– PURPOSE: Load the flat files i.e. only text files to Oracle
– tables.
– This is a generic function which can be used for
– importing any text flat files to oracle database.
– PARAMETERS:
– P_TABLE
– Pass name of the table for which import has to be done.
– P_DIR
– Name of the directory where the file is been placed.
– Note: The grant has to be given for the user to the directory
– before executing the function
– P_FILENAME
– The name of the flat file(a text file)
– P_IGNORE_HEADERLINES
– By default we are passing 1 to skip the first line of the file
– which are headers on the Flat files.
– P_DELIMITER
– Dafault “|” pipe is been passed.
– P_OPTIONAL_ENCLOSED
– Optionally enclosed by ‘ ” ‘ are been ignored.
– AUTHOR:
– Slobaray
l_input utl_file.file_type;
l_theCursor integer default dbms_sql.open_cursor;
l_lastLine varchar2(4000);
l_cnames varchar2(4000);
l_bindvars varchar2(4000);
l_status integer;
l_cnt number default 0;
l_rowCount number default 0;
l_sep char(1) default NULL;
L_ERRMSG varchar2(4000);
V_EOF BOOLEAN := false;
begin
l_cnt := 1;
for TAB_COLUMNS in (
select column_name, data_type from user_tab_columns where table_name=p_table order by column_id
) loop
l_cnames := l_cnames || tab_columns.column_name || ‘,’;
l_bindvars := l_bindvars || case when tab_columns.data_type in (‘DATE’, ‘TIMESTAMP(6)’) then ‘to_date(:b’ || l_cnt || ‘,”YYYY-MM-DD HH24:MI:SS”),’ else ‘:b’|| l_cnt || ‘,’ end;
l_cnt := l_cnt + 1;
end loop;
l_cnames := rtrim(l_cnames,’,');
L_BINDVARS := RTRIM(L_BINDVARS,’,');
L_INPUT := UTL_FILE.FOPEN( P_DIR, P_FILENAME, ‘r’ );
IF p_ignore_headerlines > 0
THEN
BEGIN
FOR i IN 1 .. p_ignore_headerlines
LOOP
UTL_FILE.get_line(l_input, l_lastLine);
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_eof := TRUE;
end;
END IF;
if not v_eof then
dbms_sql.parse( l_theCursor, ‘insert into ‘ || p_table || ‘(‘ || l_cnames || ‘) values (‘ || l_bindvars || ‘)’, dbms_sql.native );
loop
begin
utl_file.get_line( l_input, l_lastLine );
exception
when NO_DATA_FOUND then
exit;
end;
if length(l_lastLine) > 0 then
for i in 1 .. l_cnt-1
LOOP
dbms_sql.bind_variable( l_theCursor, ‘:b’||i,
ltrim(rtrim(rtrim(
regexp_substr(l_lastLine,’([^|]*)(\||$)’,1,i),p_delimiter),p_optional_enclosed),p_optional_enclosed));
end loop;
begin
l_status := dbms_sql.execute(l_theCursor);
l_rowCount := l_rowCount + 1;
exception
when OTHERS then
L_ERRMSG := SQLERRM;
insert into BADLOG ( TABLE_NAME, ERRM, data, ERROR_DATE )
values ( P_TABLE,l_errmsg, l_lastLine ,systimestamp );
end;
end if;
end loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_input );
commit;
end if;
insert into IMPORT_HIST (FILENAME,TABLE_NAME,NUM_OF_REC,IMPORT_DATE)
values ( P_FILENAME, P_TABLE,l_rowCount,sysdate );
UTL_FILE.FRENAME(
P_DIR,
P_FILENAME,
P_DIR,
REPLACE(P_FILENAME,
‘.txt’,
‘_’ || TO_CHAR(SYSDATE, ‘DD_MON_RRRR_HH24_MI_SS_AM’) || ‘.txt’
commit;
RETURN L_ROWCOUNT;
end TABLE_LOAD;
Note: when you run the function then it will also modify the source flat file with timestamp , so that we can have the track like which file was loaded .
3) Check if the user is having UTL_FILE privileges or not :
SQL> SELECT OWNER,
OBJECT_TYPE
FROM ALL_OBJECTS
WHERE OBJECT_NAME = ‘UTL_FILE’
AND OWNER =<>;
If the user is not having the privileges then grant “UTL_FILE” to user from SYS user:
SQL> GRANT EXECUTE ON UTL_FILE TO <>;
4) In the function I have used two tables like:
import_hist table and badlog table to track the history of the load and another to check the bad log if it occurs while doing the load .
Under the same user create an error log table to log the error out records while doing the import:
SQL> CREATE TABLE badlog
errm VARCHAR2(4000),
data VARCHAR2(4000) ,
error_date TIMESTAMP
Under the same user create Load history table to log the details of the file and tables that are imported with a track of records loaded:
SQL> create table IMPORT_HIST
FILENAME varchar2(200),
TABLE_NAME varchar2(200),
NUM_OF_REC number,
IMPORT_DATE DATE
5) Finally run the PLSQL block and check if it is loading properly or not if not then check the badlog:
Execute the PLSQL block to import the data from the USER:
SQL> declare
P_TABLE varchar2(200):=<>;
P_DIR varchar2(200):=<>;
P_FILENAME VARCHAR2(200):=<>;
v_Return NUMBER;
BEGIN
v_Return := TABLE_LOAD(
P_TABLE => P_TABLE,
P_DIR => P_DIR,
P_FILENAME => P_FILENAME,
P_IGNORE_HEADERLINES => P_IGNORE_HEADERLINES,
P_DELIMITER => P_DELIMITER,
P_OPTIONAL_ENCLOSED => P_OPTIONAL_ENCLOSED
DBMS_OUTPUT.PUT_LINE(‘v_Return = ‘ || v_Return);
end;
6) Once the PLSQL block is been executed then check for any error log table and also the target table if the records are been successfully imported or not. -
How to insert into two differents tables at the same time
Hi
I'm newer using JDev, (version 3.1.1.2 cause the OAS seems to support just the JSP 1.0)
and I want to insert into two differents tables at the same time using one view.
How can I do that ?
TIA
EdgarOracle 8i supports 'INSTEAD OF' triggers on object views so you could use a process similar to the following:
1. Create an object view that joins your two tables. 'CREATE OR REPLACE VIEW test AS SELECT d.deptno, d.deptname, e.empname FROM DEPT d, EMP E'.
2. Create an INSTEAD OF trigger on the view.
3. Put code in the trigger that looks at the :NEW values being processed and determines which columns should be used to INSERT or UPDATE for each table. Crude pseudo-code might be:
IF :NEW.deptno NOT IN (SELECT deptno FROM DEPT) THEN
INSERT INTO dept VALUES(:NEW.deptno, :NEW.deptname);
INSERT INTO emp VALUES (:NEW.deptno, :NEW.empname);
ELSE
IF :NEW.deptname IS NOT NULL THEN
UPDATE dept SET deptname = :NEW.deptname
WHERE deptno = :NEW.deptno;
END IF;
IF :NEW.empname IS NOT NULL THEN
UPDATE emp SET empname = :NEW.empname
WHERE deptno = :NEW.deptno;
Try something along those lines.
null -
Read data from E$ table and insert into staging table
Hi all,
I am a new to ODI. I want your help in understanding how to read data from an "E$" table and insert into a staging table.
Scenario:
Two columns in a flat file, employee id and employee name, needs to be loaded into a datastore EMP+. A check constraint is added to allow data with employee names in upper case only to be loaded into the datastore. Check control is set to flow and static. Right click on the datastore, select control and then check. The rows that have violated the check constraint are kept in E$_EMP+ table.
Problem:
Issue is that I want to read the data from the E$_EMP+ table and transform the employee name into uppercase and move the corrected data from E$_EMP+ into EMP+. Please advise me on how to automatically handle "soft" exceptions in ODI.
Thank youHi Himanshu,
I have tried the approach you suggested already. That works. However, the scenario I described was very basic. Based on the error logged into the E$_EMP table, I will have to design the interface to apply more business logic before the data is actually merged into the target table.
Before the business logic is applied, I need to read each row from the E$EMP table first and I do not know how to read from E$EMP table. -
HELP: SQL*LOADER AND Ref Column
Hallo,
I have already posted and I really need help and don't come further with this
I have the following problem. I have 2 tables which I created the following way:
CREATE TYPE gemark_schluessel_t AS OBJECT(
gemark_id NUMBER(8),
gemark_schl NUMBER(4),
gemark_name VARCHAR2(45)
CREATE TABLE gemark_schluessel_tab OF gemark_schluessel_t(
constraint pk_gemark PRIMARY KEY(gemark_id)
CREATE TYPE flurstueck_t AS OBJECT(
flst_id NUMBER(8),
flst_nr_zaehler NUMBER(4),
flst_nr_nenner NUMBER(4),
zusatz VARCHAR2(2),
flur_nr NUMBER(2),
gemark_schluessel REF gemark_schluessel_t,
flaeche SDO_GEOMETRY
CREATE TABLE flurstuecke_tab OF flurstueck_t(
constraint pk_flst PRIMARY KEY(flst_id),
constraint uq_flst UNIQUE(flst_nr_zaehler,flst_nr_nenner,zusatz,flur_nr),
flst_nr_zaehler NOT NULL,
flur_nr NOT NULL,
gemark_schluessel REFERENCES gemark_schluessel_tab
Now I have data in the gemark_schluessel_tab which looks like this (a sample):
1 101 Borna
2 102 Draisdorf
Now I wanna load data in my flurstuecke_tab with SQL*Loader and there I have problems with my ref column gemark_schluessel.
One data record looks like this in my file (it is without geometry)
1|97|7||1|1|
If I wanna load my data record, it does not work. The reference (the system generated OID) should be taken from gemark_schluessel_tab.
LOAD DATA
INFILE *
TRUNCATE
CONTINUEIF NEXT(1:1) = '#'
INTO TABLE FLURSTUECKE_TAB
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS (
flst_id,
flst_nr_zaehler,
flst_nr_nenner,
zusatz,
flur_nr,
gemark_schluessel REF(CONSTANT 'GEMARK_SCHLUESSEL_TAB',GEMARK_ID),
gemark_id FILLER
BEGINDATA
1|97|7||1|1|
Is there a error I made?
Thanks in advance
Tigmultiple duplicate threads:
to call an oracle procedure and sql loader in an unix script
Re: Can some one help he sql loader issue. -
Problem : Load PDF or similiar files( stored at operating system) into an oracle table using SQl*Loader .
and than Unload the files back from oracle tables to prevoius format.
I 've used SQL*LOADER .... " sqlldr " command as :
" sqlldr scott/[email protected] control=c:\sqlldr\control.ctl log=c:\any.txt "
Control file is written as :
LOAD DATA
INFILE 'c:\sqlldr\r_sqlldr.txt'
REPLACE
INTO table r_sqlldr
Fields terminated by ','
id sequence (max,1) ,
fname char(20),
data LOBFILE(fname) terminated by EOF )
It loads files ( Pdf, Image and more...) that are mentioned in file r_sqlldr.txt into oracle table r_sqlldr
Text file ( used as source ) is written as :
c:\kalam.pdf,
c:\CTSlogo1.bmp
c:\any1.txt
after this load ....i used UTL_FILE to unload data and write procedure like ...
CREATE OR REPLACE PROCEDURE R_UTL AS
l_file UTL_FILE.FILE_TYPE;
l_buffer RAW(32767);
l_amount BINARY_INTEGER ;
l_pos INTEGER := 1;
l_blob BLOB;
l_blob_len INTEGER;
BEGIN
SELECT data
INTO l_blob
FROM r_sqlldr
where id= 1;
l_blob_len := DBMS_LOB.GETLENGTH(l_blob);
DBMS_OUTPUT.PUT_LINE('blob length : ' || l_blob_len);
IF (l_blob_len < 32767) THEN
l_amount :=l_blob_len;
ELSE
l_amount := 32767;
END IF;
DBMS_LOB.OPEN(l_blob, DBMS_LOB.LOB_READONLY);
l_file := UTL_FILE.FOPEN('DBDIR1','Kalam_out.pdf','w', 32767);
DBMS_OUTPUT.PUT_LINE('File opened');
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.READ (l_blob, l_amount, l_pos, l_buffer);
DBMS_OUTPUT.PUT_LINE('Blob read');
l_pos := l_pos + l_amount;
UTL_FILE.PUT_RAW(l_file, l_buffer, TRUE);
DBMS_OUTPUT.PUT_LINE('writing to file');
UTL_FILE.FFLUSH(l_file);
UTL_FILE.NEW_LINE(l_file);
END LOOP;
UTL_FILE.FFLUSH(l_file);
UTL_FILE.FCLOSE(l_file);
DBMS_OUTPUT.PUT_LINE('File closed');
DBMS_LOB.CLOSE(l_blob);
EXCEPTION
WHEN OTHERS THEN
IF UTL_FILE.IS_OPEN(l_file) THEN
UTL_FILE.FCLOSE(l_file);
END IF;
DBMS_OUTPUT.PUT_LINE('Its working at last');
END R_UTL;
This loads data from r_sqlldr table (BOLBS) to files on operating system ,,,
-> Same procedure with minor changes is used to unload other similar files like Images and text files.
In above example : Loading : 3 files 1) Kalam.pdf 2) CTSlogo1.bmp 3) any1.txt are loaded into oracle table r_sqlldr 's 3 rows respectively.
file names into fname column and corresponding data into data ( BLOB) column.
Unload : And than these files are loaded back into their previous format to operating system using UTL_FILE feature of oracle.
so PROBLEM IS : Actual capacity (size ) of these files is getting unloaded back but with quality decreased. And PDF file doesnt even view its data. means size is almot equal to source file but data are lost when i open it.....
and for images .... imgaes are getting loaded an unloaded but with colors changed ....
Also features ( like FFLUSH ) of Oracle 've been used but it never worked
ANY SUGGESTIONS OR aLTERNATE SOLUTION TO LOAD AND UNLOAD PDFs through Oracle ARE REQUESTED.
------------------------------------------------------------------------------------------------------------------------Thanks Justin ...for a quick response ...
well ... i am loading data into BLOB only and using SQL*Loader ...
I've never used dbms_lob.loadFromFile to do the loads ...
i 've opend a file on network and than used dbms_lob.read and
UTL_FILE.PUT_RAW to read and write data into target file.
actually ...my process is working fine with text files but not with PDF and IMAGES ...
and your doubt of ..."Is the data the proper length after reading it in?" ..m not getting wat r you asking ...but ... i think regarding data length ..there is no problem... except ... source PDF length is 90.4 kb ..and Target is 90.8 kb..
thats it...
So Request u to add some more help ......or should i provide some more details ?? -
Import and process larger data with SQL*Loader and Java resource
Hello,
I have a project to import data from a text file in a schedule. A lager data, with nearly 20,000 record/1 hours.
After that, we have to analysis the data, and export the results into a another database.
I research about SQL*Loader and Java resource to do these task. But I have no experiment about that.
I'm afraid of the huge data, Oracle could be slowdown or the session in Java Resource application could be timeout.
Please tell me some advice about the solution.
Thank you very much.With '?' mark i mean " How i can link this COL1 with column in csv file ? "
Attilio -
Extract data from xml file and insert into another exiting xml fil
hello,
i am searching extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
Regards,
ZhuozhiIf the files are small, you can load the target file in a DOM document, insert the data from the source file and persist the DOM.
If the files are large, you probably want to use a StAX or SAX. -
Split one column value and insert into multiple columns
hi
am new to plsql .
i want to split a characters from one column and insert into multiple columns
i tried used substr function the symbol ',' vary his place dynamically ,so i can't apply substr function.
for eg: before split
col1 :
col2 :
col3 :
col4 :
colu5: adsdf,fgrty,erfth,oiunth,okujt
after split
col1 :adsd
col2 :fgrty
col3 :erfth
col4 :oiunth
col5 : adsdf,fgrty,erfth,oiunth,okujt
can anyone help me
thanks
Edited by: 800324 on Dec 23, 2010 8:28 AM
Edited by: 800324 on Dec 23, 2010 8:36 AMHow about:
SQL> create table t
2 (col1 varchar2(30)
3 ,col2 varchar2(30)
4 ,col3 varchar2(30)
5 ,col4 varchar2(30)
6 ,col5 varchar2(30)
7 );
Table created.
SQL> insert into t (col5) values ('adsdf,fgrty,erfth,oiunth,okujt');
1 row created.
SQL> insert into t (col5) values ('x,y');
1 row created.
SQL> insert into t (col5) values ('a,b,c,d');
1 row created.
SQL> select * from t;
COL1 COL2 COL3 COL4 COL5
adsdf,fgrty,erfth,oiunth,okujt
x,y
a,b,c,d
3 rows selected.
SQL>
SQL> merge into t a
2 using ( with t1 as ( select col5||',' col5
3 from t
4 )
5 select substr(col5, 1, instr(col5, ',', 1, 1)-1) col1
6 , substr(col5, instr(col5, ',', 1, 1)+1, instr(col5, ',', 1, 2)- instr(col5, ',', 1, 1)-1) col2
7 , substr(col5, instr(col5, ',', 1, 2)+1, instr(col5, ',', 1, 3)- instr(col5, ',', 1, 2)-1) col3
8 , substr(col5, instr(col5, ',', 1, 3)+1, instr(col5, ',', 1, 4)- instr(col5, ',', 1, 3)-1) col4
9 , rtrim(col5, ',') col5
10 from t1
11 ) b
12 on ( a.col5 = b.col5 )
13 when matched then update set a.col1 = b.col1
14 , a.col2 = b.col2
15 , a.col3 = b.col3
16 , a.col4 = b.col4
17 when not matched then insert (a.col1) values (null);
3 rows merged.
SQL> select * from t;
COL1 COL2 COL3 COL4 COL5
adsdf fgrty erfth oiunth adsdf,fgrty,erfth,oiunth,okujt
x y x,y
a b c d a,b,c,d
3 rows selected.
SQL> Assuming you're on 9i...
Maybe you are looking for
-
How to install networked Epson Expression 10000XL?
Hello, I have an Epson Expression 10000XL scanner with an ethernet card connected to my network. The scanner workes fine, but after makeing a clean install of OS X Mavericks I'm lost. The old drivers won't work, and the new ones are supposed to come
-
Hello, I have OSX Server 10.2.8 and it has been running fine for the past 3 years but now all of a sudden I have problems logging in to POP and IMAP accounts or even sending mail through it? The server appears to be unresponsive but then works again
-
More information density on external monitor
Hi all I have a Macbook Air (2ghz i7 - 8GB Ram - 4000 1024 graphics) mid 2012. I'm after a 27 inch external monitor - but I don't want larger content, I want MORE content. I need more actual information density so I can have several panes open and vi
-
Update language code on 6110 nav
after updating the phones software I can not get the phone on Danish what can I do
-
Oracle 7.3.4 on Sun Solaris 7
Help needed Could anyone tell me whether Oracle 7.3.4, Oracle 8, Forms 6 and Forms 5 are available for Sun Solaris 7? Thanks