Page 1 of 1

A bug in Dquote function?

Posted: Fri Sep 30, 2011 11:08 am
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.

Posted: Fri Sep 30, 2011 2:37 pm
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.

Posted: Fri Sep 30, 2011 4:24 pm
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,

Posted: Fri Sep 30, 2011 4:29 pm
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.

Posted: Fri Sep 30, 2011 10:37 pm
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.