how to avoid null value into columns

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

how to avoid null value into columns

Post by pxraja »

Hi all,

I am trying to avoid null values for Name field, I am doing simple transformation from oracle database to another oracle database through an ODBC-->TRF-->ODBC.

can anyone suggest me to avoid null values in NAME Field(Varchar).

Thanks in Advance
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

You didnt specify your requirement clearly, Avoiding Null in Names when writing to target or selecting from Source..

If it is target, In the transformer, for the name column write the derivation like If Len(Trim(InputLink.Name)) = 0 Then 'DEFAULT' Else InputLink.Name.

If it is in source, select * from Table where NAME IS NOT NULL
satya99
Participant
Posts: 104
Joined: Thu Nov 30, 2006 1:22 pm

Post by satya99 »

Write a constraint:

Trim(Source.column_name) <> ''

Good luck
satya
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

"Avoid" how? Don't insert the record? Convert the null to something else? First task is detection with IsNull (typically) then either constrain or transform based on the result.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dineshrk
Participant
Posts: 46
Joined: Thu Jun 26, 2008 9:14 pm

Re: how to avoid null value into columns

Post by dineshrk »

pxraja wrote:Hi all,

I am trying to avoid null values for Name field, I am doing simple transformation from oracle database to another oracle database through an ODBC-->TRF-->ODBC.

can anyone suggest me to avoid null values in NAME Field(Varchar).

Thanks in Advance

Try giving in constraint in the transformer the following piece of code

Not(isNull(Trim(Namefield)) and Trim(Namefield)<>""
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Avoid = don't select them in the first place (as DS_SUPPORT suggested). If you still need the rows in which NAME is null, perhaps your query could convert NULL to an in-band value, or you can do this within the job design.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

Post by pxraja »

Hi all

Thanks for your suggestions, I dont want to pass the NULL value to the target because target column is key column. I had created target database in oracle whose key column is NOT NULL and its a primary key.

then i simply transformed the input link to output. Its not accepting the NULL (obviously) and I am getting REJECTED rows which is having NULL values. Is this approach is GOOD if the source is going to be large
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

Post by pxraja »

Hi all

Thanks for your suggestions, I dont want to pass the NULL value to the target because target column is key column. I had created target database in oracle whose key column is NOT NULL and its a primary key.

then i simply transformed the input link to output. Its not accepting the NULL (obviously) and I am getting REJECTED rows which is having NULL values. Is this approach is GOOD if the source is going to be large
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

Post by pxraja »

Hi all

Thanks for your suggestions, I dont want to pass the NULL value to the target because target column is key column. I had created target database in oracle whose key column is NOT NULL and its a primary key.

then i simply transformed the input link to output. Its not accepting the NULL (obviously) and I am getting REJECTED rows which is having NULL values. Is this approach is GOOD if the source is going to be large
sankarguru
Participant
Posts: 6
Joined: Thu Aug 07, 2008 12:49 am
Location: Chennai

handling null

Post by sankarguru »

Hi,

Use NVL function in the query itself if u want substitute any value for null.The other way we have is If(Len(Trim(field)) returns true if the field is not null.(in datastage transformer)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

pxraja wrote:then i simply transformed the input link to output. Its not accepting the NULL (obviously) and I am getting REJECTED rows which is having NULL values. Is this approach is GOOD if the source is going to be large
No, this is never a "good" approach. Use a constraint to ensure these rows never go to the database. Up to you where they do go, including nowhere.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

Post by pxraja »

Hi all,

Thanks for your suggestions, I had used the constraint and its working.
Post Reply