A bug in Dquote function?

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
mctny
Charter Member
Charter Member
Posts: 166
Joined: Thu Feb 02, 2006 6:55 am

A bug in Dquote function?

Post by mctny »

Have any of you guys experienced that the DQuote function is not working properly inside a parallel transformer?

here "is not working properly" means that it is introducing extra escape characters. For example

mylink.mycolumn value is ABC"",""EFG

when I use Dquote(mylink.mycolumn) to enclose it in double quotes, and the desired output should be

"ABC"",""EFG"

however I am getting

"ABC\"\",\"\"EFG"

I noticed this after wasting 1 day and then finally I removed the Dquote function and instead I am using '"':mylink.mycolumn:'"' now.

here '"' is double quote inside single quotes.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It's not a bug. You've asked it to enclose a string in double-quotes and it found some double-quotes inside the string so they were escaped. It has no idea you intend to treat this as (in essence) two distinct comma separated fields.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mctny
Charter Member
Charter Member
Posts: 166
Joined: Thu Feb 02, 2006 6:55 am

Post by mctny »

That is exactly waht I do NOT want. I did not intend to treat it as two fields, I intend it to treat one field. It is coming as one field and I want it to leave the transformer as one field. I just want the incoming field enclosed in double quoted, that's all. I think that is the definition of this function

This is taken from the DataStage documentation ,

DQuote
Encloses a string in double quotation marks.
v Input: string (string)
v Output: result (string)
v Examples. If mylink.mystring1 contains the string needs quotes, then the following function
returns the string "needs quotes".
DQuote(mylink.mystring1)

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

Post by chulett »

Then forget my whole assumption as to what you want, it was a guess on my part based on what the end result you wanted looked like. Still doesn't change my answer - in order to have quotes of the same type inside a quoted string, the internal quotes must be escaped. Nothing more than that going on.

Your solution is the appropriate one here, add them manually.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There are two conventions when quoting strings that contain the quote character - either double them or escape them. So if the source data were ABC"",""EFG as you stated, the two possible results are "ABC"""",""""EFG" or "ABC\"\",\"\"EFG" when they are quoted. DataStage engineers have gone with the latter approach, probably because they're all C programmers and most from UNIX rather than Windows backgrounds.
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