SQL loader Data Conversion
We are receving a column values (example: Product Description) which is in a chinese language. Those rows has to be converted in to a English and load it in database custom table.
Any possibilities?
Thanks & Regards,
Balakirshna
Pl post details of OS and database versions.
Oracle is not a language translator :-) You will need to perform the language conversion outside of Oracle and then feed the data to Oracle so it can load it.
HTH
Srini
Similar Messages
-
Hi,
I have a file where fields are wrapped with ".
=========== file sample
"asdsa","asdsadasdas","1123"
"asdsa","asdsadasdas","1123"
"asdsa","asdsadasdas","1123"
"asdsa","asdsadasdas","1123"
==========
I am having a .net method to remove the wrap characters and write out a file without wrap characters.
======================
asdsa,asdsadasdas,1123
asdsa,asdsadasdas,1123
asdsa,asdsadasdas,1123
asdsa,asdsadasdas,1123
======================
the .net code is here.
========================================
public static string RemoveCharacter(string sFileName, char cRemoveChar)
object objLock = new object();
//VirtualStream objInputStream = null;
//VirtualStream objOutStream = null;
FileStream objInputFile = null, objOutFile = null;
lock(objLock)
try
objInputFile = new FileStream(sFileName, FileMode.Open);
//objInputStream = new VirtualStream(objInputFile);
objOutFile = new FileStream(sFileName.Substring(0, sFileName.LastIndexOf('\\')) + "\\" + Guid.NewGuid().ToString(), FileMode.Create);
//objOutStream = new VirtualStream(objOutFile);
int nByteRead;
while ((nByteRead = objInputFile.ReadByte()) != -1)
if (nByteRead != (int)cRemoveChar)
objOutFile.WriteByte((byte)nByteRead);
finally
objInputFile.Close();
objOutFile.Close();
return sFileName.Substring(0, sFileName.LastIndexOf('\\')) + "\\" + Guid.NewGuid().ToString();
==================================
however when I run the bulk load utility I get the error
=======================================
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 3 (NumberOfMultipleMatches).
==========================================
the bulk insert statement is as follows
=========================================
BULK INSERT Temp
FROM '<file name>' WITH
FIELDTERMINATOR = ','
, KEEPNULLS
==========================================
Does anybody know what is happening and what needs to be done ?
PLEASE HELP
Thanks in advance
VikramTo load that file with BULK INSERT, use this format file:
9.0
4
1 SQLCHAR 0 0 "\"" 0 "" ""
2 SQLCHAR 0 0 "\",\"" 1 col1 Latin1_General_CI_AS
3 SQLCHAR 0 0 "\",\"" 2 col2 Latin1_General_CI_AS
4 SQLCHAR 0 0 "\"\r\n" 3 col3 Latin1_General_CI_AS
Note that the format file defines four fields while the fileonly seems to have three. The format file defines an empty field before the first quote.
Or, since you already have a .NET program, use a stored procedure with table-valued parameter instead. I have an example of how to do this here:
http://www.sommarskog.se/arrays-in-sql-2008.html
Erland Sommarskog, SQL Server MVP, [email protected] -
Create sql loader data file dynamically
Hi,
I want a sample program/approach which is used to create a sql loader data file.
The program will read table name as i/p and will use
select stmt will column list derived from user_tab_columns from data dictionary
assuming multiple clob columns in the column list.
Thanks
ManojI 'm writing clob and other columns to a sql loader dat file.
Below sample code for writing clob column is giving file write error.
How can I write multiple clobs to dat file so that control file will handle it correctly
offset NUMBER := 1;
chunk VARCHAR2(32000);
chunk_size NUMBER := 32000;
WHILE( offset < dbms_lob.getlength(l_rec_type.narrative) )
LOOP
chunk := dbms_lob.substr(l_rec_type.narrative, chunk_size, offset );
utl_file.put( l_file_handle, chunk );
utl_file.fflush(l_file_handle);
offset := offset + chunk_size;
END LOOP;
utl_file.new_line(l_file_handle); -
SQL Loader - data exceeds maximum length
I am having an issue with SQL Loader falsely reporting that a column is too long in a CSV upload file. The offending column, Notes, is defined in the staging table as VARCHAR2(1000). The text in the Notes column in the upload file for the record that is being rejected is only 237 characters long. I examined the raw data file with a hex editor and there are no special cahracters embedded in the column. The CSV upload was recreated but the false error remains.
Any ideas what to check? Any suggestion appreciated.
Here are the pertinent files.
Control File:LOAD DATA
INFILE 'Mfield_Upl.dat'
BADFILE 'Mfield_Upl.bad'
TRUNCATE
INTO TABLE Mfield_UPL_Staging
FIELDS TERMINATED BY ',' optionally enclosed by '"'
ControlNo CHAR,
PatientID CHAR,
CollectDate DATE "MM/DD/YYYY",
TestDate DATE "MM/DD/YYYY",
AnalyteDesc CHAR,
Results CHAR,
HiLoFlag CHAR,
LoRange CHAR,
HiRange CHAR,
UnitOfMeas CHAR,
Comments CHAR,
Notes CHAR,
ClinicalEvent CHAR,
OwnerLName CHAR,
OwnerFName CHAR,
PetName CHAR,
AssecNo CHAR,
SpecimenID CHAR
{code}
Staging Table:{code}
CREATE TABLE Mfield_UPL_Staging
ControlNo VARCHAR2(20),
PatientID VARCHAR2(9),
CollectDate DATE,
TestDate DATE,
AnalyteDesc VARCHAR2(100),
Results VARCHAR2(100),
HiLoFlag CHAR(10),
LoRange VARCHAR2(15),
HIRange VARCHAR2(15),
UnitOfMeas VARCHAR2(25),
Comments VARCHAR2(100),
Notes VARCHAR2(1000),
ClinicalEvent VARCHAR2(20),
OwnerLName VARCHAR(50),
OwnerFName VARCHAR(50),
PetName VARCHAR(50),
AssecNo NUMBER(10),
SpecimenID NUMBER(10)
{Code}
Error Log File:{code}
SQL*Loader: Release 9.2.0.1.0 - Production on Wed Aug 11 08:22:58 2010
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Control File: Mfield_UPL_CSV.ctl
Data File: Mfield_UPL.dat
Bad File: Mfield_Upl.bad
Discard File: none specified
(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 MFIELD_UPL_STAGING, loaded from every logical record.
Insert option in effect for this table: TRUNCATE
Column Name Position Len Term Encl Datatype
CONTROLNO FIRST * , O(") CHARACTER
PATIENTID NEXT * , O(") CHARACTER
COLLECTDATE NEXT * , O(") DATE MM/DD/YYYY
TESTDATE NEXT * , O(") DATE MM/DD/YYYY
ANALYTEDESC NEXT * , O(") CHARACTER
RESULTS NEXT * , O(") CHARACTER
HILOFLAG NEXT * , O(") CHARACTER
LORANGE NEXT * , O(") CHARACTER
HIRANGE NEXT * , O(") CHARACTER
UNITOFMEAS NEXT * , O(") CHARACTER
COMMENTS NEXT * , O(") CHARACTER
NOTES NEXT * , O(") CHARACTER
CLINICALEVENT NEXT * , O(") CHARACTER
OWNERLNAME NEXT * , O(") CHARACTER
OWNERFNAME NEXT * , O(") CHARACTER
PETNAME NEXT * , O(") CHARACTER
ASSECNO NEXT * , O(") CHARACTER
SPECIMENID NEXT * , O(") CHARACTER
Record 1042: Rejected - Error on table MFIELD_UPL_STAGING, column NOTES.
Field in data file exceeds maximum length
Table MFIELD_UPL_STAGING:
3777 Rows successfully loaded.
1 Row 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.
{code}Try:
-- Etc ...
Notes CHAR(1000),
-- Etc ...SQL*Loader limits string buffer to 256 unless specified different.
:p -
How do i get sql loader to recognize recognize AM/PM. My control file is below. The error I get is syntax error at line 14. Expecting field-name, found ")".
OPTIONS ( SKIP=0)
LOAD DATA
INFILE '/ftp_data/labor_scheduling/kronos_punch_temp/kronos_punches.csv'
BADFILE '/ftp_data/labor_scheduling/kronos_punches/kronos_punches.bad'
DISCARDFILE '/ftp_data/labor_scheduling/kronos_punches/kronos_punches.dsc'
INTO TABLE "STAFFING"."KRONOS_TEMP_PUNCHES"
TRUNCATE
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
(EMPLOYEE_ID,
SCHEDULE_DATE DATE "MM/DD/YY",
PUNCH DATE "MM/DD/YY HH:MI AM"
)Hi Gary,
Could your problem be with this?
(EMPLOYEE_ID,You have no data type for that field.
Regards
Peter -
Hi Guys,
We have a SQL Loader script that used to data in the 'mm/dd/yyyy' format. Post migration of the script onto a seprate server the format is getting stored in 'dd/mm/yyyy' format in a VARCHAR datatype column for DOB.
Please find below the Loader script :
"insert into tsa_lists values ('" & ttsa_list_typ & "','" & ttsa_list_num & "',"
if ttsa_list_typ <> "AuthRep" then
inscmd.CommandText= "insert into tsa_lists values ('" & ttsa_list_typ & "','" & ttsa_list_num & "',?,?,?,?,?,?,?,?,?,?,sysdate,?,?)"
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_sid",200,1,30,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_lastname",200,1,500,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_firstname",200,1,500,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_firstletter",200,1,1,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_middlename",200,1,500,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_dob",200,1,100,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_pob",200,1,200,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_citizenship",200,1,200,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_cleared",200,1,3,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_misc",200,1,2000,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_firstname_orig",200,1,500,"")
inscmd.Parameters.Append inscmd.CreateParameter("ttsa_lastname_orig",200,1,500,"")Data coming in the below format:
SID CLEARED LASTNAME FIRSTNAME MIDDLENAME TYPE DOB POB CITIZENSHIP PASSPORT/IDNUMBER MISC
3799509 A ABD AL SALAM MARUF ABDALLAH 01-Jul-55
3799512 A ABD AL SALAM MARUF ABDALLAH 01-Jan-80
3727959 A KHALID KHALIL IBRAHIM MAHDI 11-Nov-50
3458238 A KHALID KHALIL IBRAHIM MAHDI 08-Jan-81
3458242 A KHALID KHALIL IBRAHIM MAHDI 31-Jul-81
3458231 A KHALID KHALIL IBRAHIM MAHDI 01-Aug-81
2407275 A MUSA BARARUDDIN Y DAGAM 19-Aug-62
Please can you guys suggest a way.
Cheers,
Shazin1) That does not look like anything recognized by "SQL*Loader" utility.
2) If you just really mean a "sql" statement to load data...then:
a) If table column is date type, then use the TO_DATE() function
b) If column is Varchar2 you should not save date's in a varchar2 column.
In any case check out the NLS_DATE_FORMAT parameter on the database and or the same parameter on client side.
:p -
Sql loader - Data loading issue with no fixed record length
Hi All,
I am trying to load the following data through sql loader. However the records # 1, 3 & 4 are only loading succesfully into the table and rest of the records showing as BAD. What is missing in my syntax?
.ctl file:
LOAD DATA
INFILE 'C:\data.txt'
BADFILE 'c:\data.BAD'
DISCARDFILE 'c:\data.DSC' DISCARDMAX 50000
INTO TABLE icap_gcims
TRAILING NULLCOLS
CUST_NBR_MAIN POSITION(1:9) CHAR NULLIF (CUST_NBR_MAIN=BLANKS),
CONTACT_TYPE POSITION(10:11) CHAR NULLIF (CONTACT_TYPE=BLANKS),
INQUIRY_TYPE POSITION(12:13) CHAR NULLIF (INQUIRY_TYPE=BLANKS),
INQUIRY_MODEL POSITION(14:20) CHAR NULLIF (INQUIRY_MODEL=BLANKS),
INQUIRY_COMMENTS POSITION(21:60) CHAR NULLIF (INQUIRY_COMMENTS=BLANKS),
OTHER_COLOUR POSITION(61:75) CHAR NULLIF (OTHER_COLOUR=BLANKS),
OTHER_MAKE POSITION(76:89) CHAR NULLIF (OTHER_MAKE=BLANKS),
OTHER_MODEL_DESCRIPTION POSITION(90:109) CHAR NULLIF (OTHER_MODEL_DESCRIPTION=BLANKS),
OTHER_MODEL_YEAR POSITION(110:111) CHAR NULLIF (OTHER_MODEL_YEAR=BLANKS)
data.txt file:
000000831KHAN
000000900UHFA WANTS NEW WARRANTY ID 000001017OHAL
000001110KHAP
000001812NHDE231291COST OF SERVICE INSPECTIONS TOO HIGH MAXIMA 92 MK
000002015TPFA910115CUST UPSET WITH AIRPORT DLR. $200 FOR PLUGS,OIL,FILTER CHANGE. FW
Thanks,Hi,
Better if you have given the table structure, I check your script it was fine
11:39:01 pavan_Real>create table test1(
11:39:02 2 CUST_NBR_MAIN varchar2(50),
11:39:02 3 CONTACT_TYPE varchar2(50),
11:39:02 4 INQUIRY_TYPE varchar2(50),
11:39:02 5 INQUIRY_MODEL varchar2(50),
11:39:02 6 INQUIRY_COMMENTS varchar2(50),
11:39:02 7 OTHER_COLOUR varchar2(50),
11:39:02 8 OTHER_MAKE varchar2(50),
11:39:02 9 OTHER_MODEL_DESCRIPTION varchar2(50),
11:39:02 10 OTHER_MODEL_YEAR varchar2(50)
11:39:02 11 );
Table created.
11:39:13 pavan_Real>select * from test1;
no rows selected
C:\Documents and Settings\ivy3905>sqlldr ara/ara@pavan_real
control = C:\control.ctl
SQL*Loader: Release 9.2.0.1.0 - Production on Sat Sep 12 11:41:27 2009
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Commit point reached - logical record count 5
11:42:20 pavan_Real>select count(*) from test1;
COUNT(*)
5 control.ctl
LOAD DATA
INFILE 'C:\data.txt'
BADFILE 'c:\data.BAD'
DISCARDFILE 'c:\data.DSC' DISCARDMAX 50000
INTO TABLE test1
TRAILING NULLCOLS
CUST_NBR_MAIN POSITION(1:9) CHAR NULLIF (CUST_NBR_MAIN=BLANKS),
CONTACT_TYPE POSITION(10:11) CHAR NULLIF (CONTACT_TYPE=BLANKS),
INQUIRY_TYPE POSITION(12:13) CHAR NULLIF (INQUIRY_TYPE=BLANKS),
INQUIRY_MODEL POSITION(14:20) CHAR NULLIF (INQUIRY_MODEL=BLANKS),
INQUIRY_COMMENTS POSITION(21:60) CHAR NULLIF (INQUIRY_COMMENTS=BLANKS),
OTHER_COLOUR POSITION(61:75) CHAR NULLIF (OTHER_COLOUR=BLANKS),
OTHER_MAKE POSITION(76:89) CHAR NULLIF (OTHER_MAKE=BLANKS),
OTHER_MODEL_DESCRIPTION POSITION(90:109) CHAR NULLIF (OTHER_MODEL_DESCRIPTION=BLANKS),
OTHER_MODEL_YEAR POSITION(110:111) CHAR NULLIF (OTHER_MODEL_YEAR=BLANKS)
data.txt
000000831KHAN
000000900UHFA WANTS NEW WARRANTY ID 000001017OHAL
000001110KHAP
000001812NHDE231291COST OF SERVICE INSPECTIONS TOO HIGH MAXIMA 92 MK
000002015TPFA910115CUST UPSET WITH AIRPORT DLR. $200 FOR PLUGS,OIL,FILTER CHANGE. FW
CUST_NBR_MAIN CONTACT_TYPE INQUIRY_TYPE INQUIRY_MODEL INQUIRY_COMMENTS OTHER_COLOUR OTHER_MAKE OTHER_MODEL_DESCRIPTION OTHER_MODEL_YEAR
000000831 KH AN NULL NULL NULL NULL NULL NULL
000000900 UH FA WANTS NEW WARRANTY ID 000001017OHAL NULL NULL NULL NULL
000001110 KH AP NULL NULL NULL NULL NULL NULL
000001812 NH DE 231291C OST OF SERVICE INSPECTIONS TOO HIGH MAXI MA 92 MK NULL NULL NULL
000002015 TP FA 910115C UST UPSET WITH AIRPORT DLR. $200 FOR PLU GS,OIL,FILTER C HANGE. FW NULL NULL- Pavan Kumar N
Edited by: Pavan Kumar on Sep 12, 2009 11:46 AM -
Sql Loader Data Import Error!!!
Hi,
I have to import a huge volume of records from a CSV(150MB) file to table using sql loader. The input file contains '3286909' records. I am using the following control file and command to run the sql loader.
Control File:
lload data
infile Test.csv
into table TEST_LOAD
fields terminated by ',' optionally enclosed by '"'
ID integer external,
PATH char
*Command:* --------------
C:\CSVFiles\CSV>sqlldr system/tiger control= test.ctl log=test.log readsize=200000000 bindsize=200000000
After running the above command I am able to import '1215717'. Once sql loader reaches this limit then it stops without any error. Somtimes I would get 'SQL*Loader-510: Physical record in data file (test.csv) is longer than the maximum(1048576)'
Please help me to perform this import operation.
Thankshttp://www.morganslibrary.org/reference/externaltab.html
Example:
I have a file on my server in a folder c:\mydata called text.csv which is a comma seperated file...
1,"Fred",200
2,"Bob",300
3,"Jim",50As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS "c:\mydata";
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser;Note: creates a directory object, pointing to a directory on the server and must exist on the server (it doesn't create the physical directory).
As myuser:
SQL> CREATE TABLE ext_test
2 (id NUMBER,
3 empname VARCHAR2(20),
4 rate NUMBER)
5 ORGANIZATION EXTERNAL
6 (TYPE ORACLE_LOADER
7 DEFAULT DIRECTORY TEST_DIR
8 ACCESS PARAMETERS
9 (RECORDS DELIMITED BY NEWLINE
10 FIELDS TERMINATED BY ","
11 OPTIONALLY ENCLOSED BY '"'
12 (id,
13 empname,
14 rate
15 )
16 )
17 LOCATION ('test.csv')
18 );
Table created.
SQL> select * from ext_test;
ID EMPNAME RATE
1 Fred 200
2 Bob 300
3 Jim 50
SQL>
{code} -
I tried inserting data into an empty table in my database but got the following error:
SQL*Loader: Release 11.1.0.6.0 - Production on Tue Jul 7 22:01:35 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL*Loader-350: Syntax error at line 7.
Expecting "," or ")", found "VARCHAR2".
countryname VARCHAR2(25),
^
What is wrong what this please? Find below the contents of .CTL and .DAT files.
Content of load_country.CTL
LOAD DATA
infile '/D:/Data/Load/load_country.dat'
INTO TABLE ASSET.COUNTRY
INSERT
FIELDS TERMINATED BY ';'
(countrycode,
countryname VARCHAR2(25),
population NUMBER(10))
The content of the load_country.DAT file:
BEN;Benin;8791832
BFA;Burkina Faso;15746232
CPV;Cape Verde;503000
Thank you.
Ofonime Essien.Hello,
After solving the Varchar2 problem, I received this error for the NUMBER data type:
SQL*Loader: Release 11.1.0.6.0 - Production on Wed Jul 8 11:47:16 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL*Loader-350: Syntax error at line 8.
Expecting "," or ")", found "number".
population number(10))
^
I replaced the Number data type with Float but received this error:
SQL*Loader: Release 11.1.0.6.0 - Production on Wed Jul 8 11:52:27 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL*Loader-350: Syntax error at line 8.
Expecting valid column specification, "," or ")", found "(".
population Float(10))
^
Replacing Number data type with Integer, I received this error:
SQL*Loader: Release 11.1.0.6.0 - Production on Wed Jul 8 12:17:11 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Control File: D:\Data\Load\tsl.CTL
Data File: D:\Data\Load\c.dat
Bad File: D:\Data\Load\c.bad
Discard File: none specified
(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 C, loaded from every logical record.
Insert option in effect for this table: INSERT
Column Name Position Len Term Encl Datatype
COUNTRYCODE FIRST * ; CHARACTER
COUNTRYNAME NEXT 27 VARCHAR
POPULATION NEXT 10 INTEGER
SQL*Loader-941: Error during describe of table C
ORA-04043: object C does not exist
Thank you so much.
Ofonime.
Edited by: ofonime on Jul 8, 2009 7:09 PM -
SQL*Loader .dat file
Hello I am trying to migrate large quantities of data from our Access database to Oracle. I managed to generate my SQL*Loader scripts in the OMWB directory but when I try to run the .bat file a text doc is generated with the following message:
SQL*Loader-128: unable to begin a session
ORA-01017: Invalid username/password: logon denied
I have tried to match the username/password in both my OEM an OMWB with no success. Please does anybody know where I am going and how it can be rectified. Or should I recreate the user again via OMWB?
Thank you
[email protected]Pilton,
I assume the problem with the username and password which you are using to run.
And one more thing that check the session previleges on the user side.
Hope it will help you.
Ramesh
Hello I am trying to migrate large quantities of data from our Access database to Oracle. I managed to generate my SQL*Loader scripts in the OMWB directory but when I try to run the .bat file a text doc is generated with the following message:
SQL*Loader-128: unable to begin a session
ORA-01017: Invalid username/password: logon denied
I have tried to match the username/password in both my OEM an OMWB with no success. Please does anybody know where I am going and how it can be rectified. Or should I recreate the user again via OMWB?
Thank you
[email protected] -
Pre parse terrible SQL Loader data file
Long story, but I'm on Oracle EBS 11.5.10.2 which means i'm stuck with an SQL Loader from the dark ages (8.06 - yes, I know and yes, it's still supported under EBS).
Anyhow. I have a vendor sending very annoying data. For example:
\|"Fan-Hou" dessert|
\|"Donald is cool | yes”|
\|"Fred “is” cool | yes”|
Due to the limitations of such an old SQL Loader, I need to end up with:
\|"Fan-Hou dessert"|
\|"Donald is cool | yes”|
\|"Fred “is” cool | yes”|
So you can see that really it's only the first row which is causing the issue, I need to shift the quote out to the end of the string (just before the |). The other two lines are just for reference, to show that I get data like that too, and I need to be able to keep that as is.
I have a rather un-elegant solution solution using perl but I'm sure someone out there knows a clever way to achieve the same result. Before you ask - no, the vendor won't change the data.
Edited by: user13007502 on 07-May-2013 01:35There are probably various ways you can do that. I would try the SED command.
The idea is the following:
1. Replace all double quotes of words that start and end with a space with a special character.
2. Remove all all double quotes.
3. Add double quotes to the beginning and end.
4. Reconstruct double quotes of words according to 1.
For instance:
$ cat testfile
|"Fan-Hou" dessert|
|"Donald is cool | yes"|
|"Fred "is" cool | yes"|
Replace double quotes with {} for words that start and end with a space:
sed -i 's: "\(.*\)" : {\1} :g' testfile
$ cat testfile
|"Fan-Hou" dessert|
|"Donald is cool | yes"|
|"Fred {is} cool | yes"|
Remove all double quotes
$ sed -i 's:"::g' testfile
$ cat testfile
|Fan-Hou dessert|
|Donald is cool | yes|
|Fred {is} cool | yes|
Replace all lines that begin and end with | with |" and "|.
$ sed -i 's:^|:|":g' testfile
$ sed -i 's:\(.*\)|:\1"|:g' testfile
$ cat testfile
|"Fan-Hou dessert"|
|"Donald is cool | yes"|
|"Fred {is} cool | yes"|
Finally replace { and } with double qoutes:
sed -i 's:{:":g' testfile
sed -i 's:}:":g' testfile
Here is the result:
# cat testfile
|"Fan-Hou dessert"|
|"Donald is cool | yes"|
|"Fred "is" cool | yes"|
{code} -
SQL Loader, data rejection problem
Hi all ,
I am trying to load data using sql loader.The first field is a long and the rest all are varchar2 and date. After the long datatype is loaded the rest of the data is rejected. What are the possible causes of data rejection by sql loader?
I am pasting the code that is working and the code which is not working( they are two different scenario's)
Working Code:
nl -w10 -s, $4/BookingDetails$3.txt > Book1.txt
echo "LOAD DATA" > booking_det.ctl
echo "INFILE 'Book1.txt'" >> booking_det.ctl
echo "REPLACE PRESERVE BLANKS INTO TABLE booking_det" >> booking_det.ctl
echo "FIELDS TERMINATED BY ','" >> booking_det.ctl
echo "TRAILING NULLCOLS" >> booking_det.ctl
echo "(SLNO, ALL_VALUES CHAR(2000), BOOKING_STATUS, " >> booking_det.ctl
echo "BOOKING_DATE, ACCT_CITY)" >> booking_det.ctl
echo '\n'Invoking SQLLDR ......
sqlldr "$1"\/"$2" silent=ALL errors=100000 control=booking_det.ctl
Code which is not working:
nl -w10 -s, $4/BookingDetails2$3.txt > Book4.txt
echo "LOAD DATA" > booking_det1.ctl
echo "INFILE 'Book4.txt'" >> booking_det1.ctl
echo "REPLACE PRESERVE BLANKS INTO TABLE booking_det" >> booking_det1.ctl
echo "FIELDS TERMINATED BY ','" >> booking_det1.ctl
echo "TRAILING NULLCOLS" >> booking_det1.ctl
echo "(SLNO, ALL_VALUES CHAR(2000), BOOKING_STATUS, BOOKING_DATE)" >> booking_de
t1.ctl
echo '\n'Invoking SQLLDR ......
sqlldr "$1"\/"$2" silent=ALL errors=100000 control=booking_det1.ctl
after inserting all_values in case 2, the rest of the data is not getting loaded in the tmep table.
Please suggest what could go wrong.
TIA
Regards
Ankur
nullHello,
Modify the column and use empty_clob() as default
ALTER TABLE EMP_TABLE
MODIFY(RESUME DEFAULT EMPTY_CLOB());
Your control file should look like this
LOAD DATA
INFILE emp.txt "str '|\r\n'"
INSERT INTO TABLE EMP_TABLE
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS
ID NULLIF (TARGET_ID=BLANKS)
, NAME NULLIF (NAME=BLANKS)
, SALARY NULLIF (SALARY=BLANKS)
, RESUME CHAR(10000)
)Regards
Edited by: OrionNet on Jan 30, 2009 11:56 AM -
SQL Loader Data loading problems.
Hello,
When Loading data using sql loader, the data gets screwed up for the MBRS column alone. In the table, MBRS column is Number(15). Appreciate any suggestions.
Thanks,
SV
Here is the data file
777,MEDICAL,2010,6666666,PPO,ASO,CP,CIGNA,OCT
777,DENTAL,2010,6666666,PPO,ASO,CP,CIGNA,OCT
Control file looks like this
OPTIONS (ERRORS=0,ROWS=50000,READSIZE=20000000,BINDSIZE=20000000)
LOAD DATA
APPEND
INTO TABLE A
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
MBRS integer,
SOURCE char(7)
, YEAR char(4)
, AS char(7)
, CATEGORY char(25)
, FNDG char(25)
, CROLE char(2)
, ALLNCE char(50)
, MONTH char(3)
)i guess eric have provided already a solution in the other thread same as this this posting.
-
Skipping fields in SQL*LOADER data file
I have a data file that has more fields than the target table does. How can I write a SQL*LOADER control file to skip some fields in the middle of the text line?
nullIf you don't want to define input fields by position, the simplest way I think is to use FILLER fields.
Quoted from SQL*Loader doc:
"Specifying Filler Fields
Filler fields have names but they are not loaded into the table. However, filler fields can be used as arguments to init_specs (for example, NULLIF and DEFAULTIF) as well as to directives (for example, SID, OID, REF, BFILE). Also, filler fields can occur anyplace in the data file. They can be inside of the field list for an object or inside the definition of a VARRAY.
See SQL*Loader DDL Behavior and Restrictions for more information on filler fields and their use.
A sample filler field specification looks as follows:
field_1_count FILLER char,
Ex:
Regards,
Zoltan -
Hi,
I am having a problem while loading data from flat file to oracle. The flat file contains date and time in a single field and I want to insert that value into a column in oracle of DATE datatype.
LOAD DATA
INFILE *
INTO TABLE CNTRL_DUAL
APPEND
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
PK INTEGER,
TS DATE "YYYY-MM-DD" TERMINATED BY ',',
ORDER_MONTH6 CHAR,
COUNTRY CHAR,
MONTH_END_DATE CHAR,
UPDATEDBY CHAR,
BEGINDATA
3,2004-08-12 10:35:06.447,199910,CI,19991102,NULL
CREATE TABLE CNTRL_DUAL
PK NUMBER(19) NOT NULL,
TS DATE,
ORDER_MONTH6 VARCHAR2(6 BYTE) NOT NULL,
COUNTRY VARCHAR2(4 BYTE) NOT NULL,
MONTH_END_DATE VARCHAR2(8 BYTE) NOT NULL,
UPDATEDBY VARCHAR2(16 BYTE)
I am facing problems with TS column.
Any help will be appreciated.Hi,
When I change my ctl file
LOAD DATA
INFILE *
INTO TABLE X_ODI_CNTRL_DUAL
APPEND
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
PK INTEGER,
TS DATE(30) "YYYY-MM-DD",
ORDER_MONTH6 CHAR,
COUNTRY CHAR,
MONTH_END_DATE CHAR,
UPDATEDBY CHAR,
STATUS_FLAG CHAR
BEGINDATA
5,2009-07-09,199910,US,19991102,NULL,
2,2004-08-12,199910,AU,19991102,NULL,
3,2004-08-12,199910,CI,19991102,NULL,
8,2007-10-25,199765,CI,20001005,NULL,
the data has been inserted into oracle table but the data in TS column is inserted as:
the year 2009 is being displayed as 0009
PK TS ORDER_MONTH6 COUNTRY MONTH_END_DATE UPDATEDBY STATUS_FLAG
808594485 7/9/0009 199910 US 19991102 NULL
808594482 8/12/0004 199910 AU 19991102 NULL
808594483 8/12/0004 199910 CI 19991102 NULL
808594488 10/25/0007199765 CI 20001005 NULL
In another case when I use my ctl as
LOAD DATA
INFILE *
INTO TABLE X_ODI_CNTRL_DUAL
APPEND
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
PK INTEGER,
TS DATE(30) "YYYY-MM-DD hh24:mi:ss.ff3",
ORDER_MONTH6 CHAR,
COUNTRY CHAR,
MONTH_END_DATE CHAR,
UPDATEDBY CHAR,
STATUS_FLAG CHAR
BEGINDATA
3,2004-08-12 10:35:06.447,199910,CI,19991102,NULL,
the log file output is
Column Name Position Len Term Encl Datatype
PK FIRST 4 INTEGER
TS NEXT 30 , DATE YYYY-MM-DD hh24:mi:ss.ff3
ORDER_MONTH6 NEXT * , CHARACTER
COUNTRY NEXT * , CHARACTER
MONTH_END_DATE NEXT * , CHARACTER
UPDATEDBY NEXT * , CHARACTER
STATUS_FLAG NEXT * , CHARACTER
Record 1: Rejected - Error on table X_ODI_CNTRL_DUAL, column TS.
ORA-01821: date format not recognized
Any help is appreciated.
Maybe you are looking for
-
Why are the fonts so small since I upgraded? I have difficulty reading folder names even when I wear my reading glasses.
-
Problem receiving Mail on Macbook Pro
i just updated my macbook pro and now i can send, but can't receive gmail in mail.
-
Want to learn how to track form referrers? Join us at tomorrow's Power Hour
Tomorrow, Chris Dickey, a Technical Lead at Oracle Marketing Cloud, will host a Power Hour on how to track where contacts are coming from before submitting your form. He'll explain how to achieve this using query strings and a bit of JavaScript. If y
-
Unable to set up wireless printer HP OJ 4680 error OS Windows XP not supported
Trying ro set up my printer for wireles and it is stating my Windows XP OS is not support. Just noticed the Starter CD is for Windows 7. Anyone know what I can do to fix?
-
Is there any way to have an Adobe form display one toolbar without revealing all toolbars? I have a form where the toolbars are hidden on intial view. A user has come to me and requested the use of one toolbar (the Comment and Markup toolbar). I w