Home » SQL & PL/SQL » SQL & PL/SQL » *Another* single quotes question
*Another* single quotes question [message #19472] Thu, 21 March 2002 00:27 Go to next message
Psy
Messages: 2
Registered: March 2002
Junior Member
Hi,

I am trying to write an Oracle SQLPlus script that accepts a string from the user and searches for that string in a table. The problem is that if you put a single quote in the string Oracle dies.

I am starting the script in SQLPlus like this:

SQL> start script.sql searchstring

And the script looks something like:

SELECT *
FROM table
WHERE column LIKE '&1';

The problem is that if you make the searchstring search'string, you get errors. Is there any way to get around this?

Cheers.
Re: *Another* single quotes question [message #19479 is a reply to message #19472] Thu, 21 March 2002 05:17 Go to previous messageGo to next message
Shekar
Messages: 25
Registered: August 2000
Junior Member
are u saying that you have a single quote(') as part
of your input? if that is the case then you should add
an extra single quote(') next to the input single quote
then oracle would understand that the first single quote is part of the input.

try it out.

- Shekar
Re: *Another* single quotes question [message #19490 is a reply to message #19479] Thu, 21 March 2002 13:18 Go to previous message
Psy
Messages: 2
Registered: March 2002
Junior Member
Thanks for your reply.

That works, but I want to be able to have one single quote in the input (E.g. "SQL> start script.sql inputwith'aquote") and change that to two single quotes in the code (E.g. "SQL> start script.sql inputwith'aquote" equates to &1 (parameter 1) being "inputwith''aquote").

I suppose my question is can Oracle do this? I don't want users to have to type in two single quotes when they only want one ...
Previous Topic: Comma delimited flat file
Next Topic: OO4o and Paging
Goto Forum:
  


Current Time: Thu Mar 28 05:00:01 CDT 2024