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))
||'%' )
Similar Messages
-
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 issueDear 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 -
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. -
How to use LIKE Operator with my query requriment
HI all,
I have a requirement as follows
EMPID ENAME JOB SAL
10 RAJ KAMAL MANAGER 25000
20 KAMAL RAJ NAYAK CLERK 4000
30 NARENDAR GUPTA ANALYST 20000
40 ASHUTOSH GUPTA DEVELOPER 10000
50 ASHUTOSH NAYAR PROGRAMMER 15000
i am searching enames such that i need to get the whole name even if i search with just a single LETTER/WORD immaterial of the order they exist in the name for which i need to get the whole name.(INFACT WORD comparision)
ex:
1) select * from emp where ename like '%ka%'
i am getting:
10 RAJ KAMAL MANAGER 25000
20 KAMAL RAJ NAYAK CLERK 4000
This is not what i need i need just word camparision not letters comparision let me tell you...
select * from emp where ename like '%amal%'
Even for this query ill get the same output.. this is not my option to go..
I need just word comparision with starting letter and immaterial of the word position in the name
If it is possible to do with query please let me know..
Thanking you
Narendar VishwanathamFull example:
SQL> ed
Wrote file afiedt.buf
1 with e as (select 10 as empid, 'RAJ KAMAL' as ename, 'MANAGER' as job, 25000 as sal from dual union all
2 select 20, 'KAMAL RAJ NAYAK', 'CLERK', 4000 from dual union all
3 select 30, 'NARENDAR GUPTA', 'ANALYST', 20000 from dual union all
4 select 40, 'ASHUTOSH GUPTA', 'DEVELOPER', 10000 from dual union all
5 select 50, 'ASHUTOSH NAYAR', 'PROGRAMMER', 15000 from dual)
6 -- END OF TEST DATA
7 select *
8 from e
9* where regexp_like(ename,'(^| )KA( |$)')
SQL> /
no rows selected
SQL> ed
Wrote file afiedt.buf
1 with e as (select 10 as empid, 'RAJ KAMAL' as ename, 'MANAGER' as job, 25000 as sal from dual union all
2 select 20, 'KAMAL RAJ NAYAK', 'CLERK', 4000 from dual union all
3 select 30, 'NARENDAR GUPTA', 'ANALYST', 20000 from dual union all
4 select 40, 'ASHUTOSH GUPTA', 'DEVELOPER', 10000 from dual union all
5 select 50, 'ASHUTOSH NAYAR', 'PROGRAMMER', 15000 from dual)
6 -- END OF TEST DATA
7 select *
8 from e
9* where regexp_like(ename,'(^| )KAMAL( |$)')
SQL> /
EMPID ENAME JOB SAL
10 RAJ KAMAL MANAGER 25000
20 KAMAL RAJ NAYAK CLERK 4000
SQL> -
Hi All,
Can i use the LIKE operator in Select query to compare the Same field that starts with different values i.e.
CONCATENATE c_5051 c_% INTO l_val1.
CONCATENATE c_5101 c_% INTO l_val2.
SELECT prctr
INTO l_prctr
FROM bseg UP TO 1 ROWS
WHERE matnr = l_matnr
AND belnr = l_belnr
AND ( hkont LIKE l_val1
OR hkont LIKE l_val2 ).
ENDSELECT.
but it is failing even though ther is an entry in BSEG table satisfying hte given condition.
Regards,
Padmasri.HI,
u can use like operator in select statement where condition.
may be it is failing because of some other selections. please make sure whether the record with the corresponding selections is available in database or not.
rgds,
bharat. -
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 -
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 -
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? -
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 -
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 ?
reagrdskindly 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 -
Alternate query to LIKE operator
I have table with contains 65 lakes records, I need to delete the records which does not contains space in column values
Ex : table
Code test_num
NL 123 AP
NL 567ZP
NL 427 SL
NL 456IP
I had return the query like these Delete table A where test_num is not like ‘% %”;
But the problem is the query is getting hang. Because of I am using like operator
Please let me know is there is any alternate query to write
If there any PLSQL to write fetch the query 1laksh records and then delete the records
Deleted rows count is 20Lakuser13711017 wrote:
I had return the query like these Delete table A where test_num is not like ‘% %”;
But the problem is the query is getting hang. Because of I am using like operator
What makes you think so?
It could "hang" (you probably mean "take a long time") due to many other reasons:
- Your system is busy with other stuff and your process gets only partial system resources;
- There is a delete (row) trigger on that table that takes a lot of time;
- The table has many indexes, whose maintenance takes a lot of time;
I doubt it is "because of you using like operator"... -
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. -
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.SDear 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 -
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.
" -
Problem when using About Operator in Contains Query
Hi,
I'm new to Oracle and this forums too. I have a problem when using about operator in contains query.
I create a table with some records and then create a context index on 'name' column.
CREATE TABLE my_items (
id NUMBER(10) NOT NULL,
name VARCHAR2(200) NOT NULL,
description VARCHAR2(4000) NOT NULL,
price NUMBER(7,2) NOT NULL
ALTER TABLE my_items ADD (
CONSTRAINT my_items_pk PRIMARY KEY (id)
CREATE SEQUENCE my_items_seq;
INSERT INTO my_items VALUES(my_items_seq.nextval, 'Car', 'Car description', 1);
INSERT INTO my_items VALUES(my_items_seq.nextval, 'Train', 'Train description', 2);
INSERT INTO my_items VALUES(my_items_seq.nextval, 'Japan', 'Japan description', 3);
INSERT INTO my_items VALUES(my_items_seq.nextval, 'China', 'China description', 4);
COMMIT;
EXEC ctx_ddl.create_preference('english_lexer','basic_lexer');
EXEC ctx_ddl.set_attribute('english_lexer','index_themes','yes');
EXEC ctx_ddl.set_attribute('english_lexer','theme_language','english');
CREATE INDEX my_items_name_idx ON my_items(name) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('lexer english_lexer');
EXEC ctx_ddl.sync_index('my_items_name_idx');Then I perform contains query to retrieve record :
SELECT count(*) FROM my_items WHERE contains(name, 'Japan', 1) > 0;
COUNT(*)
1
SELECT count(*) FROM my_items WHERE contains(name, 'about(Japan)', 1) > 0;
COUNT(*)
1But the problem is when I using ABOUT operator like in Oracle's English Knowledge Base Category Hierarchy it return 0
SELECT count(*) FROM my_items WHERE contains(name, 'about(Asia)', 1) > 0;
COUNT(*)
0
SELECT count(*) FROM my_items WHERE contains(name, 'about(transportation)', 1) > 0;
COUNT(*)
0I can't figure out what 's wrong in my query or in my index.
Any help will be appreciated.
Thanks,
Hieu Nguyen
Edited by: user2944391 on Jul 10, 2009 3:25 AMHello (and welcome),
You'd be best asking this question in the Oracle Text forum, here:
Text
And by the way, it will help others to analyse if you put {noformat}{noformat} (lowercase code in curly brackets) before and after your code snippets.
Good luck!
Maybe you are looking for
-
Nasty table behavior (bug?) in FM 7.1 (structured)
Hello, I have found that an Import => Element Definitions... command changes paragraph styles in tables. Here what I've done (all in structured FM 7.1 WinXP): 1. opened new doc based on template. 2. added two identical tables - formats came from temp
-
I have the following setup done in Intercompany Solution: Branch 01 Localization = USA Local Currency = USD System Currency = USD Branch 02 Localization = USA Local Currency = USD System Currency = USD Branch 03 Localization = UK Local Currency = GBP
-
I I am trying to start a new catalog in the organizer and up loaded new elements
Iam having trouble with PSE 11. I uploaded new elements to day from PSE Basics and Beyond. It said it uploaded 100% but I COULD not go any further. the screen just froze. What is wrong? THis is the first time I have tried to use the organizer i
-
Hello everyone, I read in Janina´s post (Response options in Marketing Campaigns ) and in the Administrator guides that "Currently there is reporting and user interface selection based on the response option" But could someone please help me find the
-
the ipod are inactive, but i don´t forgotten the code. what can i do?