quote problem

quote problem

Post by mmarcuc » Sun, 25 Mar 2001 04:51:20



does anyone have a fix quotes method that returns a "\" before
all occurences of a "'". would this be the correct way to insert
a work with a single quote into a database?
 
 
 

quote problem

Post by Davide Bianch » Sun, 25 Mar 2001 08:13:52




Quote:> does anyone have a fix quotes method that returns a "\" before
> all occurences of a "'". would this be the correct way to insert
> a work with a single quote into a database?

If you use PreparedStatement instead of the "normal" statement,
all the required subsitution are done automatically for you.
See PreparedStatement in the Java documentation.

Davide

 
 
 

quote problem

Post by Xin Zhan » Sun, 25 Mar 2001 06:49:23


Hi,

  In oracle, "'" is represented by "''".

Xin


> does anyone have a fix quotes method that returns a "\" before
> all occurences of a "'". would this be the correct way to insert
> a work with a single quote into a database?

================================================================================
   !!!!!!!!!!!!!!!!!!!!!!!!!! God Bless You !!!!!!!!!!!!!!!!!!!!!!!!!!!!
Xin Zhang                               Computer Science Graduate Student

Office: 319 Fuller Labs                 Worcester Polytechnic Institute
Home Tel/Fax:   797-3150                100 Institute Road
Office Tel:     831-5857                Worcester, MA 01609
================================================================================
 
 
 

quote problem

Post by Thomas Muelle » Sun, 25 Mar 2001 17:57:50


\ is not a escape character in SQL. To use a ' inside '....', you have to
use two '. Using PreparedStatement is a good idea. If you don't want to do
that, here's a function:

  static String createString(String s) {
    StringBuffer b=new StringBuffer().append('\'');
    if(s!=null) {
      for(int i=0,len=s.length();i<len;i++) {
        char c=s.charAt(i);
        if(c=='\'') {
          b.append(c);
        }
        b.append(c);
      }
    }
    return b.append('\'').toString();
  }

Thomas

 
 
 

quote problem

Post by mmarcuc » Mon, 26 Mar 2001 12:06:44


thanks for the help!!
 
 
 

quote problem

Post by Heinz Hube » Tue, 27 Mar 2001 15:18:40



> thanks for the help!!

I'd go for the PreparedStatements, since not only single quotes have to
quoted somehow. Some drivers interpret other special characters, too.

Regards,
Heinz

 
 
 

1. Single quote Problem

Hi All,
From Visual Basic if I want to store a name in Informix, that a single
quote charecter, then how do i do so.
The problem comes up when I try to do the following

myname="abc's"
execute("Insert into Names(name) values("'" & myname & "'");

Thanks.

Regards,
Joseph Verghese

2. San Antonio, TX Progress GUI Opportunity

3. Error in isql (quoting problem?)

4. Oracle 8 jdbc oci with IBM's JDK 1.1.8

5. single quote problem

6. isql command giving me strang errors

7. Double quotes problem

8. database develop

9. FW: Single Quote Problem

10. Quote problem

11. Single quote problem when replicating...

12. Double-quote problem over ODBC

13. Single Quote Problem