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.
"
Similar Messages
-
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 youSQL> 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 -
[VB] Like operator not functioning?
I'm trying to create the following statement in my VB code, but I'm getting a "Sub or Function not defined" error. My question is, how do you use the Like operator with InDesign scripting? InDesign doesn't seem to recognize the Like operator.
"myCurrentString" contains a letter.
If myCurrentString Like "[A-z]" Then
End If
I'm also trying to do the following:
If myCurrentDigit Like "[0-9]" Then
End IfI couldn't find "RegExp" in the InDesign script model--could you give a bit more information about what this is? I don't know how to iterate through the contents of an XMLElement as individual character objects, so I'm iterating throught XML.contents, putting each character in a basic string variable. I need a way to put strings into a With statement, or a Like operator. I haven't had success with either technique.
Here's an example:
strTime = myCurrentXMLElement.contents
strTime = Trim(strTime)
strLength = Len(strTime)
For counter = 1 to strLength
strTemp = Mid(strTime, counter, 1)
[This is where I need to find out if strTemp is a letter or a digit]
Next -
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,
RamaIf 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 -
How to use like operator in IFTHENELSE (BODS)
Hi All,
I want to find the value of ' % ASSOC%' in the name and replace it to 'Assoc.' using ifthenelse.
Can any one help me. Is there any similar fuction as LIKE operator. Can we give LIKE in ifthen else condition.
Thanks in advanceHi ,
if you have data ASSOC1,ASSOC2
and you want Output like Assoc.1,Assoc.2.
In this condition it is not possible with ifthenelse function
it will return output as Assoc.
Example Source:
If we use if then else condition. Then it will replace all the Data to Assoc.
Or else if you want to replace ASSOC to Assoc. Then you can use Search_Replace also
it will generate a XML script
The expected output as follows in the below screen. As per your requirement you can you any one of this.
Regards,
Akhileshkiran. -
i want example
about like operator
AND N.user_je_category_name LIKE'PAS_%'
and i want to said
AND N.user_je_category_name LIKE'PAS_%' and 'BS_'%
HOW MAKE THATHi,
Usama Hashem wrote:
THANX FOR U BUT HOW USE GROUP BY IN THIS QUERY What makes you think there's anything wrong with it?
Are you getting an error message? If so, post the error message.
Are you getting the wrong results? If so, describe.
Whenever you post any code, format it to show the extent of major sections (sub-queries, nested functions, nested anything, multi-part concats, ...
Whenever there's a lot of code between a '(' and its matching ')', put them on separate lines, indent them the same amount, and indent everything in between them at least that much.
Type these 6 characters:
{code}
(all small letters, inside curly brackets) before and after sections of formatted text.
The longer the code is, the more important it is to do this.
It looks like you're doing something like this:
Select sum (debt) debt
, sum (credit) credit
from (
Select ( SUM (l.ENTERED_DR)
- SUM (l.ENTERED_CR)
) Debt,
SUM (l.ENTERED_CR)
- SUM (l.ENTERED_CR) Credit
from gl_code_combinations M,
where ...
AND H.DEFAULT_EFFECTIVE_DATE BETWEEN :FROM_DATE AND :TO_DATE
AND ( N.user_je_category_name NOT LIKE 'PAS_%'
AND N.user_je_category_name NOT LIKE 'WS_%'
OR N.user_je_category_name LIKE 'RE_%'
GROUP BY M.SEGMENT2
, ( M.segment1 || '.'
|| M.segment2 || '.'
|| M. segment3 || '.'
|| M.segment4 || '.'
|| M. segment5 || '.'
|| M.segment6
-- Need ) here?That is, the main query is based on an in-line view.
The only columns in that in-line view are debt and credit.
If you want to reference columns like segment1, segemnt2, ... in the main query, then you have to include them in the SELECT clause of the in-line view.
(Since the in-line view is a UNION, remember to include them in both SELECT clauses.)
Table alias M is only defined inside each branch of the UNION. In the main query, you'll reference the columns as segment1, segment2, ...
The following two items may be giving you the right results now, but even if so, they are accidents waiting to happen, and should be fixed.
(1) What is the data type of gl_je_headers.default_effective_date?
If it's a DATE then only compare it to other DATEs. Unfortunately, bind variables can't be DATEs, so you'll have to do something like:
... AND H.DEFAULT_EFFECTIVE_DATE BETWEEN TO_DATE (:FROM_DATE, 'DD-MON-YYYY')
AND TO_DATE (:TO_DATE, 'DD-MON-YYYY')(2) Never mix AND and OR.
You probably need another layer of parentheses somewhere around:
... AND ( N.user_je_category_name NOT LIKE 'PAS_%'
AND N.user_je_category_name NOT LIKE 'WS_%'
OR N.user_je_category_name LIKE 'RE_%'
)Maybe
... AND ( ( N.user_je_category_name NOT LIKE 'PAS_%'
AND N.user_je_category_name NOT LIKE 'WS_%'
OR N.user_je_category_name LIKE 'RE_%'
)It looks like credit will always be 0 (or NULL) in the first branch of the UNION. Is that what you meant? -
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
ManjuSomething 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. -
LIKE operator- change symbol for [all characters]
I have an input parameter which contains symbols "*" (star symbol), example:
i_search_par := 'country * street';
I gonna do query:
select * from SearchTable
where col1 like i_search_par;
I want that the "*" would act the same way as "%"-symbol in LIKE operator.
So i want that query would return such results:
'country 1 street'
'country 200 street'
and so on.
What is the better way to achieve this, that "*" is going to be interpreted as a "any number of any symbols"?
Maybe i can say something like:
SET SESSION ANYCHAR SYMBOL = "*".
And after doing that Oracle understands in LIKE operators that star-symbol is like i want?
Or should i really do string replacement by replacing ""%" to "*" in "i_search_par" and in other 30 such varaibles?Hi,
Sorry, I don't think there's any way to tell LIKE to use different wildcards.
CharlesRoos wrote:
I have ca 30 input parameters:
i_search_par1 := 'country * street';
i_search_par2 := 'country * street';
i_search_par30 := 'country * street';Wouldn't it be just as easy to say:
i_search_par1 := 'country % street';
i_search_par2 := 'country % street';
i_search_par30 := 'country % street';?
>
And i will use them all like this:
select * from T
where Col1 like i_search_par1
and Col2 like i_search_par2
and
Col30 like i_search_par30You could write a very simple user-defined function. It would be slower, but the query would be a tiny bit simpler:
select * from T
where my_like (Col1, i_search_par1) = 1
and my_like (Col2, i_search_par2) = 1
and my_like (Col30, i_search_par30) = 1
Then you suggest that i sgould do string replacement 30 times for each parameter?Do you mean 1 time for each parameter, or 30 times altogether? Yes.
Isn't there better solution?
Maybe database has instruction that changes interpetation of symbol "*" into "%".It would be handy, but I don't think such a thing exists. -
Hi,
I was just wondering if there is any operator in OAFramework which is similar to "LIKE" operator in PL/SQL?
ThanksActually 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 -
Hi Everyone
Please help me to construct a PowerQuery With help of LIKE operator SQL Query
Below is my sample Query
select * from
abc where
LastModifiedDate
like
'2012-02-06%'
Thanks In Advance..Hi
Not sure if you are trying to:
use Like in a PQ, in which case Chris Webb's blog is very helpful Implementing A Basic LIKE/Wildcard Search Function In Power Query or
are you trying to pass a parameter through to a SQL Query in which case I just posted a suggestion to a similar question here How
to pass date dynamically to SqlQuery in PowerQuery
Hope this helps -
Like operator(NonCase sensitive)
Hi,
Every Body, I need query that use the like operator for pattern matching but that pattern
matching should be Non case sensitive is there any keywords that make like operater NonCase
Sensitive,
query like is ,
select * from table_name where column_name like 'matchingword';
that is in the Oracle 9i database..
please kindly help me ,
Regard's
Paritosh tomar
Edited by: user632002 on Sep 12, 2008 3:03 AMhb venki wrote:
Hi,
Try like this but i never like that of function,
select from table_name where UPPER(column_name) like UPPER(LOWER('mAtchINgwoRd'));*
hb venkiThe LOWER function there is not needed *{:-) -
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%"); -
Select Performance problems using the 'like' operator
I have a PL/SQL procedure that uses a cursor which contains a 'like' operator in the where clause. I have two database instances that are theoretically the same, however this code processes about 100,000 rows in 5 minutes on one database and 100,000 rows in several weeks on the other database. I know it is the 'like' operator that is causing the problem, but I don't know where to look in the database setup parameters as to what could be different between the two. Can someone point me in the right direction?
I tried to think of another way to write the query, but I really need to use the wildcard option on the data I'm searching for. The system I'm working with attaches a suffix to the end of every ID (ie. '214-222-1234-0') The suffix ('-0') increments but the rest of the ID stays the same ('-1','-2',etc...), but I want to find all of the rows where the first 12 characters are the same, so I strip off the suffix and use a wildcard '%' in its place. I tried adding the SUBSTR() function to the left hand column of the where clause, but it was even slower than using the 'like' operator. I know its a sound query, I just can't figure out why it works fine on one database and not the other.
-
Hi all,,
In sqldeveloper ,
I have 2 columns named A and B. column 'A' has data 1 for all rows.
column 'B' has data 12 for all rows. ( ref.below example)
my requirement is that, i need to get 'C' column and the first row of 'C' should be the total of A+B i.e, 1+12 which will give the answer 13.
Next row of column 'C' should retrieve the answer as 14. i.e, answer of 1st row of C's data + 2nd row of A's data and so on for all rows. Do i need to use any operator functions or which method can i achieve this?
eg:
A B C
1 12 13
1 12 14
1 12 15
1 12 16
1 12 17
thanks in advance.What an odd question.
If it is just A+B from the first row and then cumulatively adding A from the subsequent rows then something along the lines of...
SQL> create table tblsum(a number, b number);
Table created.
SQL> insert into tblsum (a, b) values (1,12);
1 row created.
SQL> insert into tblsum (a, b) values (1,12);
1 row created.
SQL> insert into tblsum (a, b) values (1,12);
1 row created.
SQL> insert into tblsum (a, b) values (1,12);
1 row created.
SQL> insert into tblsum (a, b) values (1,12);
1 row created.
SQL> select a, b, sum(a+(case when rownum=1 then b else 0 end)) over (order by rownum) as d from tblsum;
A B D
1 12 13
1 12 14
1 12 15
1 12 16
1 12 17
SQL> insert into tblsum (a,b) values (3, 15);
1 row created.
SQL> select a, b, sum(a+(case when rownum=1 then b else 0 end)) over (order by rownum) as d from tblsum;
A B D
1 12 13
1 12 14
1 12 15
1 12 16
1 12 17
3 15 20
6 rows selected.but we really need something to distinguish what order the rows are in... which is difficult when all (or most) of the data is identical.
We could even do something like...
SQL> select a, b, min(b) over ()+count(*) over (order by rownum) from tblsum;
A B MIN(B)OVER()+COUNT(*)OVER(ORDERBYROWNUM)
1 12 13
1 12 14
1 12 15
1 12 16
1 12 17But.... why? that's the question. -
Problem in Adhoc Query's set operation functionality.
Hi Experts,
I am facing problem executing Adhoc Query's set operation functionality.
In Selection Tab, following operations are performed :-
Execute a query and mark it as 'Set A'.(Say Hit list = X)
Execute another query and mark it as 'Set B'.(Say Hit list = Y)
In Set operation Tab, following operations are performed :-:-
Carry out an Operations 'Set A minus Set B'.
which results in Resulting Set = Z.
Transfer the resulting set 'in hit list' and press the copy resulting set button.
In Selection Tab, Hit list is populated with Z.
And when output button is pressed, I get to see 'Y' list and not 'Z' list.
Kindly help.
Thanks.
YogeshHi Experts,
I am facing problem executing Adhoc Query's set operation functionality.
In Selection Tab, following operations are performed :-
Execute a query and mark it as 'Set A'.(Say Hit list = X)
Execute another query and mark it as 'Set B'.(Say Hit list = Y)
In Set operation Tab, following operations are performed :-:-
Carry out an Operations 'Set A minus Set B'.
which results in Resulting Set = Z.
Transfer the resulting set 'in hit list' and press the copy resulting set button.
In Selection Tab, Hit list is populated with Z.
And when output button is pressed, I get to see 'Y' list and not 'Z' list.
Kindly help.
Thanks.
Yogesh
Maybe you are looking for
-
Error message when restoring my 4th generation iPod touch
I own a 4th generation iPod touch. Eventually the device it self became slow. So there fore I tried to restore it. But unfortunately, the process failed. I tried this method several times and It gives an error message every time when start the proces
-
Receivable Credit Memo document sequencing
Hi, How can we implement gapless document numbering of Credit Memos in AR? Is it the same as the setup for Invoice? wherin we define document sequences and assign? I create a dcoument sequence for the Thanks for the help. Regards, Mangvoc
-
I'm currently experiencing a problem when a supervisor (which has a webview reporting ID in the active directory) tries to generate a team report. It shows the following error: "There are no items available, because you are not authorized to view thi
-
[Resolved] pacman has stopped updating my system
For three days, "pacman -Syu" has said it is updating my repositories, then informed me, "There is nothing to do." Today, I looked on the Arch homepage and saw that there is supposed to be an updated version of btrfs-progs to 3.17.3-1. I ran "pacman
-
Apple TV unable to connect to wireless internet.
Many people seen to have this same connection problem of Apple TV with the internet. I have to unplug the power cord to restart. When it powers back up, I am unable to open "settings" which seems to be the only way to check or change things. All o