Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • 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.
 
Those are the largest trousers in the world! Especially when next to this ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!