Home » SQL & PL/SQL » Client Tools » Like clause (Oracle, 10g,Windows 2003 server)
Like clause [message #434448] Wed, 09 December 2009 05:26 Go to next message
getritesh
Messages: 235
Registered: July 2006
Location: INDIA
Senior Member

Hi,
how to introduce & in wild search as shown below


SELECT *
FROM emp
WHERE ENAME LIKE '%JPMORGAN & CO&';


Here oracle takes "&" in '%JPMORGAN & CO&' as Substitution variable.I want oracle to take whole as a search string


Regards,
Ritesh
Re: Like clause [message #434451 is a reply to message #434448] Wed, 09 December 2009 05:37 Go to previous messageGo to next message
ramoradba
Messages: 2454
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
SQL> select * from emp;

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7369 &sriram    CLERK           7902 17-DEC-80        800                    20
      7499 &sriram    SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10

14 rows selected.

SQL> set scan on
SQL> select * from emp
  2  where ename like '%&sri%';
Enter value for sri:

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7369 &sriram    CLERK           7902 17-DEC-80        800                    20
      7499 &sriram    SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10

14 rows selected.

SQL> set scan off
SQL> select * from emp
  2  where ename like '%&sri%';

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7369 &sriram    CLERK           7902 17-DEC-80        800                    20
      7499 &sriram    SALESMAN        7698 20-FEB-81       1600        300         30

SQL>


set scan off

sriram
Re: Like clause [message #434453 is a reply to message #434451] Wed, 09 December 2009 05:40 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
SET SCAN is obsolete

Use SET DEFINE OFF
Re: Like clause [message #434465 is a reply to message #434448] Wed, 09 December 2009 06:01 Go to previous messageGo to next message
getritesh
Messages: 235
Registered: July 2006
Location: INDIA
Senior Member

Hi,
thanks for reply

i want to use this in stored procedure and that stored procedure is going to get called in microsoft sharepoint.

There i cant use
SET DEFINE OFF

Please suggest me some alternate solution


Regards,
Ritesh Tidke

{Mod Edit: Altered case of final statement so that OP is not SHOUTING!]

[Updated on: Wed, 09 December 2009 06:07] by Moderator

Report message to a moderator

Re: Like clause [message #434472 is a reply to message #434465] Wed, 09 December 2009 06:10 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
The substition takes place on the client side (SQL*Plus for example). Which sort of client/driver do you use to connect to Oracle from sharepoint?
Re: Like clause [message #434474 is a reply to message #434465] Wed, 09 December 2009 06:12 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why have you any problem with & in microsoft sharepoint?
Anyway, you should better post your question in such a forum, I think you will have more answers than in a specific Oracle one.

Regards
Michel
Re: Like clause [message #434493 is a reply to message #434472] Wed, 09 December 2009 06:43 Go to previous messageGo to next message
getritesh
Messages: 235
Registered: July 2006
Location: INDIA
Senior Member

i work on oracle 10g client
Re: Like clause [message #434494 is a reply to message #434474] Wed, 09 December 2009 06:45 Go to previous message
getritesh
Messages: 235
Registered: July 2006
Location: INDIA
Senior Member

i got your point, thanks
Previous Topic: Connect to Oracle 7 from Oracle 10g
Next Topic: PL/SQL Developer : how to execute a sql script
Goto Forum:
  


Current Time: Sat Dec 03 19:56:41 CST 2016

Total time taken to generate the page: 0.05637 seconds