Hi all,
I saw a routine with the code like this
If InputArg = '' Then
Call DSLogWarn('InputArg is required.' , c_routineName ); Return
End
v_OPID = '100'
v_logFolder = 'dir'
Ans=v_OPID
IN THIS IF MY INPUT ARGUMENT IS NULL WHAT WILL HAPPEN.
WHAT DOES THE RETURN STATEMENT DO?
WILL IT RETURN BACK TO LINE V_OPID
CAN'T I USE VARIABLES WITH OUT DECLARING.
Return function in datastage routine
Moderators: chulett, rschirm, roy
Put any code you are curious about into a 'test' routine in the Administrator and then use the Test functionality there. You may have trouble checking for empty parameters there, so for testing sake change it to check for a recognizable string:
If InputArg = 'empty' Then Call DSLogWarn...
As to the "Can't I use variables without declaring" question - yes. Their first use instantiates them.
ps. posting in ALL CAPS is considered SHOUTING, please use your inside voice here.
If InputArg = 'empty' Then Call DSLogWarn...
As to the "Can't I use variables without declaring" question - yes. Their first use instantiates them.
ps. posting in ALL CAPS is considered SHOUTING, please use your inside voice here.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
If the input argument is NULL then it is not equal to "".
But if it is "" then it will execute taht code and exit the routine. The RETURN statement should read RETURN({value}) to be correct, though
But if it is "" then it will execute taht code and exit the routine. The RETURN statement should read RETURN({value}) to be correct, though
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Or if this is not the complete routine and the code that you have shown is part of a subroutine then Return will pass the execution back to the calling block. I still dont get the semicolon, is that correct systax guys?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Yes, the semicolon is used to put multiple commands on one physical line of source code. I use it all the time for commenting inline:
Code: Select all
a = 1 ;** set the value of "a" to 1
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Whenever creating routines that some other induhvidual may call, you need to check for three forms of invalid argument - unassigned, null and otherwise invalid.
Code: Select all
If UnAssigned(Arg1) Or IsNull(Arg1)
Then
RETURN(@NULL) ; * return immediately
End
If Arg1 = "" ; * for example
Then
Ans = @NULL
End
Else
* Here Arg1 is OK to keep processing
End
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.