Page 1 of 1

How should I use the system variables(@User0-@User4)

Posted: Thu Mar 11, 2004 7:01 am
by maximus
Hi Pals

Few days back I was going thru a discussion in this forum about returning more than one value from a routine.I used to concatenate those value using a delimiter and use the Field function to get them.

Ray had told about the usage of system variables @User0-@User4.So out of curiosity I tried to use them but failed.I would like to know how to use them coz if I give @User0 in the Derivation it is giving a syntax error.And the list of System variable shows @USERNO.

Max

Re: How should I use the system variables(@User0-@User4)

Posted: Thu Mar 11, 2004 7:40 am
by chulett
maximus wrote:Ray had told about the usage of system variables @User0-@User4.So out of curiosity I tried to use them but failed.
Actually, what Ray mentioned was the use of @USER0 - @USER4.

As with practically All Things DataStage, case is very important. If you literally tried using @User0 and got your error, suggest you go back and try using @USER0 instead. It should work much mo' better. :wink: If it still doesn't, come back and post your exact syntax here so we can take a look at it.

Posted: Thu Mar 11, 2004 10:09 am
by RamonaReed
This is how I used the variables in my Server Routine that Ray had mentioned. I hope it helps you.

*** Arg1
*** Arg2
*** Arg3
*** Arg4
*** Arg5
*** Arg6

*** @USER0 = Returned 1st value
*** @USER1 = Returned 2nd value
*** @USER2 = Returned 3rd value
*** @USER4 = Returned 4th value


nDefault = 1


Begin Case
Case Co = 'X'
@USER0 = 'XYZ'
Case Co = 'Y'
@USER0 = 'YZX'
Case Co = 'Z'
@USER0 = 'ZXY'
Case nDefault
@USER0 = Co
End Case

Begin Case
Case Arg6 = 'IM'
@USER3 = 'XXX'
@USER1 = Arg6
@USER2 = Arg3
Case Arg6 = 'UME'
@USER0 = 'XZY'
@USER1 = Arg6
@USER2 = Arg3
@USER3 = Arg5
Case nDefault
@USER3 = Arg5
@USER1 = Arg6
@USER2 = Arg3
End Case

Posted: Thu Mar 11, 2004 12:32 pm
by kduke
@USER variables are sort of global variables. They only work across one connection. So a complex job may not work across the whole job because the way DataStage works. Named COMMON variables have the same problem. Do a search they have both been discussed in detail. Stage variables are a better solution and are more visible to new developers.

Use a hash file to save and retrieve values across jobs or other more complex jobs. Sequential files are also good.

Posted: Thu Mar 11, 2004 10:20 pm
by maximus
As far as the routine is concerned there is no problem...The values are getting stored in the variables(@USER0,@USER1,@USER2) properly...how do I use the values in these variable IN MY JOB...ie how do I assign the value stored in the variable @USER0...coz as I said If I use @USER0 in the derivation in the Tranformer...it doesnt accept it

So can someone clarify as to how I use the variable in the job

Max

Posted: Fri Mar 12, 2004 12:14 am
by ray.wurlod
Yes it does. :lol:

Don't be concerned by the fact that the derivation remains red.
All this means is that the system variables @USER0 through @USER4 are not listed in the DSParams file in the project directory on your DataStage server.

The job will still compile and run correctly.

If the red colour really concerns you, edit the DSParams file and put the names of the system variables in there. 8)

Posted: Fri Mar 12, 2004 7:28 am
by chulett
Interesting. Up to this point, all I've ever done is use them to "pass" information between coordinated routines, so have yet to stumble across the issue of them staying red in the Transformer. Good to know.

I was concerned that the OP was trying to use them exactly as typed in their message and, while I've never actually tried spelling them in mixed case, figured it could be the source of the problem. DataStage can be so picky about stuff like that at times. :lol:

Live and learn.

Posted: Sun Mar 14, 2004 11:12 pm
by maximus
Thanx Ray...So far I have been thinking that if its Red then, it wont compile...thanx for the clarification

Regards
Max

Posted: Mon Mar 15, 2004 11:16 am
by sivatallapaneni
Thanx Ray, ur True GURU
I didnt know it works like that till now.

Have a good one.