sqlldr - datatype [message #540841] |
Thu, 26 January 2012 03:05  |
 |
nago
Messages: 10 Registered: January 2012
|
Junior Member |
|
|
hi,
there is no problem as such. But i just want to make sure that i am in right direction. please suggest me.
my oracle table having 2 fields.
filed1 VARCHAR(500)
field2 NUMBER.
i load data to this table from a file using sqlldr.
what is the proper data type should i use in control-file for both the fields.? could you suggest ?
rightnow, i dont mention any datatye in ctl file which is working fine with given dataset.
thank you
nago
|
|
|
|
|
|
|
Re: sqlldr - datatype [message #540943 is a reply to message #540841] |
Thu, 26 January 2012 11:48   |
 |
Barbara Boehmer
Messages: 9104 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
nago wrote on Thu, 26 January 2012 01:05hi,
there is no problem as such. But i just want to make sure that i am in right direction. please suggest me.
my oracle table having 2 fields.
filed1 VARCHAR(500)
field2 NUMBER.
i load data to this table from a file using sqlldr.
what is the proper data type should i use in control-file for both the fields.? could you suggest ?
rightnow, i dont mention any datatye in ctl file which is working fine with given dataset.
thank you
nago
In most cases, Oracle will attempt to match the data to the data type of the column that you are loading into and do an implicit datatype conversion. However, if you do not specify a length, the default is 255. So, for your first field, you need CHAR(500). For the second field, if you want to be more exact, then you could use FLOAT EXTERNAL. It might be slightly more efficient with big loads.
|
|
|
Re: sqlldr - datatype [message #540945 is a reply to message #540849] |
Thu, 26 January 2012 12:04   |
 |
Barbara Boehmer
Messages: 9104 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
nago wrote on Thu, 26 January 2012 02:40how should i ignore the entire record if any of the column having null values ?
i want sqlldr to ignore that record and proceed with rest of records into the tables.
-nago
Use when field1 != '' and field2 != '' after your into table clause. Rejected rows will go to the discard file if there is one, so make sure you set the discardmax high enough.
Alternatively, you can put not null constraints on your fields and set the errors to a number high enough that it will not be exceeded. Rejected rows will go to the bad file if there is one.
[Updated on: Thu, 26 January 2012 12:10] Report message to a moderator
|
|
|
|
|
|
Re: sqlldr - datatype [message #547140 is a reply to message #547135] |
Wed, 12 March 2008 15:22   |
 |
Barbara Boehmer
Messages: 9104 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
If your nom_enf is varchar2(100), then you do not need to use char(500).
If the following line is intended to replace \n with a chr(10) linefeed:
"replace(:NOM_ENF,'\n',chr(10))"
then you need to add an extra \ to escape and treat the \ as a character:
"replace(:NOM_ENF,'\\n',chr(10))"
Can you post some rows that get rejected without specifying char(500)? It might also help to have the row before and after that row. If the problem is length, then it may not be perceiving the end of the field or record where it should. I noticed that, although you are using " as the enclosure character, you also have " within your data. Although doubling the quotes seems to allow it to be processed correctly in the sample data that you provided, that may not be the case for all rows. It might be causing it to try to combine multiple fields or rows, thus exceeding the expected length. You might need to load the rows as is, without the optionally enclosed by, then trim the leading and trailing quotes and replace the doubled ones, like so:
NOM_ENF "replace (rtrim (rtrim (ltrim (replace(:NOM_ENF,'\\n',chr(10)), '\"'), chr(13)), '\"'), '\"\"', '\"')"
It might help to specify your linefeed character for your datafile, to clarify where the record ends, for example:
infile 'F_ENF.dat' "str X'0A'"
So, I would suggest the following for your control file:
load data
characterset AR8MSWIN1256
infile 'F_ENF.dat' "str X'0A'"
badfile 'F_ENF.bad'
into table F_ENF
TRUNCATE
fields terminated by X'3b'
(
ID_ENF ,
NOM_ENF "replace (rtrim (rtrim (ltrim
(replace(:NOM_ENF,'\\n',chr(10)),
'\"'), chr(13)), '\"'), '\"\"', '\"')"
)
|
|
|
|
Re: sqlldr - datatype [message #547260 is a reply to message #540945] |
Tue, 13 March 2012 11:08   |
Amine
Messages: 376 Registered: March 2010
|
Senior Member |

|
|
Here is the environement to test :
F_ENF.sql
drop table F_ENF
/
create table F_ENF
(
ID_ENF number(3) ,
NOM_ENF varchar2(500)
)
/
F_ENF.dat
198;pppppp pp ppppp pppppp pppp ppp (01)¡ pp pppp ppp ppppp pppp ppppp pppp ooooooo oooooo mmmmmmmmm mmmmmmm zzzzzzz/zzzzz¡ zzzz uuuuuu yyy 2010/350/pop/ii/Ó ertyui az 2010.07.29.\\n- azert rtyu ertyui poiuyt azer tyu (01) poiuyt er 2011.09.19 ¡ tyui poiuyt azer 2011/549/apo/i1/Ó polgtr po 2011.10.03.;|
200;\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n;|
F_ENF.ctl
load data
characterset AR8MSWIN1256
infile 'F_ENF.dat' "str x'7C0A'"
badfile 'F_ENF.bad'
into table F_ENF
TRUNCATE
fields terminated by X'3b'
(
id_enf ,
nom_enf "replace (rtrim (rtrim (ltrim (replace(:nom_enf,'\\n',chr(10)), '\"'), chr(13)), '\"'), '\"\"', '\"')"
)
F_ENF.bat
sqlldr my_user/pwd@utf8 control=F_ENF.ctl log=F_ENF_log_insert.log errors=9999999 rows=10000
I've changed the .ctl file as you mentioned.
- The "optionally enclosed by" was cut,
I've changed the .dat file as you mentioned.
- I've specified "|" to be the linefeed character,
The results are the same I've got.
Try to specify the data type for NOM_ENF for example to char(500) and the rows will be loaded.
You can check the NOM_ENF length for the two rows : it's 300 and 435 respectively.
The data to be inserted seem to be non valid (multiple chr(10)) but we don't care about the validity of the data, we insert it as it is.
Thank you in advance,
Amine
|
|
|
|
|
|
|
|
|
Re: sqlldr - datatype [message #549461 is a reply to message #547317] |
Fri, 30 March 2012 12:26  |
 |
Sticker Printing
Messages: 7 Registered: March 2012 Location: USA
|
Junior Member |
|
|
Since your column length is 250 and some of your data is that long, then you do need the char. I don't see why that should be slowing things down, so I don't know of a way to speed that up. The only things that I can suggest are general things
|
|
|