• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Comma in db2

 
shiva shankar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
How to insert comma or single quote in db2..suppose I have d'souza as a column how do i insert into sql query in db2
Thanks in advance
Shiva
 
Fred Abbot
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is a d'souza?
Originally posted by shiva shankar:
Hi all
How to insert comma or single quote in db2..suppose I have d'souza as a column how do i insert into sql query in db2
Thanks in advance
Shiva

 
shiva shankar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
d'souza is the coloumn value...sorry for the misinterpretation
 
Fred Abbot
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the escape clause is to put another single quote in from of it similar to \\in java ''
 
shiva shankar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This does not work in db2...that's the problem
shiva
 
Fred Abbot
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happens when you try it?
 
Fred Abbot
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this
public String fixquote(String quotedString) {
String tmp = "";
try {
for(int i = 0; i < quotedString.length(); i++)
if(quotedString.substring(i, i + 1).compareTo("\"") == 0)
tmp = tmp + """;
else
tmp = tmp + quotedString.substring(i, i + 1);
}
catch(Error error) { }
return tmp;
}
 
sudarshan rangarajan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you use PreparedStatement to construct the SQL and later on provide the value for the column using setString() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic