how to set different values forsamecoloumn in different rows

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

Post Reply
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

how to set different values forsamecoloumn in different rows

Post by scorpion »

hi all,

can any one please help me how to set the values of columns for different rows.

i.e.

i need to set a output column value for first row is(default to "x") and from second row onwards(>first row) the value of the same coloumn should be (default to "y")

how can i perform this.

thanks in advance,
Thanx&Regards
scorpion
kcshankar
Charter Member
Charter Member
Posts: 91
Joined: Mon Jan 10, 2005 2:06 am

Post by kcshankar »

Hi,
Try @Outrownum/@Inrownum function to get required output.

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

Post by ArndW »

Use a stage variable in a transform stage. You can either use a initial value that is changed after the first row or a condition which checks the @INROWNUM/@OUTROWNUM as kcshankar suggested to assign the column value depending upon which row is processed.
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

hi kcs/ArndW

thanks for your replies,can you please help me out detail syntax.

Example:

for "empno" coloumn, i need to display the value for first row is "x"
and for remaining rows (>1st row),i need to display the value is "y"

can you please give me exact syntax to define in stage variable for above(emp)scenario...

thanks a lot in advance.......
Thanx&Regards
scorpion
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Come now. :?

First off, a stage variable seems overkill for something as simple as this. All you need to do is check @OUTROWNUM to see if it is one or greater than one and set the value in the derivation of the column accordingly.

Are you saying you can't work out the "If Then Else" syntax?
-craig

"You can never have too many knives" -- Logan Nine Fingers
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

Thanks! Chullet,

Tried "if then else" with @OUTROWNM in derivation of Transformer,it is working fine.

i need default value for a ouput coloumn like

"Employee= " : link.coloumnname: " , Dept=S_CODE"

Note: link.coloumnname is the value of one input coloumn

so i need display in an output coloumn value like:

"Employee= "inputcoloumnvalue",Dept=S_CODE"

i tried a lot but giving in some other way....
can you please helpme on this...
Thanx&Regards
scorpion
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

When you are working inside the Derivation editor, there is an 'ellipsis' or three little dots like this (...) that you can click on for help building expressions. One of the operators it offers you is concatenation and in DataStage the concatenation operator is the colon or ':' sign.

You build up combinations of strings and link values by concatenating them together with the colon:

Code: Select all

"Employee= " : link.columnname : ",Dept=S_CODE"
Which just so happens to match what you posted, so (theoretically) should mean it worked just fine for you and you don't actually have a problem after all. :wink:

So what "didn't work" when you tried that syntax? Please be as complete and clear as possible, with examples if at all possible.
-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 »

It looks as if you used a bad variable name, is it took the value as a literal instead of as a variable name. Please follow Craig's advice and use the drop-down boxes to insert the correct variable name.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Hmmm... odd. What if you just put in, for test purposes,

"If @OUTROWNUM =1 Then 1 Else DSLink3.PermissionID" and see if that works?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You never actually said anything about it generating an error. I just got the impression that your output wasn't quite what you expected. :?

I'm still not clear on exactly what you are expecting as output. Are the double-quotes supposed to actually be in the field when all is said and done? If that's the case, you'll need to use a combination of single quotes around the outside of the strings so the double-quotes inside the strings just become data.

If that's not the error you are trying to solve, then I'm obviously still confused.
Last edited by chulett on Sun Feb 26, 2006 11:38 am, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

hey Thanks alot Chullet,

it is working fine...i need to display "(double quotes)in the field value..
as you said i append single quotes before and after the values...

now i got the required out put value...

output is an .csv file but when i open in wordpad i found 3 double quotes synbols instead of one double quotes symbols..why?
Thanx&Regards
scorpion
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Check Field default in Format Tab. The Quotes might be double. Place it Null if you require or just remove the option.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

scorpion wrote:output is an .csv file but when i open in wordpad i found 3 double quotes synbols instead of one double quotes symbols..why?
More than likely because you have quote delimited string fields in the file with quotes in the field. Then you have to 'quote the quote' in order for it to not confuse things. The important thing is - can the resulting file be read properly by whatever application it is destined for?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply