SQL LIKE Operator return nothing

I am working on an intranet application and use Access as the
database.
There is a query that I have
<CFQUERY DATASOURCE="#DSN#" NAME="GET_SEARCH_RESULT">
SELECT * FROM WL_TREES
WHERE TREENAME LIKE '3*'
</CFQUERY>
It returns nothing in ColdFusion, if I copy just the SQL and
run it in Access, it returns with the expected result.
Any idea why ColdFusion query didn't work?
Thanks,
tofuTnT

replace the * with a % and you should be good to go.
HTH
Tim Carley
www.recfusion.com
[email protected]

Similar Messages

  • SQL Like Operator query

    Hi
    I would like to extract data with criteria between 'J09' and 'J18'. These are hierarichical disease codes. Therefore you can have J091 to J189. This is my query below.
    Select * from inpatient_table
    where Diagnosis_code like 'J[09-18]%';
    the query doesnt pull the right results. Any help would be greatly appreciated.
    Regards
    Siva

    Hi Siva,
    I havent got any like expressions to work with this so far but if your not particular about using like expressions, the following should help:
    create table #temp
    text varchar(10)
    --J091
    --J189
    insert #temp select 'J089abc'
    insert #temp select 'J091abc'
    insert #temp select 'J112abc'
    insert #temp select 'J121abc'
    insert #temp select 'J134abc'
    insert #temp select 'J088abc'
    insert #temp select 'J189abc'
    insert #temp select 'J190abc'
    insert #temp select 'J291abc'
    select *
    from #temp
    where cast (right(left(text,4),3) as int) between 91 and 189
    Let me know in case of any queries
    Thanks, Jay <If the post was helpful mark as 'Helpful and if the post answered your query, mark as 'Answered'>

  • 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

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

  • Filter SharePoint list items using CAML query as same as Like operator in SQL Server.

    Hi ,
    I have filtered SharePoint list items based on Name using CAML query <Contains> . Now I have a new requirement is to filter list items using Like operator in SQL. But Like operator is not in CAML.
    How do I filter list items using CAML as same as Like operator in SQL.
    Please let me know.
    Thanks in Advance.

    Did you try using <Contains>?
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/15766fd5-50d5-4884-82a1-29a1d5e38610/caml-query-like-operator?forum=sharepointdevelopmentlegacy
    --Cheers

  • 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

  • LIKE operator in SQL LOADER

    HI,
    Is there any alternative for LIKE operator.
    Cheers.

    Hello,
    It depends of what you need, but sometimes, you write the same condition using SUBSTR.
    Regards,
    Sylvie

  • How to pass variable into lov sql query using like operator

    hi.
    i want to use a lov where i want to pass a variable using like operator.
    my query is
    select empno,name from table where empno like ':ed%';
    my empno is A001 TO A199 AND B001 TO B199 so i want show either A% or B% empno
    how can i do this ?
    reagrds

    kindly press Shift+F1 at a time you face this error to see the exact Oracle error message.
    and provide us with that detail
    and its better if you start new topic for that error... because that will be new error,,,
    -- Aamir Arif
    Edited by: Aamiz on Apr 7, 2010 12:27 PM

  • PL/SQL function body returning SQL query - ORA-06502: PL/SQL: numeric or value error

    I'm attempting to dynamically generate a rather large SQL query via the "PL/SQL function body returning SQL query" report region option.  The SQL query generated will possibly be over 32K.  When I execute my page, I sometimes receive the "ORA-06502: PL/SQL: numeric or value error" which points to a larger than 32K query that was generated.  I've seen other posts in the forum related to this dynamic SQL size limitation issue, but they are older (pre-2010) and point to the 32K limit of the DNS (EXECUTE IMMEDIATE) and DBMS_SQL.  I found this post (dynamic sql enhancements in 11g) which discusses 11g no longer having the 32K size limitation for generating dynamic SQL.  Our environment is on 11gR2 and using ApEx 4.2.1.  I do not know which dynamic SQL method -- DNS or DBMS_SQL -- ApEx 4.2.1 is using.  Can someone clarify for me which dynamic SQL method ApEx uses to implement the "PL/SQL function body returning SQL query" option?
    As a test, I created a page on apex.oracle.com with a report region with the following source:
    declare
      l_stub varchar2(25) := 'select * from sys.dual ';
      l_sql  clob := l_stub || 'union all ';
      br     number(3) := 33;
    begin
      while length ( l_sql ) < 34000 loop
        l_sql := l_sql || l_stub || 'union all ';
      end loop;
      l_sql := l_sql || l_stub;
      for i in 1 .. ceil ( length ( l_sql ) / br ) loop
        dbms_output.put_line ( dbms_lob.substr ( l_sql, br, ( ( i - 1 ) * br ) + 1 ) );
      end loop;
      return l_sql;
    end;
    The dbms_output section is there to be able to run this code in SQL*Plus and confirm the size of the SQL is indeed larger than 32K.  When running this in SQL*Plus, the procedure is successful and produces a proper SQL statement which can be executed.  When I put this into the report region on apex.oracle.com, I get the ORA-06502 error.
    I can certainly implement a work-around for my issue by creating a 'Before Header' process on the page which populates an ApEx collection with the data I am returning and then the report can simply select from the collection, but according to documentation, the above 32K limitation should be resolved in 11g.  Thoughts?
    Shane.

    What setting do you use in your report properties - especially in Type and in Region Source?
    If you have Type="SQL Query", then you should have a SELECT statement in the Region Source. Something like: SELECT .... FROM ... WHERE
    According to the ERR-1101 error message, you have probably set Type to "SQL Query (PL/SQL function body returning SQL query)". In this situation APEX expects you to write a body of a PL/SQL function, that will generate the text of a SQL query that APEX should run. So it can be something like:
    declare
    mycond varchar2(4000);
    begin
    if :P1_REPORT_SEARCH is not null THEN
    mycond:='WHERE LAST_NAME like :P1_REPORT_SEARCH ||''%''';
    end if;
    return 'select EMPLOYEE_ID, FIRST_NAME, LAST_NAME from EMPLOYEES ' ||mycond;
    end;
    And for escaping - are you interested in escaping the LIKE wildcards, or the quotes?
    For escaping the wildcards in LIKE function so that when the user enters % you will find a record with % and not all functions, look into the SQL Reference:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm
    (You would than need to change the code of your function accordingly).
    If you are interested in escaping the quotes, try to avoid concatenating the values entered by the user into the SQL. If you can, use bind variables instead - as I have in my example above. If you start concatenating the values into the text of SQL, you are open to SQLInjection - user can enter anything, even things that will break your SQL. If you really need to allow users to choose the operator, I would probably give them a separate combo for operators and a textfield for values, than you could check if the operator is one of the allowed ones and create the condition accordingly - and than still use bind variable for inserting the filtering value into the query.

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

  • Exclude "*" in Like operator

    Hi All,
    I am trying to use like operator for an output data which has "*" appended at the end.
    For example, following is the Place_ID which i have data in a table
    12190101*
    12349021
    12347284
    12598992*
    When i provide search criteria as "1234" in my application, my query is making the condition as
    Place_ID Like "1234%"
    But unfortunately it is giving 4 rows as output which is not considering the values which is appended with '*".
    I tried making use of the following, but still this is not working.
    Place_ID Like "1234%" ESCAPE '*'
    Can someone suggest me where i am doing wrong.
    Thanks,
    Prakash

    Prakash wrote:
    But unfortunately it is giving 4 rows as output which is not considering the values which is appended with '*".It is not clear what output you expect. But one thing is for sure: condition Place_ID Like 11234%' can't return 4 rows:
    {code}
    with data as(
    select '12190101*' place_id from dual union all
    select '12349021' from dual union all
    select '12347284' from dual union all
    select '12598992*' from dual
    select place_id
    from data
    where place_id like '1234%'
    PLACE_ID
    12349021
    12347284
    SQL>
    {code}
    So post desired results.
    SY.

  • How to use LIKE operator with PreparedStatement

    Hi, I need to execute a query with the LIKE operator, but using a PreparedStatement. Can I do this, and if so what must my SQL look like with the wildcard characters '%' or '_'?
    normal PS example: conn.prepareStatement("select * from mytable where name like ?");
    If I try: conn.prepareStatement("select * from mytable where name like ?%");
    I get: ORA-00911: invalid character
    If I try: conn.prepareStatement("select * from mytable where name like '?%'");
    I get: ORA-01006: bind variable does not exist
    I must use a PreparedStatement, as my variable may contain illegal characters (like '), and using PreparedStatement.setString(1, var) will automatically escape it for me.
    I could also use a normal Statement, but I need to escape my var ... is there a utility that will safely escape a String for an Oracle VARCHAR2??
    Thanks in advance,
    Stu Miller

    Hmm, it seems you are right...
    when my variable contains a '%' symbol, the PreparedStatement will NOT escape it, and thus it is treated like a wildcard. Therefore, I can just do
    pstmt.setString(1, var+"%");
    But, that may return more results than I'm asking for, as when 'var' contains a '%' symbol it is taken as a wildcard too.
    I need each character in my variable to be taken literally, and only add a wildcard at the end. Basically, I need a STARTSWITH operator ;-)
    It seems to me that escaping the sensitive characters in a String (which will differ depending on which operator is used), should be possible. I could write this, but I was hoping Oracle had already done it for me in some utility class.

  • "Like" operator in Framework

    Hi,
    I was just wondering if there is any operator in OAFramework which is similar to "LIKE" operator in PL/SQL?
    Thanks

    Actually in my case, i cannot use PLSQL because, in the ReviewPage of my custom page, i need to check the list of all the approvals for which the page goes once submitted. In this process, i had to check for some names, some jobs and add extra information from the page based on the values i get and etc.
    But i am glad that i could achieve this functionality with the "regionMatches" function for string. Below is the logic i used.
    public boolean XXXMatch(String searchStr, String findStr )
    int searchStrLength = searchStr.length();
    int findStrLength = findStr.length();
    boolean foundIt = false;
    for (int i = 0; i <= (searchStrLength - findStrLength); i++)
    if (searchStr.regionMatches(i, findStr, 0, findStrLength))
    foundIt = true;
    return foundIt;
    if (!foundIt)
    return foundIt;
    return foundIt;
    To test the above function, In the parameters, if we pass "Hello World how are you" as a parameter value for searchStr and "World" for the parameter value findStr, it will return true.
    Thanks

  • LIKE OPERATOR QUESTION

    Hi All,
    Quite simply I don't really understand two things.
    1) How is the LIKE operator is working to return both columns.
    2) When to use the LIKE operator and when to use the relation operator.
    Thanks.
    (CODE)
    SELECT *
    FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
    TO_DATE ('1-Jan-2009') bb FROM DUAL
    WHERE aa LIKE bb
    --returns both columns
    SELECT *
    FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
    TO_DATE ('1-Jan-2009') bb FROM DUAL
    WHERE aa = bb
    --returns nothing
    (/CODE)

    Hi,
    DaveyB wrote:
    Hi All,
    Quite simply I don't really understand two things.
    1) How is the LIKE operator is working to return both columns.The WHERE clause (whether it contains LIKE or anything else) will only control the number of rows: every row will have the same numberr of columns.
    2) When to use the LIKE operator and when to use the relation operator.Use LIKE when you want to use "wildcards" (% or _).
    Use other operators (like =) when you don't have wildcards.
    (CODE)
    SELECT *
    FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
    TO_DATE ('1-Jan-2009') bb FROM DUAL
    WHERE aa LIKE bb
    --returns both columns
    SELECT *
    FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
    TO_DATE ('1-Jan-2009') bb FROM DUAL
    WHERE aa = bb
    --returns nothing
    (/CODE)It's great that you're trying to format your code! I wish everyione did that.
    Use square brackets (&#091; and &#093;) if you want to use &#091;CODE&#093; and &#091;/CODE&#093; tags.
    LIKE operates on strings. Don't use a DATE where a string is required. Do some experiments like the ones you tried just using strings, if you want to see how LIKE behaves.

Maybe you are looking for

  • Crash Occuring When Trying To Make In-App Purchases

    Whenever I try to buy stuff from apps or games, the application just completely crashes. I can't seem to find a reason why this is actually happening. I have been restarting it and still looking for an answer. My next thought is if I should restore t

  • In Search - Only first ten name displays

    Dear All, When I search for a name,only top ten relevant names pops out,for more information please check the attachment. is it bug or Google chrome impact ?. Thanks Agasthuri PS: I was looking for name "Amit Srivastava" the search result pop out onl

  • Organizing Photo Library Page Hints

    I do not run a business, but rather enjoy my computer for home use... so my hints for organizing an iPhoto Library Page relate to personal/home use. I have iPhoto 6.0.5 (316) on my computer. Regarding the "View" of the Library Page, I do keep my "Fil

  • Can not edit PS  CS 5 files  in  CC 2014

    Hi. I have  CS5 and CC 2014 installed on my iMac (Yosemite 10.10.1).  After I installed CC 2014 this happens: When I try to open CS5  files in Camera Raw , they open in the old CR window and not in the CC 2014, CR window.  New files open in the new C

  • Camera & Torch not working

    Hello,  Since December 2014 my phone camera has not been working.  A few times I would restart, and it would work again for a day or so, then it would stop working again.  I get 3 different error messages (screenshots attached in this message).  The