0

I would like to know if when I place a sql query using java , does it retain the new lines?

for instance if i have

"IF EXISTS (SELECT * FROM mytable WHERE EMPLOYEEID='"+EMPID+"')"+
"UPDATE myTable SET ....)"

So after the "+" sign in the first line the UPDATE follows, does it maintain the new line when it is being passed to the database?

Thank you

2 Answers 2

4

No. For the query to work successfully you will have to add a space before UPDATE or after ).

Sign up to request clarification or add additional context in comments.

Comments

1

Firstly, there is no newline in the example source code to "maintain" ...

Secondly, your problem is with Java rather than SQL. You will only get an newline into a Java String if you put it there explicitly; e.g.

// No newline in this string
String s = "a" + 
    "b";

// Line break in these strings
String s = "a" + "\n" + "b";
String s2 = "a\nb";
String s3 = "a" + System.getProperty("line.separator") + "b";

Finally, in your example, a space or TAB will do just as well as a line break.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.