Like Query
Guyz What wrong with my query?
Im using form 6i database 9i
IF :CTRL.DIS_SRCH IS NULL THEN
ALERT_MESSAGES('Enter some words to search database');
ELSE
SET_BLOCK_PROPERTY('COR_ITEM_DESCP', DEFAULT_WHERE, UPPER('ITEM_DESCP')LIKE UPPER('%'||:CTRL.DIS_SRCH||'%''');
GO_BLOCK('COR_ITEM_DESCP');
EXECUTE_QUERY;
END IF;As my query working fine below.
AMC>SELECT ITEM_ID,CATEGORY,ITEM_DESCP FROM COR_ITEM_DESCP WHERE upper(ITEM_DESCP) LIKE upper('%&ITEM_NAME%')
2 /
Enter value for item_name: CA
old 1: SELECT ITEM_ID,CATEGORY,ITEM_DESCP FROM COR_ITEM_DESCP WHERE upper(ITEM_DESCP) LIKE upper('%&ITEM_NAME%')
new 1: SELECT ITEM_ID,CATEGORY,ITEM_DESCP FROM COR_ITEM_DESCP WHERE upper(ITEM_DESCP) LIKE upper('%CA%')
ITEM_ID CATEGORY
ITEM_DESCP
1010124 BANDAGES
UNICAST COTTON 5 CM
1010125 BANDAGES
UNICAST COTTON 10 CM 3X4
1010126 BANDAGES
CASTING TAPE (FIBER GLASS) 3 INCH
1010127 BANDAGES
CASTING TAPE (FIBER GLASS) 4 INCH 4X4
1010139 GLOVES
SURGICAL GLOVES 7 CM
1010140 GLOVES
SURGICAL GLOVES 7.5 CM
1010141 GLOVES
ITEM_ID CATEGORY
ITEM_DESCP
SURGICAL GLOVES 8 CM
1010156 SYRINGES
SCALP VEIN SET 22G
1010157 SYRINGES
SCALP VIEN SET 24G
1010158 SYRINGES
I.V CANNULA 22G
1010159 SYRINGES
I.V CANNULA 24G
1010165
THERMOSCAN COVER
1010168
SURGICAL BLADE 11
ITEM_ID CATEGORY
ITEM_DESCP
1010169
SUGRICAL BLADE 15
1010176
SUFUNE CATGUT - 2/0
1010177
SUFUNE CATGUT - 3/0
1010193
FOLEY CATHETER 12
1010194
FOLEY CATHETER 14
1010195
FOLEY CATHETER 16
ITEM_ID CATEGORY
ITEM_DESCP
1010196
FOLEY CATHETER 18
1010197
FOLEY CATHETER 20
1010200
SUCTON CATHETOR 10
1010201
SUCTON CATHETOR 12
1010202
SUCTON CATHETOR 14
1010207 PRINTING STUFF
PATIENT CARD
1010209 PRINTING STUFF
ITEM_ID CATEGORY
ITEM_DESCP
PRESCRIPTION CASH
1010224 PRINTING STUFF
MEIDCAL REPORT BOOKS
1010237 PRINTING STUFF
CASH PAYMENT VOUCHER
1010238 PRINTING STUFF
CASH RECEIVED VOUCHER
29 rows selected.
I solved by modifying the below code....
SET_BLOCK_PROPERTY('COR_ITEM_DESCP', DEFAULT_WHERE, 'UPPER(ITEM_DESCP)LIKE UPPER(:CTRL.DIS_SRCH)||''%''');Regards
Moazam Shareef
Similar Messages
-
Dear all,
can i doing regex query in SAP B1?
And how to use 'like' query with table, i mean :
SELECT * FROM test T0 INNER JOIN test2 T1
WHERE T0 LIKE '%T1.testfield%'
thanks for your helpwait - something came out funny in the previous posting - the system highlighted the name "field" with blue - that is NOT what I typed...
instead I typed...
"field" between two brackets ( bracket = [ and the other bracket - I cannot type them in because they come out as a different character)
what the heck is going on with the forum here??? I am seeing this highlighting in other postings as well...
Hope THIS one comes out correctly
Edited by: Zal Parchem on Dec 29, 2007 2:47 PM -
Hey Can Anyone tell me how ca i execute like query using jdbc odbc bridge
when i use the following syntax it gives me an error
select topicid,name,subject from topic where subject like("subject1%")
or
select topicid,name,subject from topic where subject like("subject1*")
both of the statements issue an error
Please Help
asap
Thanxwhen i use the following syntax it gives me an error
select topicid,name,subject from topic where subject
like("subject1%")You need to use single quotes instead of double quotes.
SELECT topicid, name, subject FROM topic WHERE subject LIKE 'subject1%' -
Is there any LIKE query equivalent in XML?
Is there any LIKE query equivalent in XML?
I would like the display words starts with 'A' in flex list, vice versa. I send A as a input.
Any ideas?Hi,
I don't know that one - but with slight modification I can filter nodes values also - not onlyl attributes:
var people:XML = <people>
<person>
<firstName>Peter</firstName>
</person>
<person>
<firstName>Auguste</firstName>
</person>
<person>
<firstName>Gregory</firstName>
</person>
<person>
<firstName>Andy</firstName>
</person>
</people>
(so we have nodes that have values - not attributtes)
and then e.g.:
var peopleList:XMLList = people.person.(firstName.charAt(0) == "A");
trace(peopleList);
(this is dynamic statement - you could replace "A" with variable reference, etc)
Edit;
I've googled interesting article you could read on that subject here:
http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=4
hth,
regards,
Peter
Message was edited by: Peter Blazejewicz -
Cm:select performance problem with multiple likes query clause
I have query like <br>
<b>listItem like '*abc.xml*' && serviceId like '*xyz.xml*'</b><br>
Can we have two likes clauses mentioned above in the cm:select. The above is executing successfully but takes too much time to process. <br><br>
Can we simplify the above mentioned query or any solution. Please help me in this issue.<br><br>
Thanks & Regards,<br>
Murthy NalluriA few notes:
1. You seem to have either a VPD policy active or you're using views that add some more predicates to the query, according to the plan posted (the access on the PK_OPERATOR_GROUP index). Could this make any difference?
2. The estimates of the optimizer are really very accurate - actually astonishing - compared to the tkprof output, so the optimizer seems to have a very good picture of the cardinalities and therefore the plan should be reasonable.
3. Did you gather index statistics as well (using COMPUTE STATISTICS when creating the index or "cascade=>true" option) when gathering the statistics? I assume you're on 9i, not 10g according to the plan and tkprof output.
4. Looking at the amount of data that needs to be processed it is unlikely that this query takes only 3 seconds, the 20 seconds seems to be OK.
If you are sure that for a similar amount of underlying data the query took only 3 seconds in the past it would be very useful if you - by any chance - have an execution plan at hand of that "3 seconds" execution.
One thing that I could imagine is that due to the monthly data growth that you've mentioned one or more of the tables have exceeded the "2% of the buffer cache" threshold and therefore are no longer treated as "small tables" in the buffer cache. This could explain that you now have more physical reads than in the past and therefore the query takes longer to execute than before.
I think that this query could only be executed in 3 seconds if it is somewhere using a predicate that is more selective and could benefit from an indexed access path.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
"CONNECT BY"-like query using XPath
Greetings!
The problem is as follows:
I have a XML document whose main part contains a set of many subelements names "rasterFile". Each of this elements has an attribute "rasterRefId" which refers to another rasterFile element (to its id attribute). These references form a tree-like structure of parent and child rasters.
What we need is to be able to effectively extract a subset of this structure, e.g. for rasterFile with id="4" we need to get this element, its referenced elements, and the elements referenced by the previously referenced elements (but we may request event four or five levels).
Using a relation database, we should use the CONNECT BY statement, but the document is stored in a XMLType table containing only one row (we use only one large document). So I need to do this sort of query in XPath. How? Or is there any other way to do that?
Thanks in advance.
Petr
The sample document (shortened, the original has about ten thousand rasterFile elements):
<ber:backdropData xmlns:ber="http://www.berit.com/ber">
<ber:name>bdemx</ber:name>
<ber:description/>
<ber:backdropLayer backdropRefId="bt_5002826" structure="hierarchical"
format="jpeg">
<ber:rasterFile id="ti_bt_5002826_jpeg_0_0x0" name="0-0x0.jpeg" decreaseRatio="2">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>1.2996519899999999 1.2996519899999999</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_1_1x1" name="1-1x1.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_0_0x0">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.6498259949999999 0.6498259949999999</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_1_1x0" name="1-1x0.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_0_0x0">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.6498259949999999 0.6498259949999999</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_1_0x1" name="1-0x1.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_0_0x0">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.6498259949999999 0.6498259949999999</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_1_0x0" name="1-0x0.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_0_0x0">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.6498259949999999 0.6498259949999999</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_3x3" name="2-3x3.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_1x1">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_3x2" name="2-3x2.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_1x1">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_3x1" name="2-3x1.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_1x0">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_2x3" name="2-2x3.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_1x1">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_2x2" name="2-2x2.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_1x1">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_2x1" name="2-2x1.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_1x0">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
<ber:shear>0.0 0.0</ber:shear>
<ber:translate>633142.205995 239189.641789</ber:translate>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_1x3" name="2-1x3.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_0x1">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_1x2" name="2-1x2.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_0x1">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_1x1" name="2-1x1.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_0x0">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_1x0" name="2-1x0.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_0x0">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_0x3" name="2-0x3.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_0x1">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_0x2" name="2-0x2.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_0x1">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_0x1" name="2-0x1.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_0x0">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
<ber:rasterFile id="ti_bt_5002826_jpeg_2_0x0" name="2-0x0.jpeg" decreaseRatio="2" rasterRefId="ti_bt_5002826_jpeg_1_0x0">
<ber:size>1000 1000</ber:size>
<ber:trMatrixCoord>
<ber:scale>0.32491299749999997 0.32491299749999997</ber:scale>
</ber:trMatrixCoord>
</ber:rasterFile>
</ber:backdropLayer>
</ber:backdropData>Thanks for reply.
Well, the view doesn't seem to help me. We have only one xml document stored and therefore there is only one row in the XMLType table. Using the "SELECT extract()" statement returns one row containing whole result (in CLOB or whatever) and the view has the same problem.
What would solve this problem is the query for a collection of elements that would return each resulting element in a single row. But I haven't been able to find out how to do such a thing.
Petr -
Looking for a keyword using like query which could contain multiple occurrence in the same column
I am facing an issue. A bunch of my frontend JSP code has been stored in few tables of my database (65 rows in a table), which I have identified using few like queries. Now I want to update a Href link which is present in all these queries. But since these column entries are very long (50-60 lines long) and it is possible that a few rows may the link (which is to be replaced), multiple times, I am not sure that if a simple update query using a single like will work for it or not?
Any suggestion/ideas are welcome.
Please let me know if you require any more info.Hi,
e5d4d744-cf66-4fe0-8353-bbd8fd826b21 wrote:
I am facing an issue. A bunch of my frontend JSP code has been stored in few tables of my database (65 rows in a table), which I have identified using few like queries. Now I want to update a Href link which is present in all these queries. But since these column entries are very long (50-60 lines long) and it is possible that a few rows may the link (which is to be replaced), multiple times, I am not sure that if a simple update query using a single like will work for it or not?
Any suggestion/ideas are welcome.
Please let me know if you require any more info.
Yes; whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), so that the people who want to help you can re-create the problem and test their ideas.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Simplify the problem as much as possible. For example, if your strings are sometimes up to 4000 characters long, you don't have to post any data that's nearly that long. You can probably show what you want with strings that are 80 characters long.
Always say which version of Oracle you're using (for example, 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002#9362002
This statement:
UPDATE table_x
SET str = REPLACE ( str
, old_link
, new_link
WHERE str LIKE '%' || old_link || '%'
will change all occurrences of old_link to new_link. It will only change the rows where old_link occurs, but, aside from that, it doesn't matter how many times old_link occurs in str: if it appears 2 times in the same str, then both occurrences will be changed to new_link.
Watch out for the "mother is in chemotherapy" problem. If old_link is 'bar.com', the statement above will change 'fubar.com'. You may need REGEXP_REPLACE and/or REGEXP_LIKE if you need to consider what (if anything) comes immediately before 'bar.com' when deciding whether or not to change it. -
I am using PHP and ORACLE and am having trouble with binding. I can get a basic bind to work, but I am having trouble with a more complex query like this:
$oracle_search_name = 'some input text';
$query1 = "SELECT source_title FROM records WHERE UPPER(source_title) LIKE UPPER('%$oracle_search_name%')";
It works OK without binding, but how can I replace $oracle_search_name with a bind variable? Simply replacing the $ sign with a colon doesn't seem to work.Hey cj,
Thanks for the help! That seems to do the trick.
I noticed that you capitalized the bind variable in the OciBindByName() function. Is that required? Here is my example:
OciBindByName($s, ":MY_BIND_VARIABLE", $my_bind_variable, -1); // Capitalized ":MY_BIND_VARIABLE"
Also, another question: Will Oracle automatically understand to bind multiple instances of the bind variable like this?
SELECT tid, col1, col2, col3 FROM test1 WHERE UPPER(col1) LIKE UPPER('%'||:my_bind_variable||'%') OR UPPER(col2) LIKE UPPER('%'||:my_bind_variable||'%')
That seems to work correctly but I am having trouble finding a detailed reference online about binding in Oracle.
Thanks again for the input. -
X-Path like Query option for XMLModel?
Hi,
is there an option to use x-path-like queries in the XMLModel?
E.g.
<?xml version="1.0" encoding="UTF-8"?>
<main>
<config>
<mode>1</mode>
<ext>
<item date="January 2009">
<unit>900</unit>
<current>1</current>
<interactive>1</interactive>
</item>
</ext>
</config>
<config>
<mode>2</mode>
<ext>
<item date="February 2009">
<unit>400</unit>
<current>2</current>
<interactive>5</interactive>
</item>
</ext>
</config>
</main>
and
var oTable2 = new sap.ui.table.Table();
oTable2.bindRows("/config['mode='1'']/ext");
to select a node directly?
The source is from an old Post [SAPUI5 - XMLModel] Xpath filter ? where the solution was to loop through the result.
Does SAPUI support X-Path like queries in the meantime?
Thanks,
OliverI'm not sure about an xpath query (which was deprecated in JCR 2.0), but here's how you could use the JCR API to retrieve all of the versions from a path:
* Returns all of the versions at the specified path as a List of Versions.
* @param session
* the currect JCR session, must not be null
* @param path
* the absolute path of the node to retrieve
* @return the list of versions at the specified path
* @throws UnsupportedRepositoryOperationException
* thrown if the node at the specified path is not versionable
* @throws RepositoryException
* an unexpected exception occurs interacting with the JCR
* repository
public List<javax.jcr.version.Version> getVersions(final Session session,
final String path) throws UnsupportedRepositoryOperationException,
RepositoryException {
final List<Version> versions = new ArrayList<Version>();
final VersionManager versionMgr = session.getWorkspace()
.getVersionManager();
final VersionHistory versionHistory = versionMgr
.getVersionHistory(path);
final VersionIterator versionIterator = versionHistory.getAllVersions();
while (versionIterator.hasNext()) {
versions.add(versionIterator.nextVersion());
return versions; -
create table t1(id1 number,name varchar2(10));
create table t2(id1 number,id2 number,name_value varchar2(10));
create table t3(id2 number, name1 varchar2(10));
insert into t1 (ID1, NAME)
values (1, 'dave');
insert into t1 (ID1, NAME)
values (2, 'rob');
insert into t1 (ID1, NAME)
values (3, 'matt');
insert into t1 (ID1, NAME)
values (4, 'mike');
insert into t2 (ID1, ID2, NAME_VALUE)
values (1, 6, 'val1');
insert into t2 (ID1, ID2, NAME_VALUE)
values (2, 6, 'val2');
insert into t2 (ID1, ID2, NAME_VALUE)
values (3, 7, 'val3');
insert into t2 (ID1, ID2, NAME_VALUE)
values (4, 7, 'val4');
insert into t3 (ID2, NAME1)
values (6, 'snap');
insert into t3 (ID2, NAME1)
values (7, 'tom');
insert into t3 (ID2, NAME1)
values (8, 'harry');
insert into t3 (ID2, NAME1)
values (9, 'katie');
i want output as
name1 DAVE rob matt mike as columns
snap val1 val2 null null
tom null null val3 val4SolomonYakobson wrote:
Why do you group by?
Because I confused myself ?
I included all columns in initial query:
( select t1.id1, t2.id2,
t1.name,
t2.name_value,
t3.name1
Because of that, the pivot returns looking like this:
ID1 ID2 NAME1 'dave' 'rob' 'matt' 'mike'
3 7 tom val3
2 6 snap val2
1 6 snap val1
4 7 tom val4
4 rows selected.
So yeah, remove those from the initial part, and don't need the group by.
Didn't notice that. Thanks for pointing it out. -
Hi
I am new to Performance tuning and I know only very basic things.
My DB version is 10.2.0.4.
I want to tune my query which uses like clause and it is a dynamically created with either left truncation or right truncation or both.
I found in some sites that catserach will solve my problem and i tried the same in test DB.
So I did the following.
SQL >alter system flush buffer_cache;
GRANT EXECUTE ON CTX_DDL TO user;
EXEC CTX_DDL.DROP_INDEX_SET('test_set');
EXEC CTX_DDL.CREATE_INDEX_SET('test_set');
EXEC CTX_DDL.ADD_INDEX('test_set','d');
create index test_table_idx on test_table(c) INDEXTYPE IS CTXSYS.CTXCAT PARAMETERS ('index set test_set');
SQL> SELECT COUNT(*) COUNT, a, b FROM test_table
WHERE UPPER(c) LIKE '%270%' AND d = 0 GROUP BY a, b ;
5664 rows selected.
Elapsed: 00:00:12.29
Execution Plan
Plan hash value: 4088289091
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Ti
me |
| 0 | SELECT STATEMENT | | 59358 | 1739K| | 8039 (4)| 00:01:37 |
| 1 | HASH GROUP BY | | 59358 | 1739K| 5144K| 8039 (4)| 00:01:37 |
|* 2 | TABLE ACCESS FULL| test_table | 59358 | 1739K| | 7547 (4)| 00:01:31 |
Predicate Information (identified by operation id):
2 - filter(UPPER("C") LIKE '%270%' AND "D"=0)
Statistics
812 recursive calls
0 db block gets
33459 consistent gets
33206 physical reads
0 redo size
168223 bytes sent via SQL*Net to client
4639 bytes received via SQL*Net from client
379 SQL*Net roundtrips to/from client
22 sorts (memory)
0 sorts (disk)
5664 rows processed
SQL >alter system flush buffer_cache;
SQL> SELECT COUNT(*) COUNT, COUNT, a, b FROM test_table
WHERE CATSEARCH(C,'<query> <textquery grammar="context">%270% </textquery></query>',NULL) > 0
GROUP BY a, b;
5664 rows selected.
Elapsed: 00:00:27.51
Execution Plan
Plan hash value: 2203090224
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 59369 | 2261K| | 606 (2)| 00:00:08 |
| 1 | HASH GROUP BY | | 59369 | 2261K| 6072K| 606 (2)| 00:00:08 |
| 2 | TABLE ACCESS BY INDEX ROWID| test_table | 59369 | 2261K| | 2 (0)| 00:00:01 |
|* 3 | DOMAIN INDEX | test_table_idx | | | | | |
Predicate Information (identified by operation id):
3 - access("CTXSYS"."CATSEARCH"("C",'<query> <textquery grammar="context">%270% </textquery></query>',NULL)>0)
Statistics
17856 recursive calls
0 db block gets
26550 consistent gets
9047 physical reads
0 redo size
168223 bytes sent via SQL*Net to client
4639 bytes received via SQL*Net from client
379 SQL*Net roundtrips to/from client
8 sorts (memory)
0 sorts (disk)
5664 rows processed.
I did all the above steps purely from reading some documents.
Can anyone explain me
1. if catsearch is the best option based on the stats (as catsearch option has many recursive calls).
2. What is the purpose of Oracle Grammar
3. What is the purpose of EXEC CTX_DDL.CREATE_INDEX_SET('test_set'); ??
4. I used grammar only for right and both side truncation and for left truncation my where clause is
WHERE CATSEARCH(C,'1044*',NULL) > 0 AND D = 0 GROUP BY A,B;
Also Can I modify the above where clause as
WHERE CATSEARCH(C,'1044*',' D = 0 ' > 0 GROUP BY A,B;
and explain the same pls.Here is the Trace for bit map.
DROP INDEX test_table_idx;
CREATE bitmap INDEX test_table_idx ON test_table(c) PARALLEL 20 nologging;
SELECT COUNT(*) COUNT, a, b FROM test_tableWHERE UPPER(c) LIKE '1044270%' AND d = 0 GROUP BY a, b
Elapsed: 00:00:00.85
Execution Plan
Plan hash value: 7812215
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 59358 | 1739K| | 87592 (1)| 00:17:32 |
| 1 | HASH GROUP BY | | 59358 | 1739K| 5144K| 87592 (1)| 00:17:32 |
|* 2 | TABLE ACCESS BY INDEX ROWID | test_table | 59358 | 1739K| | 87100 (1)| 00:17:26 |
| 3 | BITMAP CONVERSION TO ROWIDS| | | | | | |
|* 4 | BITMAP INDEX FULL SCAN | test_table_idx | | | | | |
Predicate Information (identified by operation id):
2 - filter("C"=0)
4 - filter(UPPER("C") LIKE '1044270%')
Statistics
1 recursive calls
0 db block gets
5310 consistent gets
0 physical reads
0 redo size
657 bytes sent via SQL*Net to client
492 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SELECT COUNT(*) COUNT, a, b FROM test_table WHERE UPPER(c) LIKE '10%' AND d = 0 GROUP BY a, b ;
687644 rows selected.
Elapsed: 00:00:35.26
Execution Plan
Plan hash value: 7812215
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 59358 | 1739K| | 87592 (1)| 00:17:32 |
| 1 | HASH GROUP BY | | 59358 | 1739K| 5144K| 87592 (1)| 00:17:32 |
|* 2 | TABLE ACCESS BY INDEX ROWID | test_table | 59358 | 1739K| | 87100 (1)| 00:17:26 |
| 3 | BITMAP CONVERSION TO ROWIDS| | | | | | |
|* 4 | BITMAP INDEX FULL SCAN | test_table_idx | | | | | |
Predicate Information (identified by operation id):
2 - filter("C"=0)
4 - filter(UPPER("C") LIKE '10%')
Statistics
21 recursive calls
0 db block gets
246786 consistent gets
10328 physical reads
0 redo size
20956978 bytes sent via SQL*Net to client
504754 bytes received via SQL*Net from client
45844 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
687644 rows processed
SELECT COUNT(*) COUNT, a, b FROM test_table WHERE UPPER(c) LIKE '%EXT' AND d = 0 GROUP BY a, b
118760 rows selected.
Elapsed: 00:01:13.34
Execution Plan
Plan hash value: 7812215
| Id | Operation | Name | Rows | Bytes |TempS
pc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 59358 | 1739K| | 87592 (1)| 00:17:32 |
| 1 | HASH GROUP BY | | 59358 | 1739K| 5144K| 87592 (1)| 00:17:32 |
|* 2 | TABLE ACCESS BY INDEX ROWID | test_table | 59358 | 1739K| | 87100 (1)| 00:17:26 |
| 3 | BITMAP CONVERSION TO ROWIDS| | | |
| | |
|* 4 | BITMAP INDEX FULL SCAN | test_table_idx | | | | | |
Predicate Information (identified by operation id):
2 - filter("C"=0)
4 - filter(UPPER("C") LIKE '%0EXT')
Statistics
1 recursive calls
0 db block gets
122629 consistent gets
13682 physical reads
0 redo size
3534421 bytes sent via SQL*Net to client
87579 bytes received via SQL*Net from client
7919 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
118760 rows processed -
Hello!
I'm building dinamic SQL to query a products table, and i use LIKE '%xxx%' statements
to search the table. How can i optimize this?
Oracle would not use any index, isn't it?
READ ONLY transactions would speed anything?
Thanks.,
ferranIf you're searching on, say, a product description, you might want to consider using interMedia.
I worked on a database behind a web-site that held many documents. These documents could be searched for a word or phrase, and response time was near instantaneous. A bit more set-up is required than simple sticking the text in a VARCHAR2, but the payback is much more flexible, powerful (and fast!) searching.
Using READ ONLY transactions might give you a small speed advantage, but nothing that will significantly conteract the effect of LIKE '%xxx%'.
null -
Like Query with Case insensitive
Hi ,
I have select query with Like, need to add case insenstive for that.
E.g
Select * from emp where empname like ('D%').
The above query will fetch only names starting with 'D' not the name starting with 'd'.But i need to fetch all the name starting with D or d. Can anyone help me out with this query.
Thanks
DuraiHi
Use uppercase for example:
Select * from emp where upper(empname) like ('D%');
Ott Karesz
http://www.trendo-kft.hu -
Help with simple LIKE query...
I have a person table, the person table has a field which has their interests... In a form they choose which interests they have i.e. swimming, tennis through checkboxes. What i don't get IS how do i create a query based on this? (for example one person likes swimming and the other tennis:
SELECT * from Person WHERE interests LIKE '%Swimming%Tennis%';
the above gives me 0 results any ideas?You can avoid difficult application issues by enabling a more appropriate schema.
Here is a very basic schema that may or may not work for you, but I hope it will give you some ideas. I did not create any unique indexes in this sample, but both PERSON and INTEREST table would have a unique index created on them. The PERSON_INTEREST table would have a non-unique index created for it. I also included a query that shows how to correctly query against this schema. This is in Oracle syntax, but the DDL should be similar to whatever DBMS you are using, and the SQL should be the same.
I'll be honest, this might be overkill for what you are attempting, but if you plan on extending your project / assignment in anyway, you would be better off with a more complete schema. I hope it helps. Good luck on your project / assignment.
CREATE TABLE PERSON (PERSON_ID NUMBER, NAME_LAST VARCHAR2(20), NAME_FIRST VARCHAR2(20), EMAIL VARCHAR2(30));
CREATE TABLE INTEREST (INTEREST_ID NUMBER, INTEREST_DESC VARCHAR2(20));
CREATE TABLE PERSON_INTEREST (PERSON_ID NUMBER, INTEREST_ID NUMBER);
INSERT INTO PERSON VALUES(1, 'SMITH','JOHN','[email protected]');
INSERT INTO PERSON VALUES(2, 'JONES','FRED','[email protected]');
INSERT INTO PERSON VALUES(3, 'ANDERSON','TOM','[email protected]');
INSERT INTO PERSON VALUES(4, 'JACOBSEN','SAM','[email protected]');
INSERT INTO PERSON VALUES(5, 'PUCKETT','KIRBY','[email protected]');
INSERT INTO INTEREST VALUES (1,'TENNIS');
INSERT INTO INTEREST VALUES (2,'SWIMMING');
INSERT INTO INTEREST VALUES (3,'BOWLING');
INSERT INTO INTEREST VALUES (4,'TABLE TENNIS');
INSERT INTO INTEREST VALUES (5,'FISHING');
INSERT INTO PERSON_INTEREST VALUES (1,1);
INSERT INTO PERSON_INTEREST VALUES (1,3);
INSERT INTO PERSON_INTEREST VALUES (1,5);
INSERT INTO PERSON_INTEREST VALUES (2,2);
INSERT INTO PERSON_INTEREST VALUES (2,3);
INSERT INTO PERSON_INTEREST VALUES (3,1);
INSERT INTO PERSON_INTEREST VALUES (3,2);
INSERT INTO PERSON_INTEREST VALUES (4,2);
INSERT INTO PERSON_INTEREST VALUES (4,3);
INSERT INTO PERSON_INTEREST VALUES (5,4);
INSERT INTO PERSON_INTEREST VALUES (5,5);
// Find all the Interests for a Person
SELECT
A.NAME_LAST,
A.NAME_FIRST,
B.INTEREST_DESC
FROM
PERSON A,
INTEREST B,
PERSON_INTEREST C
WHERE
A.NAME_LAST = 'SMITH'
AND A.NAME_FIRST = 'JOHN'
AND A.PERSON_ID = C.PERSON_ID
AND B.INTEREST_ID = C.INTEREST_ID
ORDER BY 3
NAME_LAST NAME_FIRST INTEREST_DESC
SMITH JOHN BOWLING
SMITH JOHN FISHING
SMITH JOHN TENNIS
// Find all people who likes to swim and bowl
SELECT
A.NAME_LAST,
A.NAME_FIRST
FROM
PERSON A,
INTEREST B,
PERSON_INTEREST C
WHERE
B.INTEREST_DESC IN ('SWIMMING', 'BOWLING')
AND B.INTEREST_ID = C.INTEREST_ID
AND A.PERSON_ID = C.PERSON_ID
GROUP BY
A.NAME_LAST,
A.NAME_FIRST
ORDER BY 1,2
NAME_LAST NAME_FIRST
ANDERSON TOM
JACOBSEN SAM
JONES FRED
SMITH JOHN
-
Hi
I have a situation where in my main query's where clause I have to use like ('% <value returned from query2>%'). However, my query2 can return multiple rows.
It is something like this:
Select .....
from table1 t1
where path like ('%<query2>%').
Path can have multiple values - it is just representing a parent child relationship like 1/2/3. 1 is a parent of 2. 2 is a parnt of 3 and so on. What I get from query2 could be either of these. So I have to use like and not in. How may I achieve this?select lvl,
Path
from (select distinct level as lvl,
sys_connect_by_path(parent,'/') Path
from table1 t1
connect by prior child = parent)
where instr(path,((select parent --+
from (select parent, sm, rank() over (order by sm desc) r |
from (SELECT parent, SUM(CT1) as sm |
FROM ((select parent,count(child) ct1 |
from table1 t1 |
where group by parent |
-- end level 1) |
UNION ALL |
(select parent, count(child) ct2 | try to move this sub-query
from table1 t1 | at the FROM clause
where child in --first level |
(select parent |
from (select distinct parent,count(child) ct1 |
from table1 t1 |
where group by parent) q1)-- end level 1 |
group by parent))--MAIN SEL |
GROUP BY parent)) |
where r =1))) > 0--end instr --+
and lvl = 1
you may try to move sub-queries in your WHERE clause to the FROM clause.
Message was edited by:
Warren Tolentino
justin has the same idea :D
Maybe you are looking for
-
Facebook images do not load after upgrading to 6.0. What to do?
After upgrading to Firefox 6.0 my Facebook images will not open. I see a white box with a frame but after clicking on it a totally black square opens up instead a photo. All is OK when using IE9. (Also, the same with Twitpics on Twitter.)
-
Hi, Can you help me to resolve this issue? 1.I have sites A (Singapore) and B (India) 2.At site A (Singapore) there is a Cisco router with VWIC-2MFT-T1 is connected to PBX T1 port.(120 users are sitting with a hand set) 3.This router is also connecte
-
Hi all: I'm using MS Project Professional 2007 and I created the schedule as an .mpp file and assigned resources before I loaded the schedule to the EPM server. I created the resource names consistently with the names in the Enterprise resource pool
-
Why can't i download itunes to windows 8.1
I just purchased a computer with Windows 8.1. Every time I attempt to download Apple I Tunes, it says that download is complete, but it is no where to be found on my computer. I had Windows XP and all of my tunes are on that computer. I want to trans
-
How to configure OC4J to force the access only to one page after the log in
Hi, I want to know how could I force the access to only one page of the web application when the user first time accesses. I don't want to use session. Is there another way, say by configuring the OC4J configuration files? Thanks