Page 1 of 1

writing quote (") to a file in a routine

Posted: Wed Aug 24, 2005 11:01 am
by hrthomson
Hello,

We are trying to create a file from a routine and need to write double quotes to it. Does anyone know how to specify quote characters within the DataStage Basic language?


Thanks in advance,

Heather

Posted: Wed Aug 24, 2005 11:08 am
by ArndW
Heather, in DataStage Basic you can use ", ', or / as a quote character interchangeably. So you can assign a double-quote via '"' or /"/ .

Posted: Wed Aug 24, 2005 11:14 am
by hrthomson
Thanks for the quick response...however....

I have the following piece of code, using DOS to pipe a line to a file:

CALL DSExecute('DOS','echo SignonMake ' : '"' : ModelSignon : '"' : ' PromptForPassword False UserId ' : '"' : DBSignonUId : '"' : ' Password ' : '"' : DBSignonPwd : '"': ' >':SignonMDLFile,sResult,sReturnCode)

I get quotes around the first parameter, but none after that. If anyone has any ideas, they would be greatly appreciated.

cheers,

Heather

Posted: Wed Aug 24, 2005 4:51 pm
by ray.wurlod
Try using a function such as Quote or DQuote.

Code: Select all

CALL DSExecute('DOS', 'echo SignonMake ' : Quote(ModelSignon) : ' PromptForPassword False UserId ' : Quote(DBSignonUId) : ' Password ' : Quote(DBSignonPwd) : ' >' : SignonMDLFile, sResult, sReturnCode) 
Beware (search the forum) that passing quoted strings to another shell can cause one level of quotes to be stripped off. If you don't need to capture the result, you may be better off using the PERFORM statement with the DOS verb.

Code: Select all

Command = 'echo SignonMake ' : Quote(ModelSignon) : ' PromptForPassword False UserId ' : Quote(DBSignonUId) : ' Password ' : Quote(DBSignonPwd) : ' >' : SignonMDLFile
PERFORM "DOS /C " : Command

Posted: Wed Aug 24, 2005 7:53 pm
by manojmathai
Hi

You can use char(34) to put double quotes while creating a file from the routine.

For eg : Char(34) : "Tom" : Char(34) will give the out file as "Tom"

Regards
Manoj

Posted: Thu Aug 25, 2005 9:41 am
by hrthomson
Hi

I tried all three of the above suggestions and am still not getting the quotes after the first parameter. Actually, the PERFORM command doesn't do anything.

And we've just discovered that if the parameter value has a space in it, the quotes work, otherwise they're ignored.

So I guess my question is, is there any way to force quotes to a file. I run the same command on the dos prompt, and everything is fine.

Again, thanks for your help.

Heather

Posted: Thu Aug 25, 2005 12:38 pm
by hrthomson
Hi everyone, me again.

I ended up using the OpenSeq command and writing to the file that way. Since this is supposed to be dynamic, I'll simply use the DOS command to pipe to and create an empty file.

Thanks again for your input.

cheers,

Heather