Home » SQL & PL/SQL » SQL & PL/SQL » Finding a character in a string
Finding a character in a string [message #345066] Tue, 02 September 2008 04:15 Go to next message
matpj
Messages: 115
Registered: March 2006
Location: London, UK
Senior Member

Hi all,

my use of the search function returned no results for this, surprisingly.
I need to flag up when a field contains the character ';' (semicolon)
Can anyone help me with this?

I am using Oracle 10g

Thanks in advance,
Matt
Re: Finding a character in a string [message #345068 is a reply to message #345066] Tue, 02 September 2008 04:20 Go to previous messageGo to next message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
I need to flag up when a field contains the character ';' (semicolon)??

I am not able to understand this.

please follow ./fa/1707/0/

Regards,
Rajat

Re: Finding a character in a string [message #345070 is a reply to message #345066] Tue, 02 September 2008 04:23 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
where col like '%;%'

Regards
Michel
Re: Finding a character in a string [message #345077 is a reply to message #345066] Tue, 02 September 2008 04:39 Go to previous messageGo to next message
durgadas.menon
Messages: 365
Registered: December 2007
Location: Nowhere
Senior Member
I believe he is trying to avoid sql injection...so no user can enter data which contains characters like ';', 'and', 'or' to exploit weak coding and wreak the system.

try things like this

SQL> declare a varchar2(20) := 'durgadas;menon'; b number; begin 
select instr(a,';') into b from dual; if b is not null then dbms_output.put_line('DANGER'); else dbms_output.put_line('CLEAR'); end if; end;
  2  /
DANGER

PL/SQL procedure successfully completed.


Re: Finding a character in a string [message #345078 is a reply to message #345077] Tue, 02 September 2008 04:43 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
All versions
INSTR(field,';') >0 

10g +
REGEXP_LIKE(FIELD,';')
Previous Topic: Ms-access and oracle connection
Next Topic: Need Query
Goto Forum:
  


Current Time: Fri Dec 09 13:26:03 CST 2016

Total time taken to generate the page: 0.10571 seconds