Modify Usage

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
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Modify Usage

Post by benny.lbs »

As you may know, when convert Decimal to String, a leading space and trailing full stop will exist.

Can Modify stage achieve the convertion without space and full stop?

I know

Code: Select all

E:string[5] = substring[0,5](A)
C:string[7] = string_from_decimal(B)
But when I use the following statement, it failed with

Code: Select all

C:string[7] = substring[1,5](string_from_decimal(B))
main_program: Error parsing modify adapter: Error in binding: Expected ')', got: "("
Is it my syntax error ? How to combine ? Please help

Thanks in advance.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Let me make it even easier for you.

Code: Select all

E:string[7]=string_from_decimal[suppress_zero](A)
The suppress_zero option is not documented anywhere in the Parallel Job Developers Guide but it is in the Orchestrate Operator's reference.
stringField = string_from_decimal[fix_zero][suppress_zero] (decimalField)
Converts decimals to strings.
fix_zero causes a decimal field containing all zeros to be treated as a valid zero.
suppress_zero specifies that the returned ustring value will have no leading or trailing zeros.
Examples: 000.100 -> 0.1; 001.000 -> 1; -001.100 -> -1.1
suppress_zero also gets rid of the leading space and the decimal point. This makes it more useful then the standard string_from_decimal and a handy undocumented flag.
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Post by benny.lbs »

vmcburney,

Thanks your information. If I would like the string with fix_zero case, how to handle ?
vmcburney wrote:Let me make it even easier for you.

Code: Select all

E:string[7]=string_from_decimal[suppress_zero](A)
The suppress_zero option is not documented anywhere in the Parallel Job Developers Guide but it is in the Orchestrate Operator's reference.
stringField = string_from_decimal[fix_zero][suppress_zero] (decimalField)
Converts decimals to strings.
fix_zero causes a decimal field containing all zeros to be treated as a valid zero.
suppress_zero specifies that the returned ustring value will have no leading or trailing zeros.
Examples: 000.100 -> 0.1; 001.000 -> 1; -001.100 -> -1.1
suppress_zero also gets rid of the leading space and the decimal point. This makes it more useful then the standard string_from_decimal and a handy undocumented flag.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Simply add the word surrounded by square brackets in your specification. Add [fix_zero] and/or [suppress_zero].
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Post by benny.lbs »

You mean ?

Code: Select all

C:string[7] = string_from_decimal[fix_zero,suppress_zero](B)
I would like to know how to use fix_zero option, but without leading space and trailing decimal point.

Would you please give me a sample, thanks a lot.
vmcburney wrote:Simply add the word surrounded by square brackets in your specification. Add [fix_zero] and/or [suppress_zero].
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

No, as per the documentation:
stringField = string_from_decimal[fix_zero][suppress_zero] (decimalField)
C:string[7] = string_from_decimal[fix_zero][suppress_zero](B)
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Post by benny.lbs »

Job Aborted.
main_program: Error parsing modify adapter: Error in binding: Expected '(', got: "["
Expected destination field selector, got: ")"; input:
C:string[7] = string_from_decimal[fix_zero][suppress_zero](B)
;
vmcburney wrote:No, as per the documentation:
stringField = string_from_decimal[fix_zero][suppress_zero] (decimalField)
C:string[7] = string_from_decimal[fix_zero][suppress_zero](B)
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Good point! I posted without testing it first. Your original syntax was correct and my correction was incorrect. You should use [fix_zero, suppress_zero] instead of [fix_zero][suppress_zero].
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Post by benny.lbs »

But the result is the same as only [suppress_zero].

e.g.
A Decimal(5,0)

123

I want "00123", not "123" or " 00123."
vmcburney wrote:Good point! I posted without testing it first. Your original syntax was correct and my correction was incorrect. You should use [fix_zero, suppress_zero] instead of [fix_zero][suppress_zero].
Post Reply