Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Loader put NULL in NCHAR field when it should be blanks

Status
Not open for further replies.

petersJazz

Programmer
Jan 28, 2002
222
EU
In our sql loader scripts we load text files into unicode char fields. In previous version of the software it loaded the same text files into normal char fields and then it loaded blanks into blanks in table. Is this a bug, can the behavior be overwritten somehow?
 

Can you share a piece of the offending controlfile?
What about the column definitions on which the issue happens?
What about the NLS_LANG environment variable, is some type of character type conversion happening?
[ponder]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Thank you for your comment.

Here are some more details:

Command line in unix to do the load is (unix AIX):

sqlldr errors=0 rows=9999 discardmax=1 control=p1.ctl userid=... log=p1.log

p1.dat is the data file, ordinary text file, one line looks like this:

FENIXLR ; ;00;0000001 ; ;00001000; ; ;000000; ;00000;0;A;J;3000001497 ; ;00000000;00100;UQ;00000000;109365;0000000; ; ;00000000;G ;000000;000000;000000; ;100B60003120,26968,1999 ;2; ; ; ; ;00099000;A;AA;00;00;00; ;SEK;000000000.00000;000000000000000;000000; 000000006138000; 000000000000000; ; ; ;FENIXLR 3000001497 ;FENIXLR ;S2102 ;F0010004; ; ;00000000; ; ; ; ; ; ; ;000000;000000; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;000000; ; ; ; ;0000000;00;00; ;000000; ; ; ;00; ; ;000000;SE ;00000000;000000000000000;FENIXLR ; ;FENIXLR ;000000;000000;D; 000000000000000;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00;00; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

And control file p1.ctl looks like this, with my workaround nvl() that I use for the moment to load blank.

LOAD DATA

INFILE '/somepath/p1.dat'

APPEND

INTO TABLE sometable

(VNEDUS POSITION(01:10) char,
VNEDTY POSITION(12:12) char,
...
VNPOST POSITION(154:154) char "nvl:)VNPOST,' ')",
...
VNITM POSITION(1033:1040) char)
 

To prevent whitespace trimming in all CHAR, DATE, and numeric EXTERNAL fields, you specify PRESERVE BLANKS as part of the LOAD statement in the control file.
[thumbsup2]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
hi,

thanks. We have tried that but its not a good idee. We get error messages if we do so for every numeric field.
 


And if you do it only for the text fields?
[3eyes]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Yes, that the work around I described. Thats what we have done. But it takes some time with lots of columns and tables.
 
Using NCHAR fields are not a good idea. Uzse NVARCHAR2 fields and your problem will go away.

Bill
Lead Application Developer
New York State, USA
 
Thank you for the advice but this is a standard system (Oracle EnterpriseOne) and we can not change data types in it. Rather, we can but we dont know that effect that will give. We have now already solved it with the work around so its not much more to say I guess. But, thanks for your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top