EJB QL "LIKE" OPERATOR NIGHTMARE

i want to pass input parameter to my ejb ql.
it will look like this :
"SELECT OBJECT(p) FROM EntityBeanTable p WHERE p.Title LIKE ?1"
But it seem its imposible with ejb 2.0. am i right ?
how to overcome this then,
"LIKE" operator is so damn important, without this we can't continue our development.
shall we use bmp ? or ????

You can use the like operator with parameters, you just have to put your wildcards into the parameter. Here's an excerpt:
A query that uses a LIKE operator would look something like this:
SELECT DISTINCT OBJECT(user)
FROM User user
WHERE user.userInfo.lastName LIKE ?1
If you check out the code in the code listing on the left-hand side of this panel, you will
note that a method exposes this functionality from the UserManagement session bean
so that you can access it from the client with the getUserByLastNameLike()
method. Thus, to use getUserByLastNameLike(), you can specify the pattern
string as a parameter.
For example, to find users with last names like "High", you would pass the following
parameter value:
users = userMgmt.getUserByLastNameLike("High%");

Similar Messages

  • EJB QL LIKE Operator

    Hello,
    I want to perform search by keyword on all fields of a table. Say I have a product table with following fields:
    Field Name Data Type
    ProductNo Integer
    ProductName String
    Brand String
    UnitPrice Double
    SupCode Integer
    I cannot use LIKE operator as follows:
    "SELECT OBJECT(p) FROM Product AS p WHERE p.productName LIKE ?1 or p.supCode LIKE ?1 or p.partNo LIKE ?1 p.brand LIKE ?1 or p.unitPrice LIKE ?1 ORDER BY p.productName ASC"
    This throws error as LIKE operator expects String fields only. Is there any way I can use LIKE operator or any other way to search by keywords on all field of any data type using EJB QL.

    Hi Muerrtu,
    I'm assuming you're using an implementation of J2EE 1.3, and thus EJB 2.0. EJB 2.1 (J2EE 1.4) added support for an input parameter with the LIKE clause.
    --ken
    Kenneth Saks
    J2EE SDK Team
    SUN Microsystems

  • EJB QL "LIKE" PROBLEM

    Hai All.
    I got an error when put this EJB-QL syntax :
    <query>
    <query-method>
    <method-name>findByName</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    </method-params>
    </query-method>
    <ejb-ql>SELECT DISTINCT object (a) FROM DummyData a WHERE a.name LIKE ?1</ejb-ql>
    </query>
    Seems like this method cannot take an arguments, because it runs well when I change the <ejb-ql> syntax with harcode query like this :
    <ejb-ql>SELECT DISTINCT object (a) FROM DummyData a WHERE a.name LIKE %FOO%</ejb-ql>
    Is there something wrong with my first syntax?
    or the EJB-QL cannot take an arguments for LIKE operator in EJB 2.0??
    Below is the error output
    Auto-deploying file:/C:/NS/jdev/TAX_WORKSPACE/TAX_PROJECT/classes/ (No previous deployment found)... Encountered "a . birthdate LIKE ?1" at line 1, column 7.
    EJB QL method : public abstract java.util.Collection gov.tax.business.registration.IEbDummyLocalHome.findByName(java.lang.String) throws javax.ejb.FinderException
    com.sun.ejb.ejbql.EjbQLQuery
    com.sun.ejb.ejbql.parser.EjbQLParser.parse(com.sun.ejb.ejbql.SymbolTable, com.sun.enterprise.deployment.PersistenceDescriptor, java.lang.reflect.Method, java.lang.String)
    Thanx in advance

    Hi,
    You can achieve this by overriding EJB-QL in orion-ejb-jar.xml file. Please look at
    http://otn.oracle.com/docs/products/ias/doc_library/903doc_otn/generic.903/a97677/ql.htm#1005714
    So you can have something like
    <finder-method query="$name like $1"> in orion-ejb-jar.xml
    and a dummy (but valid) ejb-ql in ejb-jar.xml, like
    <ejb-ql>SELECT DISTINCT object (a) FROM DummyData a WHERE a.name =?1</ejb-ql>
    Hope this helps,
    Neelesh
    OTN Team @ IDC

  • Can I use a LIKE operator in an IF statement in a column formula

    This is what I have so far.
    CASE WHEN Opportunity."Sales Type" LIKE '*New Acct' THEN 'Sale to NEW Customer' END
    I want to display 'Sale to NEW Customer' if opportunity type contains the terms New Acct.

    Try this:
    CASE WHEN Opportunity."Sales Type" LIKE '%New Acct' THEN 'Sale to NEW Customer' END
    The LIKE operator requires a % wildcard rather than the * wildcard.
    Mike L.

  • Why the 'LIKE' operator takes so much time to run?

    I have a table T with 3 columns and 3 indexes:
    CREATE TABLE T
    id VARCHAR2(38) NOT NULL,
    fid VARCHAR2(38) NOT NULL,
    val NVARCHAR2(2000) NOT NULL
    ALTER TABLE T ADD (CONSTRAINT pk_t PRIMARY KEY (id,fid));
    CREATE INDEX t_fid ON T(fid);
    CREATE INDEX t_val ON T(val);
    Then I have the following two queries which differ in only one place - the 1st one uses the '=' operator whereas the 2nd uses 'LIKE'. Both queries have the identical execution plan and return one identical row. However, the 1st query takes almost 0 second to execute, and the 2nd one takes more than 12 seconds, on a pretty beefy machine. I had played with the target text, like placing '%' here and/or there, and observed the similar timing every time.
    So I am wondering what I should change to make the 'LIKE' operator run as fast as the '=' operator. I know CONTEXT/CATALOG index is a viable approach, but I am just trying to find out if there is a simpler alternative, such as a better use of the index t_val.
    1) Query with '=' operator
    SELECT id
    FROM T
    WHERE fid = '{999AE6E4-1ED9-459B-9BB0-45C913668C8C}'
    AND val = '3504038055275883124';
    2) Query with 'LIKE' operator
    SELECT id
    FROM T
    WHERE fid = '{999AE6E4-1ED9-459B-9BB0-45C913668C8C}'
    AND val LIKE '3504038055275883124';
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=1 Card=1 Bytes=99)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T' (Cost=1 Card=1 Bytes=99)
    2 1 INDEX (RANGE SCAN) OF 'T_VAL' (NON-UNIQUE) (Cost=4 Card=12)

    I will for sure try to change the order of the PK and see whether there will be any impact to the performance.
    In our application, val is much closer to a unique value than fid. In the example query, the execution plan showed that the index on val was indeed used in the execution of the query. That's why the 1st query took almost no time to return (our table T has more than 6 million rows).
    I was hoping the 'LIKE' operator would utilize the t_val index effectively and provide similar performance to the '=' operator. But apparently that's not the case, or needs some tricks.

  • [Microsoft][SQL Server Native Client 11.0][SQL Server]The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.  'Items' (OITM) (OITM)

    Dear Experts,
    i am getting the below error when i was giving * (Star) to view all the items in DB
    [Microsoft][SQL Server Native Client 11.0][SQL Server]The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.  'Items' (OITM) (OITM)
    As i was searching individually it is working fine
    can any one help me how to find this..
    Regards,
    Meghanath.S

    Dear Nithi Anandham,
    i am not having any query while finding all the items in item master data i am giving find mode and in item code i was trying to type *(Star) and enter while typing enter the above issue i was facing..
    Regards,
    Meghanath

  • Error in SQL Query The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. for the query

    hi Experts,
    while running SQL Query i am getting an error as
    The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. for the query
    select  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
    T2.LineText
    from OQUT T0  INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
    QUT10 T2 ON T1.DocEntry = T2.DocEntry where T1.DocEntry='590'
    group by  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
    ,T2.LineText
    how to resolve the issue

    Dear Meghanath,
    Please use the following query, Hope your purpose will serve.
    select  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
    CAST(T2.LineText as nvarchar (MAX))[LineText]
    from OQUT T0  INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
    QUT10 T2 ON T1.DocEntry = T2.DocEntry --where T1.DocEntry='590'
    group by  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
    ,CAST(T2.LineText as nvarchar (MAX))
    Regards,
    Amit

  • Like operator functionality

    We have a simple select query which is using the 'Like' operator on a char(4) column.
    In a oracle windows environment when we have a query such as:
    select col1, col2, col3
    from table1
    where col1 like 'AB'
    it returns everything which is = to 'AB' and doesn't seem to be including the trailing 2 spaces as would be stored becasue the column is char(4)
    In a oracle unix environment when we the same query:
    select col1, col2, col3
    from table1
    where col1 like 'AB'
    it returns nothing...
    It appears as if the version running on a windows environment is truncating the trailing 2 spaces when using the like expression but in a unix environment, it is not. Does anybody have any idea or clue what could be occuring or if there is some database setting which could cause this to occur?

    Quote from Oracle Doc:
    Character Values
    Character values are compared using one of these comparison rules:
    Blank-padded comparison semantics
    Nonpadded comparison semantics
    The following sections explain these comparison semantics.
    Blank-Padded Comparison Semantics If the two values have different lengths, then Oracle first adds blanks to the end of the shorter one so their lengths are equal. Oracle then compares the values character by character up to the first character that differs. The value with the greater character in the first differing position is considered greater. If two values have no differing characters, then they are considered equal. This rule means that two values are equal if they differ only in the number of trailing blanks. Oracle uses blank-padded comparison semantics only when both values in the comparison are either expressions of datatype CHAR, NCHAR, text literals, or values returned by the USER function.
    Nonpadded Comparison Semantics Oracle compares two values character by character up to the first character that differs. The value with the greater character in that position is considered greater. If two values of different length are identical up to the end of the shorter one, then the longer value is considered greater. If two values of equal length have no differing characters, then the values are considered equal. Oracle uses nonpadded comparison semantics whenever one or both values in the comparison have the datatype VARCHAR2 or NVARCHAR2.
    "

  • Using Like Operator in a decode function

    Hi,
    I am trying to find out if I can use the like operator in a decode function
    like:
    select decode(1234,like '%123%','123 is a match') from dual;
    this reults in error ORA-00936: missing expression
    is there any way to make this work?
    thank you

    SQL> ed
    Wrote file afiedt.buf
      1  WITH tbl AS (SELECT '201aaa' dt FROM DUAL UNION ALL
      2               SELECT '123bbb' dt FROM DUAL UNION ALL
      3               SELECT '567ccc' dt FROM DUAL UNION ALL
      4               SELECT 'ab123ddd' dt FROM DUAL
      5               )
      6  SELECT dt,CASE WHEN dt like '%123%' THEN 'Match'
      7         ELSE 'Not Matched'
      8         END With_case
      9        ,DECODE(REGEXP_SUBSTR(dt,'123'),NULL,'Not Match','Match')   With_Regexp
    10        ,DECODE(INSTR(dt,'123'),0,'Not Match','Match') With_Instr
    11        ,DECODE(REPLACE(dt,'123'),dt,'Not Match','Match') With_Replace
    12* FROM tbl
    SQL> /
    DT       WITH_CASE   WITH_REGE WITH_INST WITH_REPL
    201aaa   Not Matched Not Match Not Match Not Match
    123bbb   Match       Match     Match     Match
    567ccc   Not Matched Not Match Not Match Not Match
    ab123ddd Match       Match     Match     MatchEdited by: Saubhik on Jul 26, 2010 5:24 AM
    Edited by: Saubhik on Jul 26, 2010 5:40 AM
    Edited by: Saubhik on Jul 26, 2010 5:40 AM

  • LIKE operator is not working in SQL Query in XML file

    Hi Gurus,
    LIKE operator is not working in SQL query in XML template.
    I am creating a PDF report in ADF using Jdeveloper10g. The XML template is as follows
    <?xml version="1.0" encoding="WINDOWS-1252" ?>
    <dataTemplate name="catalogDataTemplate" description="Magazine
    Catalog" defaultPackage="" Version="1.0">
    <parameters>
    <parameter name="id" dataType="number" />
    <parameter name="ename" dataType="character" />
    </parameters>
    <dataQuery>
    <sqlStatement name="Q1">
    <![CDATA[
       SELECT ename, empno, job, mgr from EMP where deptno=:id and ename LIKE :ename || '%']]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="EmployeeInfo" source="Q1">
    <element name="EmployeeName" value="ename" />
    <element name="EMPNO" value="empno" />
    <element name="JOB" value="job"/>
    <element name="MANAGER" value="mgr" />
    </group>
    </dataStructure>
    </dataTemplate>
    if i pass the parameter value of :ename from UI, it doesn't filter. But if I give ename = :ename it retrieves the data. Can anyone help me why LIKE operator doesn't work here?
    Appreciate your help,
    Shyamal
    email: [email protected]

    Hi
    Well for a start, you are doing some very strange conversions there. For example...
    and to_char(a.msd, 'MM/DD/YYYY') != '11/11/2030'
    and to_char(a.msd, 'MM/DD/YYYY') != '10/10/2030'If a.msd is a date then you should e converting on the other side ie.
    and a.msd != TO_DATE('11/11/2030', 'MM/DD/YYYY')
    and a.msd != TO_DATE('10/10/2030', 'MM/DD/YYYY')Also, you may want to take into consideration nothing being input in :P2_ITEM_NUMBER like this...
    AND INSTR(a.item_number,NVL(:P2_ITEM_NUMBER,a.item_number)) > 0Is item number actually a number or char field? If it's a number, you want to explicitly convert it to a string for using INSTR like this...
    AND INSTR(TO_CHAR(a.item_number),NVL(TO_CHAR(:P2_ITEM_NUMBER),TO_CHAR(a.item_number))) > 0?
    Cheers
    Ben

  • 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.

  • Like operator in a query

    I need a user to be able to enter a city to pull up results
    for that city using a LIKE operator. However, if the master list
    contains St. Paul, instead of Saint Paul, how can I get either one
    to show up? I've tried several things and I just can't get it to
    work!!! Thanks!

    I have had code like some below but it slows thing down
    because indexes can't be used. Instead for searches that don't have
    to be exactly up to date I build a work file that is in a
    standardized format nightly but it could be done by triggers. This
    code is for Oracle.
    where
    ( length(
    translate(
    UPPER(LTRIM(RTRIM('#Form.StreetName#'))
    'A,._%1234567890'
    ,'A')
    ) >= 4 AND
    V.StNum = '#Form.StreetNumber#'
    <CFIF '#Form.StreetDirection#' NEQ ''>
    and V.stdir = '#Form.StreetDirection#'
    </cfif>
    and (
    V.stName LIKE RTRIM(SUBSTR(
    DECODE(
    SUBSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||'
    ',1,INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ',' ',1,1)-1)
    ,'1','FIRST'
    ,'2','SECOND'
    ,'3','THIRD'
    ,'4','FOURTH'
    ,'5','FIFTH'
    ,'6','SIXTH'
    ,'7','SEVENTH'
    ,'8','EIGHTH'
    ,'9','NINTH'
    ,'10','TENTH'
    ,'11','ELEVENTH'
    ,'12','TWELVTH'
    ,'1ST','FIRST'
    ,'2ND','SECOND'
    ,'3RD','THIRD'
    ,'4TH','FOURTH'
    ,'5TH','FIFTH'
    ,'6TH','SIXTH'
    ,'7TH','SEVENTH'
    ,'8TH','EIGHTH'
    ,'9TH','NINTH'
    ,'10TH','TENTH'
    ,'11TH','ELEVENTH'
    ,'12TH','TWELVTH'
    ,'E','EAST'
    ,'N','NORTH'
    ,'S','SOUTH'
    ,'W','WEST'
    ,'SE','SOUTHEAST'
    ,'SW','SOUTHWEST'
    ,'SAINT','ST'
    ,'MT','MOUNT'
    ,'CT','COURT'
    ,'CORP','CORPORATE'
    ,SUBSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||'
    ',1,INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ',' ',1,1)-1))
    ||
    DECODE(instr(ltrim(rtrim('#Form.StreetName#')),' ',1,1),0,'',
    ' '||
    SUBSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||'
    ',INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ',' ',1,1)+1,
    INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ','
    ',-2,1)-INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#')))
    ,'`''_,.%','%%')||' ',' ',1,1))
    ||
    DECODE(
    RTRIM(SUBSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||'
    ',INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ',' ',-2,1)+1))
    ,'AVENUE','AV'
    ,'AVE','AV'
    ,'BOULEVARD','BL'
    ,'BLVD','BL'
    ,'COURT','CT'
    ,'CRT','CT'
    ,'DRIVE','DR'
    ,'LANE','LN'
    ,'PARK','PK'
    ,'PLACE','PL'
    ,'POINT','PT'
    ,'POINTE','PT'
    ,'ROAD','RD'
    ,'SQUARE','SQ'
    ,'STREET','ST'
    ,'STR','ST'
    ,'TRACE','TR'
    ,'TRAIL','TR'
    ,'CIRCLE','CIR'
    ,'CR','CIR'
    ,'EXTENSION','EXT'
    ,'HIGHWAY','HWY'
    ,'HIWAY','HWY'
    ,'HIWY','HWY'
    ,'PIKE','PKE'
    ,'RW','ROW'
    ,'RN','RUN'
    ,'TERRACE','TER'
    ,'WY','WAY'
    ,RTRIM(SUBSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||'
    ',INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ',' ',-2,1)+1)))
    ),1,4))
    ||'%'
    OR
    V.stName LIKE RTRIM(SUBSTR(
    DECODE(
    SUBSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||'
    ',1,INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ',' ',1,1)-1)
    ,'1','FIRST'
    ,'2','SECOND'
    ,'3','THIRD'
    ,'4','FOURTH'
    ,'5','FIFTH'
    ,'6','SIXTH'
    ,'7','SEVENTH'
    ,'8','EIGHTH'
    ,'9','NINTH'
    ,'10','TENTH'
    ,'11','ELEVENTH'
    ,'12','TWELVTH'
    ,'1ST','FIRST'
    ,'2ND','SECOND'
    ,'3RD','THIRD'
    ,'4TH','FOURTH'
    ,'5TH','FIFTH'
    ,'6TH','SIXTH'
    ,'7TH','SEVENTH'
    ,'8TH','EIGHTH'
    ,'9TH','NINTH'
    ,'10TH','TENTH'
    ,'11TH','ELEVENTH'
    ,'12TH','TWELVTH'
    ,'E','EAST'
    ,'N','NORTH'
    ,'S','SOUTH'
    ,'W','WEST'
    ,'SE','SOUTHEAST'
    ,'SW','SOUTHWEST'
    ,'SAINT','ST'
    ,'MOUNT','MT'
    ,'CT','COURT'
    ,'CORP','CORPORATE'
    ,SUBSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||'
    ',1,INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ',' ',1,1)-1))
    ||
    DECODE(instr(ltrim(rtrim('#Form.StreetName#')),' ',1,1),0,'',
    ' '||
    SUBSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||'
    ',INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ',' ',1,1)+1,
    INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ','
    ',-2,1)-INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#')))
    ,'`''_,.%','%%')||' ',' ',1,1))
    ||
    DECODE(
    RTRIM(SUBSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||'
    ',INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ',' ',-2,1)+1))
    ,'AVENUE','AV'
    ,'AVE','AV'
    ,'BOULEVARD','BL'
    ,'BLVD','BL'
    ,'COURT','CT'
    ,'CRT','CT'
    ,'DRIVE','DR'
    ,'LANE','LN'
    ,'PARK','PK'
    ,'PLACE','PL'
    ,'POINT','PT'
    ,'POINTE','PT'
    ,'ROAD','RD'
    ,'SQUARE','SQ'
    ,'STREET','ST'
    ,'STR','ST'
    ,'TRACE','TR'
    ,'TRAIL','TR'
    ,'CIRCLE','CIR'
    ,'CR','CIR'
    ,'EXTENSION','EXT'
    ,'HIGHWAY','HWY'
    ,'HIWAY','HWY'
    ,'HIWY','HWY'
    ,'PIKE','PKE'
    ,'RW','ROW'
    ,'RN','RUN'
    ,'TERRACE','TER'
    ,'WY','WAY'
    ,RTRIM(SUBSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||'
    ',INSTR(translate(UPPER(LTRIM(RTRIM('#Form.StreetName#'))),'A`''_,.%','A')
    ||' ',' ',-2,1)+1)))
    ),1,4))
    ||'%' )

  • Problem in JDBC , when using LIKE operator. - VERY URGENT

    Problem in JDBC , when using LIKE operator.
    LINE 1 : String temp = "AA";
    LINE 2 : String query = "select * from emp where EMPNAME like '*temp*' ";
    LINE 3 : Staement st = con.createStaement();
    LINE 4 : ResultSet rs = st.executeQuery(query);
    '*' character is not getting evaluated. In MS ACCESS2000 only * is accepted instead of '%'. Moreover in MS ACCESS the like operator has to be used within double quotes as a String. whereas in other databases, it accepts single quotes as a String.
    Ex:
    In MS ACCESS
         select * from emp where ename like "*aa*";
    Other Databases
         select * from emp where ename like '%aa%';
    In my situation iam passing a Variable inside a like operator and '*' is used.
    For the above Scenario, Please help me out.
    If possible Kindly let me know the exact Syntax.
    Please give me the answer as LINE1,LINE2,LINE3,LINE4,
    I have verified in JDBC Spec also, it has been specified to use escape sequence.that too did not work.
    Due to this, My project is in hold for about 4 days. I could not find a suitable solution.
    Please help me out.

    I made a LIKE clause work with M$ Access, using PreparedStatement and the % wildcard:
                escapeStr                   = "%";
                String sql                  = "SELECT USERNAME, PASSWORD FROM USERS WHERE USERNAME LIKE ?";
                PreparedStatement statement = connection.prepareStatement(sql);
                statement.setString(1, ("user" + escapeStr));
                ResultSet resultSet         = statement.executeQuery();
                while (resultSet.next())
                    System.out.println("username: " + resultSet.getObject("USERNAME") + " password: " + resultSet.getObject("PASSWORD"));

  • 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

  • How does this LIKE operator work ?

    Values JOHN and KEITH have spaces in the string.
    create table string_test ( test_str varchar2(15));
    insert into string_test values ('JO HN');
    insert into string_test values ('JOHN');
    insert into string_test values ('RAM');
    insert into string_test values ('KEITH ');
    SQL> select * from string_test;
    TEST_STR
    JO HN
    JOHN
    RAM
    KEITHFrom OTN , i found the query to find all string values which has a white space in it.
    select * from string_test where test_str like '%' || chr(32) || '%';But, i don't understand how this works. Won't the percent sign in single quotes ('%') be considered a literal ?

    GarryB wrote:
    Values JOHN and KEITH have spaces in the string.
    create table string_test ( test_str varchar2(15));
    insert into string_test values ('JO HN');
    insert into string_test values ('JOHN');
    insert into string_test values ('RAM');
    insert into string_test values ('KEITH ');
    SQL> select * from string_test;
    TEST_STR
    JO HN
    JOHN
    RAM
    KEITHFrom OTN , i found the query to find all string values which has a white space in it.
    select * from string_test where test_str like '%' || chr(32) || '%';But, i don't understand how this works. Won't the percent sign in single quotes ('%') be considered a literal ?No, because the "%" sign has special meaning to the LIKE operator. It's a wildcard meaning any characters.

Maybe you are looking for

  • Lost index stats in Ora 8.1.6 Tables when selecting via jdbc

    Hi, i'm using JBuilder8 and Kylix2 on a Linux machine with Oracle oci drivers of client 8.1.7. The connect through JB8 jdbc via DBPilot is succesful and shows the tables of the db. After executing a select on any table the index stats of this table a

  • I upgraded from a 3gs to 4g and want to separate accounts for each phone

    I upgraded to iPhone 4S from the 3GS.  I handed down the 3GS to my son but, my contacts remain on the 3GS.  Will creating a new name and account for the 3GS separate the account and phone from the account and phone (4S)?

  • Accessing html pages outside tomcat server

    Hi I have my images and html pages stored in a directory outside the server. This is because of the WAR file. Other people are developing the html pages and uploading them. The name of the html file is in a mysql table. With the name I have to show t

  • WAD Export to Excel, PDF parameters query export

    Hi, I solve the problem with export to excel in WAD. Customer want to see all parameters (and also filters in query) with which are query execute in query in  export to MS Excel or PDF. Any advices? Thanks Petr

  • VMI laid at customer consignment

    Hi Friends, I have an  interesing scenario to be solved. Our client holds a vendor whos complete products are maitained as a vendor managed inventory in the vendors own storage location. This storage location is a part of our clients Org structure. A