Solved

Apostrophes break my query?

Posted on 2000-05-16
4
1,672 Views
Last Modified: 2008-02-26
Hi......
I'm using Perl-DBI to extract data from Oracle.
My selects and inserts have apostrophes in them.
This breaks my sql statement with...........
"quoted string not properly terrminated."
help, the same happens when I try and escape the \' in sqlplus.
cheers
0
Comment
Question by:rickyr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Expert Comment

by:davdonin
ID: 2813965
If you want an apostrophe inside of your statemnt you have to double them, e.g: 'this ''is a'' string with ''apostrophes'''.
Hope this helps.
0
 
LVL 9

Accepted Solution

by:
dbalaski earned 50 total points
ID: 2814010
Hi,  
Pretty easy to do this,  two methods outline

Method #1 Use double apostrophes inside  the string to insert:
example:  (All done in a database for verification of results)

Connected to:
Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production

SQL> create table test (field1  varchar2(200));
Table created.
     
** note the double '' in the field1 insert statement

SQL> insert into test values ('Radha''s Database');
1 row created.

SQL> commit;

SQL> select * from test;
FIELD1
---------------------------
Radha's Database
        **  here it is

Second Method:   Say you want to encapsultate a value in apostrophes from a table,   use character string 39 appended to the field.  Example:
SQL> select chr(39)||name||chr(39) from v$database;

CHR(39)||NA
-----------
'RADHA_T1'
**            **  here they are!

Hope this answers everything okay!  
Let me know how it works for you!
dB
0
 
LVL 3

Author Comment

by:rickyr
ID: 2945728
Answer accepted
0
 
LVL 3

Author Comment

by:rickyr
ID: 2945729
Thanks, see my new Q about loging users out!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question