Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 10th, 2006, 05:47 AM
mantai007 mantai007 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 290 mantai007 User rank is Corporal (100 - 500 Reputation Level)mantai007 User rank is Corporal (100 - 500 Reputation Level)mantai007 User rank is Corporal (100 - 500 Reputation Level)mantai007 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 3 h 48 m 33 sec
Reputation Power: 6
Strings with string's

im trying to select something that has an Apostrophe in it, for example word.title = 'didn't'
so is there a way in SQL to quote the whole thing without getting an error?

Reply With Quote
  #2  
Old May 10th, 2006, 06:14 AM
sr sr is offline
Problem Solver
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jan 2001
Location: Stockholm, Sweden
Posts: 3,051 sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 17 h 3 sec
Reputation Power: 178
What you do is that you quote the apostrophe.
Code:
... LIKE 'som\'ing'


And if you use PHP then you can use the mysql_real_escape_string() function and it will quote all characters that can cause an error for you.
__________________
/Stefan

Reply With Quote
  #3  
Old May 10th, 2006, 06:29 AM
mantai007 mantai007 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 290 mantai007 User rank is Corporal (100 - 500 Reputation Level)mantai007 User rank is Corporal (100 - 500 Reputation Level)mantai007 User rank is Corporal (100 - 500 Reputation Level)mantai007 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 3 h 48 m 33 sec
Reputation Power: 6
err

'Electrician\'s book'

get: ORA-01756: quoted string not properly terminated

Reply With Quote
  #4  
Old May 10th, 2006, 06:36 AM
r937's Avatar
r937 r937 is online now
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 18,339 r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 h 45 m 46 sec
Reputation Power: 1090
the reason you got an error is that you tried to run some syntax which works in mysql but doesn't work in oracle

the reason you got that mysql syntax is because you posted your question in the mysql forum!!

in oracle, you must use two consecutive single quotes
Code:
'Electrician''s book'
incidentally, that also works in mysql, and in fact, that's the standard sql way to do it

i will move your thread over to the oracle forum
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon

Reply With Quote
  #5  
Old May 10th, 2006, 06:38 AM
sr sr is offline
Problem Solver
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jan 2001
Location: Stockholm, Sweden
Posts: 3,051 sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 17 h 3 sec
Reputation Power: 178
You din't mention that you where using Oracle and since this is a MySQL forum that is rather important to mention because the DB's differ in syntax.

Use double apostrophe in that case:
Code:
... LIKE 'som''ing'


When they are grouped together like that they will be considered as one in the string.

Reply With Quote
  #6  
Old May 10th, 2006, 07:18 AM
mantai007 mantai007 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 290 mantai007 User rank is Corporal (100 - 500 Reputation Level)mantai007 User rank is Corporal (100 - 500 Reputation Level)mantai007 User rank is Corporal (100 - 500 Reputation Level)mantai007 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 3 h 48 m 33 sec
Reputation Power: 6
oh sorry, i thought oracle was mySQL... ive just started learning.

so whats the difference between the 2?

Reply With Quote
  #7  
Old May 10th, 2006, 07:52 AM
sr sr is offline
Problem Solver
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jan 2001
Location: Stockholm, Sweden
Posts: 3,051 sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level)sr User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 17 h 3 sec
Reputation Power: 178
Quote:
Originally Posted by mantai007
oh sorry, i thought oracle was mySQL... ive just started learning.

Then you have a lot to learn my friend.

Quote:
Originally Posted by mantai007
so whats the difference between the 2?

Over 49,000 employees and they are as similar as David and Goliath regarding company size, revenue and technology.

Reply With Quote
  #8  
Old May 10th, 2006, 07:55 AM
r937's Avatar
r937 r937 is online now
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 18,339 r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 h 45 m 46 sec
Reputation Power: 1090
that's like saying "oh, i thought the lada was the same as the ferrari"

they are both cars ...

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Strings with string's


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT