select statement in Transformer Stage

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

sarathi
Participant
Posts: 27
Joined: Thu Feb 11, 2010 4:14 pm
Location: Minneapolis

select statement in Transformer Stage

Post by sarathi »

Can we pass StageVariable into Select statement in Transformer Stage..

Here is what i am looking to pass to LOC VARIABLE

LOC = SELECT searchcode from LOCATIONS
WHERE searchcode like STAGEVARIABLE

Any help appreciated

Sarathi
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Is LOC target field?
You are the creator of your destiny - Swami Vivekananda
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Is LOC target field?
You are the creator of your destiny - Swami Vivekananda
sarathi
Participant
Posts: 27
Joined: Thu Feb 11, 2010 4:14 pm
Location: Minneapolis

Post by sarathi »

Yes LOC is target field
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Then yes possible

Code: Select all

LOC = 'SELECT searchcode from LOCATIONS WHERE searchcode like ' : STAGEVARIABLE
You are the creator of your destiny - Swami Vivekananda
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm curious how you are planning on executing your 'select statement in a Transformer stage'. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
sarathi
Participant
Posts: 27
Joined: Thu Feb 11, 2010 4:14 pm
Location: Minneapolis

Post by sarathi »

LOC = 'SELECT searchcode from LOCATIONS WHERE searchcode like ' : STAGEVARIABLE

This is not working. It's taking as string and passing...

Craig- Do u have solution for this. I appreciate your help


Sarathi
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Craig would not know what solutions U does or doesn't have.

The second person personal pronoun in English is spelled "you", not "u".


How are you using a SELECT statement in a Transformer stage? The Transformer stage does not connect to external data sources.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sarathi
Participant
Posts: 27
Joined: Thu Feb 11, 2010 4:14 pm
Location: Minneapolis

Post by sarathi »

Hi

Sorry about mis-pronouncation.
Can it be done by Sub-routines like DSRoutines.
I am not particular that it should be done in Transformer stage.
Any type of solution for this issue will be appreciated.

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

Post by chulett »

That's the problem, we don't know what the "it" is you are trying to do, what "issue" it is you are trying to solve. About I all see if you are trying to build a string of dynamic SQL, which by itself is a pretty trivial undertaking but after that... ??

How about you explain what problem you are trying to solve? Forget DataStage, forget the whole 'select statement in a transformer' thing, just let us know where this all started and where you're trying to go.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Use a parameter. Your whole SQL can be #jpMySqlStatement#.
Mamu Kim
sarathi
Participant
Posts: 27
Joined: Thu Feb 11, 2010 4:14 pm
Location: Minneapolis

Post by sarathi »

Let me explain to you in brief....

Need to CALL SELECT ...LIKE VARIABLE IN Transformer/Applicable Stage.I declared VARIABLE as STAGE VARIABLE.

Value of VARIABLE = If LOCATION LIKE 'Technology Center' Then 'BACKUP ' Else 'TTCE' else If LOCATION LIKE .........

I am using '%Technology Center%' to check for LIKE condition in IF statement.

Let me know if you need additional information.

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

Post by chulett »

Ummm... yes. And I'd prefer you explained completely rather than briefly, briefly is just extending the pain. :?

You keep using the word "select" - is there a database involved in this derivation somewhere? Are you needing to pull information from a table using SQL or is this just a simple "if-then-else" field derivation? Doing the like and the % wildcards is fine for something like Oracle but has no place in a transformer derivation... unless (as I asked before) you are trying to dynamically build some SQL and then somehow execute that in a database elsewhere for some still unknown purpose.

In other words, the picture remains unclear as to what it is that you need to accomplish. Please re-read the last paragraph in my previous post and let's try this again.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sarathi
Participant
Posts: 27
Joined: Thu Feb 11, 2010 4:14 pm
Location: Minneapolis

Post by sarathi »

I needing to pull information from a table using SQL in which uses field variable from "if-then-else" derivation. Using the % wildcards in If-then-else.

SELECT A From B where A LIKE 'VARIABLE'

VARIABLE= If LOCATION LIKE 'Technology Center' Then 'BACKUP ' Else 'TTCE' else If LOCATION LIKE .........

I was trying to do in Transformer stage but could not succeed.

Hope this Helps

Sarathi
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

A Transformer stage can not access a data source.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply