setNull() output in Char(1) data type

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
Amar_nath
Participant
Posts: 56
Joined: Tue Apr 18, 2006 5:03 am

setNull() output in Char(1) data type

Post by Amar_nath »

Hello All,
I am working on IIS 8.1 and source & target database is MS SQL server.

I have one flag in target table with data type char(1). I want to set value NULL when it is not Y or N. I am achieving using -

If ( monitoring_flag != 'Y' and monitoring_flag != 'N')
Then SetNull()
Else monitoring_flag

When I check in database I can see empty cell for this flag and not NULL.

:?: What should be done to achive the same?

Thanks & Regards.
Amar_nath
Participant
Posts: 56
Joined: Tue Apr 18, 2006 5:03 am

Post by Amar_nath »

Sorry the logic in transformer is as below -

If ( monitoring_flag <> 'Y' and monitoring_flag <> 'N')
Then SetNull()
else monitoring_flag
manoj_23sakthi
Participant
Posts: 47
Joined: Tue Feb 23, 2010 12:16 am
Location: CHENNAI

Re: setNull() output in Char(1) data type

Post by manoj_23sakthi »

Hi,
you can obtain this using this
If ( monitoring_flag <> 'Y' or monitoring_flag <> 'N')
Then SetNull()
else monitoring_flag
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Use OR instead of AND

Regards
Sreeni
Amar_nath
Participant
Posts: 56
Joined: Tue Apr 18, 2006 5:03 am

Post by Amar_nath »

Hi All,

Something which is unclear to me.. bit strange ..

If (len(trim(monitoring_flag)) = 0 or Seq(monitoring_flag) = 0)
Then SetNull()
else monitoring_flag

this works fine .. gives NULL in output
but when I check

If IsNull(monitoring_flag)
Then SetNull()
else monitoring_flag

it gives spce in that flag .. i.e. ASCII 32.. I donno why .. any suggestions ?
veerabusani185512
Participant
Posts: 11
Joined: Fri Jan 30, 2009 3:21 am

Try this one

Post by veerabusani185512 »

If ( trim(nulltoempty(monitoring_flag)) ='Y' or trim(nulltoempty(monitoring_flag)) = 'N')
Then monitoring_flag else setnull()
Post Reply