-1

I used the following statement below:

Trim(IF FromDataSource.PID_VALID = 'Y' THEN FromDataSource.Person_ID ELSE @NULL)
Yogesh Sharma
  • 49,870
  • 5
  • 26
  • 52

3 Answers3

1

Assuming you are using this code within a Transformer stage in DataStage this will help

IF Trim(FromDataSource.PID_VALID) = 'Y' THEN Trim(FromDataSource.Person_ID) ELSE @NULL

Hint: For you next question you might ask in this forum you should provide more details - do not let us guess. Also describe what you have tried and what error you got etc.

MichaelTiefenbacher
  • 3,805
  • 2
  • 11
  • 17
0

You can use case expression :

(CASE WHEN FromDataSource.PID_VALID = 'Y' THEN TRIM(FromDataSource.Person_ID) END)

else will return null if condition evaluate as false, you don't need to specify null.

Yogesh Sharma
  • 49,870
  • 5
  • 26
  • 52
0

If you want to set null if PID is not valid then->

IF FromDataSource.PID_VALID = 'Y' THEN trim(FromDataSource.Person_ID) ELSE setnull()

If you want to set empty when PID is not valid then->

IF FromDataSource.PID_VALID = 'Y' THEN trim(FromDataSource.Person_ID) ELSE ''

Chinmay
  • 11
  • 1