Rejecting Null records

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

Abhi700
Participant
Posts: 20
Joined: Thu Nov 25, 2010 3:52 am
Location: Pune

Rejecting Null records

Post by Abhi700 »

I had a situation where i have to reject Null records .
The Null records may be with spaces in one row & not having spaces at other.
I had used len(stripwhitespaces(col_name))=0 or isnull(col_name)
but it is rejecting only the column which is having spaces.
So i need to reject both columns which are null's either empty spaces or null value.

Please Suggest!!!!!
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Re: Hadling Null

Post by jwiles »

Perhaps something along the lines of

len(trim(NullToEmpty(column)))

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If this "len(stripwhitespaces(col_name))=0 or isnull(col_name)" only rejects spaces then you don't have any nulls. What is your source?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Abhi700
Participant
Posts: 20
Joined: Thu Nov 25, 2010 3:52 am
Location: Pune

Post by Abhi700 »

My source contains Empty spaces & Nulls in the primary key Columns.
So I have to Handle both to reject.
ABHILASH
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

From your initial post what is meant by "null". whether it is "Empty column with out any space" or "null".

if it is really "null "then your initial logic should work. If not then try with following derivation.

Left(Trim(NullToEmpty(column)),1)=''
Cheers
Ravi K
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Abhi700 - You seem to have missed my point... and still haven't clarified your source - flat file? Database table? Something else entirely?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Abhi700
Participant
Posts: 20
Joined: Thu Nov 25, 2010 3:52 am
Location: Pune

Post by Abhi700 »

My source file is Sequntial file.
And it contains empty spaces & without spaces i.e delimiter without spaces.
I have to reject both of them to rejected data.
For e.g " ,,Abhi,20100101,"
I have to rejecr both the columns
ABHILASH
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

This being the case, you are calling the empty columns (those without spaces) the Nulls? Do your input options convert empty strings to NULLs?

If your columns are set as Nullable=Yes, then check for Len(Trim(NullToEmpty(inputcolumn)))=0. If they are set as Nullable=No, then Len(Trim(inputcolumn))=0 should be sufficient. An variation of these would be: Trim(NullToEmpty(inputcolumn))="", or Trim(inputcolumn)="", respectively.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
Abhi700
Participant
Posts: 20
Joined: Thu Nov 25, 2010 3:52 am
Location: Pune

Post by Abhi700 »

When i am using Trim(Input Col)="" then its working when input col has atleast one empty space.
Actually source row is " ,,abhi ,20100115,".
Then such record should be rejected.
When I am using Trim(Input Col)="".I tried with Trim(NullT0Empty(InputCol))="".
In both the cases record is dropping.
I need the reject to be rejected.
Last edited by Abhi700 on Mon Jan 31, 2011 3:46 am, edited 1 time in total.
ABHILASH
Shruthi
Participant
Posts: 74
Joined: Sun Oct 05, 2008 10:59 pm
Location: Bangalore

Post by Shruthi »

Try this.
StageVar:
If StripWhiteSpace(NullToEmpty(Input Col))<>'' Then If IsNotNull(Input Col) Then 0 Else 0 Else InputCol

Reject in Transformer where StageVar=0

Hope this works!
Abhi700
Participant
Posts: 20
Joined: Thu Nov 25, 2010 3:52 am
Location: Pune

Post by Abhi700 »

StageVar:
If StripWhiteSpace(NullToEmpty(Input Col))<>'' Then If IsNotNull(Input Col) Then 0 Else 0 Else InputCol

Reject in Transformer where StageVar=0
I tried with this.
But my Issue ha not resolved.
As specified in the above error my seq file record is as follows
" ,,Abhi,20100105"
I have to move it to reject link.
Last edited by Abhi700 on Thu Feb 03, 2011 12:30 am, edited 1 time in total.
ABHILASH
Shruthi
Participant
Posts: 74
Joined: Sun Oct 05, 2008 10:59 pm
Location: Bangalore

Post by Shruthi »

Do a view of this sequential file in Seq File Stage. Are these values getting read as NULL or Blanks.

What is the condistion you have given in Transformer.

Can you post your code here.
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Try the below logic once.

StageVar:
If Left(Trim(NullToEmpty(column)),1)='' Then '0' Else '1'

Reject in Transformer where StageVar=0

It may help you.
Cheers
Ravi K
Abhi700
Participant
Posts: 20
Joined: Thu Nov 25, 2010 3:52 am
Location: Pune

Post by Abhi700 »

Do a view of this sequential file in Seq File Stage. Are these values getting read as NULL or Blanks.

What is the condistion you have given in Transformer.

Can you post your code here.
I am getting Nulls if there are no empty spaces i.e delimiter. If there are any empty spaces then it shows as blanks.
ABHILASH
Abhi700
Participant
Posts: 20
Joined: Thu Nov 25, 2010 3:52 am
Location: Pune

Post by Abhi700 »

StageVar:
If Left(Trim(NullToEmpty(column)),1)='' Then '0' Else '1'

Reject in Transformer where StageVar=0

Problem Solved

Thanks to every body
ABHILASH
Post Reply