s sarma wrote:
Jeff Verdegan wrote:Sounds like what got saved to the DB was the '\' character and the 'n' character, rather than the actual newline character.
Your choices are:
1. Save the actual newline character to the DB. (How did that data get in there in the first place?)
or
2. Parse the data coming out of the DB and turn '\' + 'n' into the newline character.
Choice 1 is to be preferred.
Jeff,
Thank you for the comments.
Data is coming through a Insert Script . I was inserting String with "\" and "n" and was expecting that it would be recognized by Java as newline characters.
That depends.
If you have
Then, as Paul pointed out, the Java compiler will turn the '\' + 'n' combination in that
string literal into the single newline character in your
String object.
If, on the other hand, your code does something like prompting the user to input some text, and the user types 'a' then 'b' then 'c' then '\' then 'n', etc., then you will have the two separate '\' and 'n' characters int your String.
There's nothing special about the character sequence '\' 'n' in a Java String object. That's only translated to a newline character in a String literal by the compiler, not in String objects in general.
Now, if you do
Then what goes into the DB and what you get back should include the newline character, since it actually was in your String object.
guess i would be using something like CHR(10) while inserting into DB.I guess that should solve the problem.
If it's coming from Java code, then no, you don't need to do that. If there's some other tool you're using to get or generate the string and then insert it, it depends on that tool's rules for special characters.