Inserting into a not null column.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
psriva
Participant
Posts: 44
Joined: Fri Aug 11, 2006 8:40 am

Inserting into a not null column.

Post by psriva »

Can Datastage insert spaces into a column defined as NOT NULL?
I tried to insert space in a column defined as not null but the job fails.
ps
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

What's the target database and loading method? Most bulk loaders default to assuming a single space into a CHAR type target column should be interpreted as a NULL. There's switches you need to set to alter that behavior. More information please.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

This is not a datastage issue but rather the type of database. I have, in the past, inserted space in not null columns in a SqlServer table.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Nah... I'd wager it's a settings issue as Ken notes. You usually have to tell your process to 'PRESERVE_BLANKS' in some fashion otherwise they typically get stripped. Then your space gets turned into an empty string and blows the NOT NULL constraint.

More information please. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
psriva
Participant
Posts: 44
Joined: Fri Aug 11, 2006 8:40 am

Post by psriva »

The target database is Oracle and the write_method=load. The target column is defined as not null.

My input file consists of:

record nullable
{final_delim=none, record_length=fixed, record_delim_string='\n', delim=none, quote=none}
(
code:not_nullable string[1] {width=1};
)

I get an error saying inserting null into a not null column.

Please let me know if you need more info. Thanks
ps
psriva
Participant
Posts: 44
Joined: Fri Aug 11, 2006 8:40 am

Post by psriva »

Where can you set the preserve blanks option.
ps
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It's one of the many APT environment variables, from what I recall.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kwwilliams
Participant
Posts: 437
Joined: Fri Oct 21, 2005 10:00 pm

Post by kwwilliams »

APT_ORACLE_PRESERVE_BLANKS. Its under the Operator Specific environmental variables.
psriva
Participant
Posts: 44
Joined: Fri Aug 11, 2006 8:40 am

Post by psriva »

Thank you all of you, very very much. By setting that environment variable to TRUE, my job works fine.

Thanks again.
ps
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Time to mark your post as "Resolved". :)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
bonds
Premium Member
Premium Member
Posts: 15
Joined: Thu Aug 16, 2007 12:34 am
Location: Australia

Size in DB

Post by bonds »

DSguru2B wrote:Time to mark your post as "Resolved". :)
Hello All,

I have found that using APT_ORACLE_PRESERVE_BLANK = True option also Pads blank spaces behing the passed string.

i.e. eventhough i pass only 5 characters to a field defined as Varchar 30, in database it is actually stored as 30 instead of 5.

Database: Oracle
Wrtite Mode: LOAD -> Replace

Please suggest how to resolve this issue.

Thank You

Satish
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.

Procedural Note
We do not hijack threads. For a new topic, we start a new thread.
Please do so.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply