Page 1 of 1

how to avoid null value into columns

Posted: Tue Aug 05, 2008 8:02 am
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

Posted: Tue Aug 05, 2008 8:12 am
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

Posted: Tue Aug 05, 2008 8:18 am
by satya99
Write a constraint:

Trim(Source.column_name) <> ''

Good luck

Posted: Tue Aug 05, 2008 8:37 am
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.

Re: how to avoid null value into columns

Posted: Tue Aug 05, 2008 8:48 am
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)<>""

Posted: Tue Aug 05, 2008 4:01 pm
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.

Posted: Tue Aug 05, 2008 9:40 pm
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

Posted: Tue Aug 05, 2008 9:45 pm
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

Posted: Tue Aug 05, 2008 9:50 pm
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

handling null

Posted: Thu Aug 07, 2008 1:34 am
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)

Posted: Thu Aug 07, 2008 7:08 am
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.

Posted: Thu Aug 07, 2008 7:32 am
by pxraja
Hi all,

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