aspose file tools*
The moose likes Java in General and the fly likes Escaping Sequence problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Escaping Sequence problem." Watch "Escaping Sequence problem." New topic
Author

Escaping Sequence problem.

Harish Chandra Durgapal
Greenhorn

Joined: Mar 01, 2006
Posts: 14
Hi All,
Last time I really stuck with a simple String initilization problem..
I have initilise a String variable with a large sql query as follow.....

String query="select rpad('WS'||substr(h.wdcode,1,7),15) wdcode,
rpad('S'||substr(d.brandcode,1,4)||decode(b.unitsperpack,5000,5,7000,1,10000,2,12000,3,6000,4,0),15) brandcode,
rpad(to_char(h.secsaledate,'"WEEK1M"MMYYYY'),15)docdt,
rpad('CL12',15) trntype,lpad(to_char(sum(d.retailer),'999999999'),15) qty
from basis.dp_secsaleheader h, basis.dp_secsaldetail d, basis.brandmstr b
where h.secsaleheadercode = d.secsaleheadercode and d.secsalecategorycode=1 and b.company='GPI' and d.brandcode = b.brandcode and to_number(to_char(h.secsaledate,'DD')) <=7 and h.secsaledate >= to_date'01092006','DDMMYYYY') and h.secsaledate <= to_date('30092006','DDMMYYYY')and d.retailer>0 and substr(h.wdcode,1,2) ='02' group by rpad('WS'||subst(h.wdcode,1,7),15),rpad('S'||substr(d.brandcode,1,4)||decode (b.unitsperpack,5000,5,7000,1,10000,2,12000,3,6000,4,0),15),
rpad(to_char(h.secsaledate,'"WEEK1M"MMYYYY'),15),
rpad('CL12',15)"
This gives me a error String literal is not properly closed by double quote.
Can any one guide me how to initilise this query to a String variable.
Thanks
harish.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Is this all on one line, or are those line breaks really in your code? You have to have it all on one line in the code. I also can't tell if you have actual double quotes inside the String or not; if you do, then you need to put a "\" backslash before each one.


[Jess in Action][AskingGoodQuestions]
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3646
    
  15
If I were you I'd build the statement using a StringBuffer/StringBuilder. It will make it a lot easier to maintain.
e.g.


As Ernest said, there's probably some double quotes in there which you will need to escape.

[ October 04, 2006: Message edited by: Joanne Neal ]
[ October 04, 2006: Message edited by: Joanne Neal ]

Joanne
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

And I would put linebreaks and tabs into the sql, to make debugging more convenient:

How readable is that?
[ October 04, 2006: Message edited by: Stefan Wagner ]

http://home.arcor.de/hirnstrom/bewerbung
Harish Chandra Durgapal
Greenhorn

Joined: Mar 01, 2006
Posts: 14
Hi Ernest,Joanne,Stefan

Thanks a lot .It solved my problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Escaping Sequence problem.