DataStage BASIC functions with variable number of arguments

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

DataStage BASIC functions with variable number of arguments

Post by ArndW »

I recall having programmed my own functions with variable numbers of parameters in the past and am faced with a situation here where being able to do that would save large amounts of run-time; but I can't recall how I did it and haven't found anything on the web about this. Does anyone here know how this might be accomplished?

Thanks in advance,
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Can't remember either, but there's always the array as an argument trick.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I suppose that might be an option - but in my case I'd be calling this function from a transform stage and we can't put DIM statements to allocate an array; a dynamic array might work but would be quite unwieldy in this case. I think if I can't get a variable number of arguments sorted out I'll have to resort to something completely different.

I think making a variable number of options involved a special declaration in the code or the compiler options; and then you had to use ASSIGNED() to figure out which arguments had been passed into the function. And all the internal programs which I might use to see what they had done have been compiled with the -I option so that they cannot be VLISTed :(
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What about creating the routine as taking a fixed number of parameters and then putting a series of transforms over the top of it that take your 'variable number of arguments'. The transform could default / hard code the 'unused' parameters in that case. :?
-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 »

Craig,

that's a good approach, I like that idea and hadn't approached it from that angle. But in this it wouldn't work because of the extra performance overhead, this routine gets called ~100 Million times per day so I am trying to tweak performance out of the common call. I found that by adding/removing just 2 parameters the CPU overhead gets changed by over 10%.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Interesting... good luck with that. :wink:

Seriously, let us know what you come up with.
-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 I might steer away from variable number of arguments even if I do get an answer; since it is most likely not fully documented. I think I will now have one routine with 12 parameters called one time per stage to set up all the environment, then for each of the ~100million daily rows will call the "real" function with just 2 parameters.
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I think Ken was referring to the ol' dynamic array as an argument trick. (Indeed, you can use any delimited string, but a field-mark delimited dynamic array gives you more flexible parsing options as well as the hint mechanism for extra speed.)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Arnd

I think the trick is in VB when you call a routine. I think it is easier there.
Mamu Kim
Post Reply