Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Apostrophes break my query?

Posted on 2000-05-16
4
Medium Priority
?
1,680 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
  • 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

876 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