Null Handling Function on Environment Variable.

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Kel
Participant
Posts: 31
Joined: Mon May 11, 2015 3:20 am
Location: Robinsons Cybergate Tower 2
Contact:

Null Handling Function on Environment Variable.

Post by Kel »

Hi Everyone,

Is it possible to check if an environment variable or a parameter is null? Because on job properties variables dont have nullability option.

Hope you can help me.

Thanks.
BOG
Thomas.B
Participant
Posts: 63
Joined: Thu Apr 09, 2015 6:40 am
Location: France - Nantes

Post by Thomas.B »

Job parameters can't be null, your job will abort if they are.
To check if the parameters are given or not by the main program you can initialize them with a default value and in the job, check for that value. Ex:

Parameter : LPAR_TMP -> Default value : 'NULL'
On a Transformer :

Code: Select all

If LPAR_TMP = 'NULL'
	Then 'The parameter LPAR_TMP is null'
Else 'The parameter LPAR_TMP is not null'
Hope that can help you.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Thomas.B wrote:Job parameters can't be null, your job will abort if they are.
From what I recall that's mostly true, it depends on the data type. Some are required while others (like String) are not. Unless this is something they've changed in recent versions. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I think that using a string "NULL" can be confusing and potentially introduce problems, I prefer something less ambiguous such as "NotDefined" or "Undefined".

NULL handling ranks up there with date/time formatting in my top 10 list of "things that cause problems, but shouldn't". Although I suppose that exactly those issues pay for my lifestyle :)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Aye Matey!

-craig

"You can never have too many knives" -- Logan Nine Fingers
Kel
Participant
Posts: 31
Joined: Mon May 11, 2015 3:20 am
Location: Robinsons Cybergate Tower 2
Contact:

Post by Kel »

Can i use Len($variable) = 0 to validate?
BOG
rkashyap
Premium Member
Premium Member
Posts: 532
Joined: Fri Dec 02, 2011 12:02 pm
Location: Richmond VA

Post by rkashyap »

Yes.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That would have been quicker to just test out for yourself. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply