• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1682
  • Last Modified:

Apostrophes break my query?

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.
  • 2
1 Solution
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.
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 - Production
With the Partitioning option
JServer Release - 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;
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;

**            **  here they are!

Hope this answers everything okay!  
Let me know how it works for you!
rickyrAuthor Commented:
Answer accepted
rickyrAuthor Commented:
Thanks, see my new Q about loging users out!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now