Solved

Apostrophes break my query?

Posted on 2000-05-16
4
1,667 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
Comment Utility
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
Comment Utility
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
Comment Utility
Answer accepted
0
 
LVL 3

Author Comment

by:rickyr
Comment Utility
Thanks, see my new Q about loging users out!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
oracle- 10.2.04 3 42
Oracle Syntax 8 37
SQL Retrieve Values 4 39
scheduler for Procedure in DB with 3 arguments in 10g 7 7
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…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
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.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now