how to use isnull

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
chooi
Participant
Posts: 19
Joined: Wed Jan 26, 2005 8:33 pm

how to use isnull

Post by chooi »

Hi all,
if i use isnull function in ETL on a numeric field?it will hit the error?Urgent one. Please help!!!
nick.bond
Charter Member
Charter Member
Posts: 230
Joined: Thu Jan 15, 2004 12:00 pm
Location: London

Post by nick.bond »

IsNull() Will only return true if the value provided is null, it doesn't matter what data type the field is.
Regards,

Nick.
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
It might help to state the expression you use and the exact error you get so we might give a more helpfull reply.
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The IsNull() function can take any data type as its argument, and returns 1 (= true) if the argument is null, or 0 (= false) if the argument is not null.

The only time you can get an error - which is actually a warning - is if you try to use an unassigned variable as the argument. This can happen because of a spelling or casing error. In the following example the two variable names (Amount and amount) are different.

Code: Select all

FUNCTION AddTax(Amount, TaxRate)
If IsNull(amount)
Then
   Ans = @NULL
End
Else
   Ans = Amount * (1 + TaxRate / 100)
End
RETURN(Ans)
In this case you get a warning about an unassigned variable, referring to the "amount" variable.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
arun_im4u
Premium Member
Premium Member
Posts: 104
Joined: Mon Nov 08, 2004 8:42 am

Post by arun_im4u »

The isnull function can be used to reject rows in the transformer. Use the IsNull() to reject rows which have null value. The syntax would be:

If IsNull(column_name) then REJECTED else Not(REJECTED).
Post Reply