If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > special character handling

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-05-04, 13:12
rongfu84 rongfu84 is offline
Registered User
 
Join Date: Mar 2004
Posts: 4
Question special character handling

hi ppl out there

mi using java, do anyone know how to handle special character for sql?
doing a project and need help.. thanks alot..
Reply With Quote
  #2 (permalink)  
Old 03-05-04, 13:43
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
I guess I don't understand what you mean by "special character" (to me that means certain ASCII values that cause things to happen, like EOL, etc). Can you explain a bit more for me???

-PatP
Reply With Quote
  #3 (permalink)  
Old 03-06-04, 12:50
rongfu84 rongfu84 is offline
Registered User
 
Join Date: Mar 2004
Posts: 4
Question special character handling in sql

hi

for example, i type select * from user where user='o'connor';
o'connor is actually one of the data in the database.
when that query is submited, it return a error:
Error: Syntax error (missing operator) in query expression 'user ='o'conner';'. (State:37000, Native Code: FFFFF3E4)

thanks
Reply With Quote
  #4 (permalink)  
Old 03-06-04, 15:27
ss659 ss659 is offline
Registered User
 
Join Date: Jan 2004
Posts: 492
Re: special character handling in sql

Quote:
Originally posted by rongfu84
hi

for example, i type select * from user where user='o'connor';
o'connor is actually one of the data in the database.
when that query is submited, it return a error:
Error: Syntax error (missing operator) in query expression 'user ='o'conner';'. (State:37000, Native Code: FFFFF3E4)

thanks
For single quotes in a string use 2 single quotes together:

EX:

'o''connor'

Note: This is 2 SINGLE quotes, and not 1 double quote.
Reply With Quote
  #5 (permalink)  
Old 03-07-04, 00:11
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
So then you mean characters that SQL uses for special purposes, such as the apostrophe? Different dialects of SQL treat different chacters as "special", so you'll really have to read the documentation for the SQL engine that you are using, and follow it's guidlines for how to handle them.

-PatP
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On