common variables

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
spracht
Participant
Posts: 105
Joined: Tue Apr 15, 2003 11:30 pm
Location: Germany

common variables

Post by spracht »

Can somebody please enlighten me on common variables, especially their visibilty and lifecycle. What I understand, is that they are something like global variables.

Where can they be used, in batch jobs and/or routines?

Where are they visible? presumably only in those batch jobs / routines that directly descent from the one where they were first declared. Or even ouside of them?

How long do they exist? Do they disappear, as soon as the batch /routine ends, where they were first declared?

What are they typically used for?

Thanks in advance!

Stephan
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Stephan

There are a couple of common variables. They can be named or not. The best way is named common. There are examples of named common variables in the SDK. If you telnet into your server and at TCL type in HELP BASIC then you will see a lot of commands not very well documented. The goal of DataStage is not to expose you to all of the functionality of the underlying engine because it is going away. If you need the syntax then I will send it but basically you give your group of variables a name. You list each variable you want to share. The values are passed between each subroutine or program which has this same named common. The variable list has to exactly match between each program. This is sort of a short cut to adding a whole bunch of variables to the argument list.

The most often used solution to using a named common is because you want a store values from one record to the next. Say you have a running total and you call a routine which has a named common with just one variable the running total. You can use this total in a dariavation by having the routine return this value. You need some way to reset the total to zero if the total has a grouping to it like the customer number changes. You need to use it before you reset it.

A named common is only active for one session. If 2 users call the same routine then they maintain their own separate copies of this named common because they each have their own connection to the database. What Ken pointed out recently is that one job can create multiple connections to the database becuase there are more than one primary input sources. The job is multi-threaded within itself. All the primary inputs start at the same time. The job will wait for all of these to finish only if they have a single stage that all of them link to.

source1 -> transform1 -> target1
source2 -> transform2 -> target2

These have no stages both are linked to so they function as totally independant streams.


source1 -> transform1 ->
target1 -> transform3 -> target3
source2 -> transform2 ->


transform3 waits for both streams until both source 1 and 2 are done.

A named common will not be shared between source1 and source2.

Kim.

Kim Duke
DwNav - ETL Navigator
www.Duke-Consulting.com
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Note also that variables declared to be in a COMMON area of memory (which is not the same thing as shared memory) are only accessible within a single process. That is not the same thing as a job; for example, such a variable can be accessible from a before-stage subroutine, within routines called from a Transformer stage that called that before-stage subroutine, and in an after-stage subroutine called from that Transformer stage. However, a COMMON variable declared in a before-job routine is not accessible from a Transformer stage, because the job and the stage run in separate processes.
For this and other reasons variables in COMMON are sensible only for server jobs and job control routines. They can not be used in parallel jobs and they can not be used in mainframe jobs.

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
spracht
Participant
Posts: 105
Joined: Tue Apr 15, 2003 11:30 pm
Location: Germany

Post by spracht »

Kim, Ray

thank you very much, indeed, for your explanations. I really appreciate them.

Kind Regards

Stephan
spracht
Participant
Posts: 105
Joined: Tue Apr 15, 2003 11:30 pm
Location: Germany

Post by spracht »

Kim

when you state:

"If you telnet into your server and at TCL type in HELP BASIC then you will see a lot of commands not very well documented. The goal of DataStage is not to expose you to all of the functionality of the underlying engine because it is going away"

does this mean that the functionality won't be available in the future, and to what extent? What about existing jobs and when is this going to happen? Was it worth the effort to print out the BASIC guide and starting to read it [:(]?

Kind Regards

Stephan
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Stephan

Probably Ray or Ken need to answer this but some of this functionality is already gone in PX. From what I hear it may take several years to completely change over. Maybe by then most of this will be available.

Kim.

Kim Duke
DwNav - ETL Navigator
www.Duke-Consulting.com
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

I'm not commenting on the future of the underlying BASIC engine or Server jobs.

Kenneth Bland
Post Reply