Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Safe to allow ' character in varchar fields?
On Wed, 03 Feb 1999 12:49:58 GMT, adrianh_at_globalnet.co.uk (Adrian Harrison)
wrote:
>I have a request by users to allow ' in varchar2 fields
>
>At the moment I stop them entering this character as it's used to denote strings
>
>Is it safe to allow it to be saved in to these fields or not?
Yes.
>
>Also how would you do an SQL wild card search on field that contain wildcard characters?
>Is this the way to do it "select * from mytable where mycol like '%%'; ?
You need to define an escape character.
eg.
SQL> select * from t;
ID TEXT
---------- -------------------- 1 %ljkgldjgl 1 sdfsd%sdfsd
SQL> select * from t where text like '/%%' escape '/';
ID TEXT
---------- -------------------- 1 %ljkgldjgl
hope this helps.
chris.
>
>Thanks
>
>Adrian Harrison
--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.