Issue with like operator

Hi All,
we are using like operator for search functionality (oracle 10G).
could any one help me in handling null, when we use like operator.
Ex:
select empno,ename,d.deptno
from emp e, dept d
where e.deptno = d.deptno
and e.ename like '%JO%';
we have a text box in the front end to key in employee name (ename) or part of ename. when user doesnt use this option, he leaves it blank.
so In the above query, if ename is null then my query fails.
could anybody help me out in handling this scenario.
My query should still give me all the employee ids, if the ename is blank.
using dynamic sql is not advisable.
Thanks
Manju

Something like this ->
satyaki>select *
  2     from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE    10.2.0.3.0      Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:00.26
satyaki>
satyaki>
satyaki>select *
  2  from emp
  3  where upper(ename) like nvl('%'||upper('&str')||'%',upper(ename));
Enter value for str:
old   3: where upper(ename) like nvl('%'||upper('&str')||'%',upper(ename))
new   3: where upper(ename) like nvl('%'||upper('')||'%',upper(ename))
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
      7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
      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       4450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       7000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
13 rows selected.
Elapsed: 00:00:00.02
satyaki>
satyaki>/
Enter value for str: sa
old   3: where upper(ename) like nvl('%'||upper('&str')||'%',upper(ename))
new   3: where upper(ename) like nvl('%'||upper('sa')||'%',upper(ename))
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
Elapsed: 00:00:00.08Regards.
Satyaki De.

Similar Messages

  • Issue with parallel operation of SAP NW SSO 2.0 and SNC Client Encryption (Logon Groups)

    Hi!
    One of our customers is using the SNC Client Encryption solution to ensure encryption using SNC (based on Kerberos Technology) for their SAP GUI Dialog connections. They have lots of SAP backends DEV, QAS, PRD all with the SNC Client Encryption SNC Lib installed. The profile parameter snc/identity/as contains the following value: p:CN=SAP/<ServiceAccount>@<DOMAIN>.
    Example: p:CN=SAP/[email protected]
    The customer is using one AD Service Account "SNCServiceUser" with one registered SPN "SAP/SNCServiceUser" for all systems (yes, this is not recommended... but the case).
    Important: All users use group entries in the SAP Logon (saplogin.ini). Means, for SAP logon the SNC name can not be manually configured on the SAP Front End. With group logons, the application server's SNC name is dynamically requested by the message server each time a SAP GUI connection is started. The SNC Name is greyed out in this case as dynamically obtained from the applications servers profile parameter snc/identity/as.
    Now our customer implements SAP NetWeaver Single Sign-On 2.0 within his landscape. Based on the Secure Login Server 2.0 (SP3) he likes to use X.509 based authentication to his AS ABAP backends using SAP GUI SNC while others still use SNC Client Encryption.
    Replacing the SNC Library on the AS ABAP
    The Secure Login Library 2.0 (SP3) has been installed on one of the ABAP systems and the SNC Client Encryption SNC Library (which is based on SSO 1.0) is no longer used, thus we changed the parameter snc/gssapi_lib to point to the new SNC library. We removed the old PSE.ZIP containing the keytab and created the new SAPSNCSKERB.PSE incl. the keytab and proper credentials. To ensure parallel operation, we kept the snc/identity/as value as is =  p:CN=SAP/[email protected].
    After restarting the system with initialized Secure Login Library 2.0, still the SNC client encryption works fine for existing users.
    The problem
    We created on the Secure Login Server an SNC certificate for the AS ABAP which has the following X.509 Distinguised Name Fomat: CN=SAP/[email protected] This is to avoid having to change the snc/identity/as to an "real" X.509 DN which would lead to non-working SNC Client Encryption for all the other users using SAP GUI and logon groups.
    As soon as we install the PSE via STRUST on the system the SNC Client Encryption solution stops working with error „Server refuses kerberos key exchange“.
    As part of an pilot implementation we have installed Secure Login Client 2.0 (SP3) on some test PCs. The test PC with SLC is able to perform Single Sign-On with SNC based on X.509 (incl. Encryption) to the ABAP system.
    Seems the SAP System now only tries to do X.509 based authentication thus key exchange fails. The problem is, we cannot change the snc/identity/as value because of the logon groups. If we were able to do so, we would in any case set the server identity to X.509 DN and in addition create the SAPSNCSKERB.PSE incl. keytab. This should work, as confirmed by SAP see this post.  
    Any ideas how to solve this and have both solutions in parallel?
    Appreciate any help.
    Regards,
    Carsten

    Hi all,
    we was able to fix the issue. It was an issue with the customers cluster configuration and the  $SECUDIR variable. This tricky issue leads to non working or sporadic working SNC Client Encryption...
    This was how the configuration looks before:
    Environment variable $SECUDIR is defined:
    "/ABCDEF<SID>/usr/sap/<SID>/DVEBMGSxx/sec“
    sapgenpse seclogin -l -v
    running seclogin with USER="<SID>adm"
    Credentials for username '<SID>adm':
    0 (LPS:OFF):
             (LPS:OFF): /ABCDEF<SID>/usr/sap/<SID>/DVEBMGSxx/sec/SAPSNCSKERB.pse
    1 (LPS:OFF):
             (LPS:OFF): /usr/sap/<SID>/DVEBMGSxx/sec/SAPSNCS.pse
    After changing the $SECUDIR to "/usr/sap/<SID>/DVEBMGSxx/sec“ and re-creating the credentials, it worked like a charm.
    As a result of this we can confirm, this configuration and SNC Client Encryption works with CommonCryptoLib in parallel to the SSO configuration.
    And Valerie was right with 2. SLC starting from V. 1.0 SP2 PL3 was able to convert the CN= part of the SNC Name into an SPN, was my mistake. In addition SNC Client Encryption starting from Version 1 SP1 PL1 does this also.. just to make this clear
    Thread closed hope this helps someone
    Carsten

  • Case Insensitive Search coupled with "LIKE" operator.

    Greetings All, I am running Oracle 11gR1 RAC patchet 25 on Windows X64.
    This db supports and application that requires case insensitive searches.
    Because there are a few entry points into the db I created an "after login" trigger:
    CREATE OR REPLACE TRIGGER MyAppAfterLogon_TRGR
    AFTER LOGON
    ON DATABASE
    DECLARE
    vDDL VARCHAR2(200) := 'alter session set nls_comp=''linguistic''';
    vDDL2 VARCHAR2(200) := 'alter session set nls_sort=''binary_ci''';
    BEGIN
    IF ((USER = 'MyAppUSER') OR(USER = 'MyAppREPORTINGUSER')) THEN
    EXECUTE IMMEDIATE vDDL;
    EXECUTE IMMEDIATE vDDL2;
    END IF;
    END MyAppAfterLogon_TRGR;
    This ensures that everyone connecting to the DB via any mechanism will automatically have case insensitive searches.
    Now, to optimize the know queries I created the standard index to support normal matching queries:
    select * from MyTable where Name = 'STEVE';
    The index looks like:
    CREATE INDEX "CONTACT_IDX3 ON MYTABLE (NLSSORT("NAME",'nls_sort=''BINARY_CI'''))
    This all works fine, no issues.
    The problem is when I write a query that uses the "LIKE" operator:
    select * from MyTable where Name like 'STEV%';
    I get back the record set I expect. However, my index is not used? I can't for the life of me get this query to use an index.
    The table has about 600,000 rows and I have run gather schema stats.
    Does anyone know of any issues with case insensitive searches and the "LIKE" clause?
    Any and all help would be appreciated.
    L

    I think there is issue with your logon trigger :
    "IF ((USER = 'MyAppUSER') OR(USER = 'MyAppREPORTINGUSER')) THEN"
    it should be :
    IF UPPER(USER) = 'MYAPPUSER' OR UPPER(USER) = 'MYAPPREPORTINGUSER' THEN
    because user name stored in Upper case. Check and try.
    HTH
    Girish Sharma

  • Multiple row subquery with like operator

    can any1 give me an example where we can use a multiple row subquery with the like operator.I read it can be used but when i tried it gives the following error
    select * from gagan_emp where ename like (select ename from gagan_emp where deptno=10)
    ERROR at line 1:
    ORA-01427: single-row subquery returns more than one row

    The right part of 'LIKE' is permitted only single value expression
    (including subquery that returns single value),
    is not permitted multiple values.
    -- Examples (but.... not so good)
    select * from gagan_emp e0
    where exists
    (select ename from gagan_emp e1 where deptno=10
    and e0.ename like e1.ename)
    select * from gagan_emp e0
    where exists
    (select ename from gagan_emp e1 where deptno=10
    and e0.ename = e1.ename)
    select * from gagan_emp e0
    where ename = any
    (select ename from gagan_emp e1 where deptno=10)
    select * from gagan_emp
    where ename like
    (select ename from gagan_emp e1 where deptno=10 and rownum=1)
    ;

  • Problem with LIKE operator in select query

    Hi,
    I want to compare one field using LIKE operator. But i m not able to do that.
    DATA: l_doctext type c value ''''.
    CONCATENATE l_doctext s_lbktxt-low '%' l_doctext INTO s_lbktxt-low.
    SELECT bukrs belnr gjahr blart bldat budat xblnr bktxt waers awtyp
                FROM bkpf INTO TABLE g_t_bkpf_labor
                FOR ALL ENTRIES IN g_t_bseg_unique
                WHERE bukrs = g_t_bseg_unique-bukrs
                AND belnr = g_t_bseg_unique-belnr
                AND gjahr = g_t_bseg_unique-gjahr
                AND blart = p_ldtype
                AND bktxt LIKE s_lbktxt-low.
    plz help. Am i dng something wrong.
    Value in s_lbktxt can be like 'TEA.....'

    hi ,
    check this program..
    tables:mara.
    data: begin of it_mara occurs 0,
          matnr like mara-matnr,
          meins like mara-meins ,
          mtart like mara-mtart,
          end of it_mara.
    select-options: s_matnr for mara-matnr.
          select matnr
                 meins
                 mtart
                 from mara
                 into table it_mara
                 where matnr like '%7'.
    sort it_mara by matnr.
    loop at it_mara.
    write:/ it_mara-matnr,
    it_mara-meins,
    it_mara-mtart.
    endloop.
    regards,
    venkat.

  • SQL Query With Like Operator - Performance is very poor - Oracle Apps Table

    Hi,
    I'm querying one of the Oracle Applications Standard Table. The performance is very slow when like operator is used in the query condition. The query uses a indexed column in the where clause.
    The query is..
    select * from hz_parties
    where upper(party_name) like '%TOY%'
    In the above case, It is not using the index and doing full table scan. I have checked the explain plan and the cost is 4496.
    select * from hz_parties
    where upper(party_name) like 'TOY%'
    If I remove the '%' at the begining of the string, the performance is good and it is using the index. In this case, the cost is 5.
    Any ideas to improve the performance of the above query. I have to retrieve the records whose name contains the string. I have tried hints to force the use of index. But it is of no use.
    Thanks,
    Rama

    If new indexes are disallowed, not a lot of good ones, no.
    If you know what keyword(s) are going to be searched for, a materialized view might help, but I assume that you're searching based on user input. In that case, you'd have to essentially build your own Text index using materialized views, which will almost certainly be less efficient and require more maintenance than the built-in functionality.
    There may not be much you could do to affect the query plan in a reasonable way. Depending on the size of the table, how much RAM you're willing to throw at the problem, how your system is administered, and what Oracle Apps requires/ prohibits in terms of database configuration, you might be able to force Oracle to cache this table so that your full table scans are at least more efficient.
    Justin

  • Issue with logical operator using SetEnvIF in OHS

    We have a requirement to set constant value in ssl.conf (OHS) based on Request_URI & referrer. For example, if (Request_URI=/forms/base/login) and (Referer=http://example.com), then we need to set variable value with 1. Similarly we some more conditions. I am trying to use 'SetEnvIf', but it is not allowing to use logical operations (and, or, &, |).
    Can any let us know in resolving issues?

    Just to confuse matters, this problem is intermittent and I haven't been able to successfully replicate it in our Test environment.
    That would seem to indicate something else was going on in the DB that was interfering with the clear, but the logs aren't showing any errors, locks, etc that could have caused the problem.

  • HT5243 Issue with Java operation on printer operation using Shipping software.

    We are running a shipping system from APC couriers using the online booking system, there system runs using Java for the printing but it will not print normally due to a Java issue so has to be printed from another screen, our system has the latest version of Java any suggestions

    4 x 146.8Gb local disks RAID 5 mirrored using the hardware raid controller HP Smart Array 5i+.
    2 Emulex LP10000 HBA cards dual path connected to EMC Symmetrix and IBM DS4800 SAN Storage. There's your problem right there.
    In almost every situation I've encountered as a DBA, RAID5 is slow. Slower than single disk. If you have 4 drives, you're better off doing a RAID10 so that your hardware doesn't have to compute the parity bit. You'll lose 145GB, but you're MUCH better off in terms of performance. RAID5 was meant for file servers and low-load webservers, not high-end databases.
    The only time I've ever seen RAID5 perform acceptably was when we had redo, rollback and the default tablespaces on a different set of disks, and the main data tablespaces on a RAID5. There were very few updates/inserts to the main tablespaces and mostly reads. That's the only time you can use RAID5. But I'd still suggest doing RAID10 and just putting everything on it.
    In general, I also have NOT seen good performance with a SAN. The only time you should use a SAN is when you can't get the capacity you need onto a SCSI channel (or, again, you don't need it to be fast). Otherwise go internal disks on a RAID10 and forget about the SAN. SANs have the disadvantage of having to be shared with a large number of hosts to be cost-effective and shared IO isn't something you want on a high-end database.
    For more information, check this out:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:3322095211375936281::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:359617936136

  • Capital letters issue with 'like'

    Hello
    Maybe it is simple but I cant find solution for this.
    For example I have table pets with column name
    "name" | "category"
    1. Tomcat | cat
    2. tomy | cat
    3. toM | cat
    4. tim | cat
    5. tOmi | cat
    query
    select name from pets where name like '%to%'
    results will give me
    2. tomy
    3. toM
    but i want as results all names wit 'to' no matter if it has capital letters or not
    1. Tomcat
    2. tomy
    3. toM
    5. tOmi
    How should i write this query ?
    please help

    Hi,
    Salski wrote:
    but I also have to remember to convert entered string in inputtext to uppercase as well
    someString.toUpperCase()You can also do that on the back-end, if that's better for you:
    select  name
    from    pets
    where   UPPER (name) like '%' || UPPER (someString) || '%'
    Thanks all for respondGlad to help!

  • PDF issues with new operating system upgrade...

    After upgrading to the newest operating system, pdf files will no longer open when clicking the hyperlinks within webpages. I am able to open the menu and save the file, but it will no longer open automatically with preview or adobe. Any solutions?

    In the Finder, select Go ▹ Go to Folder... from the menu bar. Copy the line of text below into the box that opens, and press return:
    /Library/Internet Plug-ins/AdobePDFViewer.plugin
    If a Finder window open with that item selected, delete it, then quit and relaunch Safari. Otherwise post again.

  • HT201364 issues with updating operating system

    my mac wont update to a newer operating system. i dont know why. its operating now on 10.7.5. i bought the computer refurbished. besides making an appointment and taking it in, what else can i do to get it updated so i can actually use it for what i bought it for... so annoyed by this situation. thanks for any help!!

    To install Mavericks, you need one of these Macs:
    iMac (Mid-2007 or later)
    MacBook (13-inch Aluminum, Late 2008), (13-inch, Early 2009 or later)
    MacBook Pro (13-inch, Mid-2009 or later),
    MacBook Pro (15-inch or 17-inch, Mid/Late 2007 or later)
    MacBook Air (Late 2008 or later)
    Mac mini (Early 2009 or later)
    Mac Pro (Early 2008 or later)
    Xserve (Early 2009)
    Your Mac also needs:
    OS X Mountain Lion, Lion, or Snow Leopard v10.6.8 already installed
    2 GB or more of memory
    8 GB or more of available space

  • Working with LIKE operator

    hi,
    i have a small confusion in escape clause.
    create table products (product_name varchar2(100));
    begin
    insert into products (product_name) values('A%_WQ123');
    insert into products (product_name) values('A%BWQ123');
    insert into products (product_name) values('AB_WQ123');
    commit;
    end;
    select * from products where product_name like '%\%_WQ12%' escape '\';
    output:
    product_name
    A%_WQ123
    A%BWQ123
    can you please tell how this is working,  in the above statment the ESCAPE will escape only % or both %and_
    thanks,

    Are you after this?
    select * from products where product_name like '%\%\_WQ12%' escape '\';
    Cheers,
    Manik.

  • Question with like operator

    create table mytestc(x varchar2(10));
    insert into mytestc values ('18t');
    insert into mytestc values ('4t;8t');
    commit;
    How do I give a select so I can select all the rows where 8t is present
    select * from mytestc where x like '%8t%'
    gives 18t in result set

    Hi,
    user650888 wrote:
    create table mytestc(x varchar2(10));
    insert into mytestc values ('18t');
    insert into mytestc values ('4t;8t');
    commit;Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful.
    Don't forget to post the results you want from that data, an explanation of how you get those results from that data, and the version of Oracle you're using.
    How do I give a select so I can select all the rows where 8t is present
    select * from mytestc where x like '%8t%'
    gives 18t in result setThat's right; '8t' is present in '18t'. That's what you said you wanted. If you would post your desired results and an explanation, then people could help you more.
    Did you mean to say that '8t' has to be a complete item in the ;-delimited list, not a subset of some other string, like '18t' or '8td'?
    In other words, do you mean that you only want to count '8t' as a match when the character before it is a ';' (or when it is at the beginning of x) qnd the character immediately after it is also ';' (or it comes at the end of x)?
    If so:
    WHERE     INSTR ( ';' || x || ';'
               , ';8t;'
               )          > 0The exxpression above will be more efficient than the (otherwise) equivalent:
    WHERE     ';' || x || ';'     LIKE '%;8t;%'This is called the "mother is in chemotherapy" problem.
    Edited by: Frank Kulash on May 24, 2011 4:39 PM

  • I seem to be unable to download Firefox update 36.0 to my Mac (Yosemite); are there any download issues with this operating system?

    I have tried this download several times and after 24 hours or more the only system message I get is "connecting to update server".

    Hello Gibby500, please download and install firefox, follow the next steps:
    1. Download a copy of the latest firefox from http://www.mozilla.org/en-US/firefox/all.html (full dmg package)
    2. '''Trash''' the current Firefox application to do a clean install.
    3. Install the version that you have downloaded.
    Do not select to remove your personal data, your profile data is stored elsewhere in the [http://kb.mozillazine.org/Profile_folder_-_Firefox#Mac Firefox Profile Folder], so you won't lose your bookmarks or other personal data.
    see also: [https://support.mozilla.org/en-US/kb/how-download-and-install-firefox-mac How to download and install Firefox on Mac]
    thank you

  • Like operator issue with on Number column

    Hi,
    Query with like operator for Example: " where RATE LIKE ('%2%')"
    the result of the query returns rows which contains "2" as part of field value along with few rows which are updated recently, but do not contain 2 in that row.
    In the table data type of COLUMN is Number, no precision.
    Pls let me know if any one knows about this.
    --satya.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Can you please post the result of the query you are using?
    Regards

Maybe you are looking for