Using function based index causing connection to abort
My problem is as below
I m using oracle 8i data base
I have a table Dummy with column col1 .
I have created a function based index on col1
Now i try to update the table dummy using this function based index (i.e)
i run the following query
update dummy set col2='new value' where col1=ltrim(col2,'0')
now when i execute this statement it causes the connection to abort. It gives the error
ERROR at line 1:
ORA-03113: end-of-file on communication channel
But if i run select query (i.e) select col2 from dummy where col1=ltrim(col2,'0')
it executes sucessfully.
Also if i wrap the ltrim over some other function it works (i.e.)
update dummy set col2='new value' where col1=upper(ltrim(col2,'0'))
Any thoughts or ideas on what can be the reason...
plese let me know for any questions,clarifications..
Thanks in advance...
Balaji
Balaji, what is the exact error message returned? Remember to always include all the error details so that the problem can be identified and diagnosed.
If you mean you are getting an ORA-03113: end-of-file on communication channel, this means that the Oracle Server Process that serviced your client session, crashed.
In that case you need to refer to the alert log file on the database instance to see the server-side error message that resulted (often an ORA-0600 internal error) and the name of the trace file that was created at a result.
You also failed to specify the exact Oracle 8i version you are using. Make sure you're on the very last patch set released for 8i - that should be 8.1.7.4 as far as I recall.
Similar Messages
-
Problem using two function based indexes at once!
Hello Oracle!
I've got problems using two function based indexes on geometries at once.
The problem occures, when I use a spatial join between two geometries both using function based indexes.
The test case:
CREATE TABLE quad (centroid NUMBER);
CREATE TABLE points (no NUMBER, point MDSYS.SDO_GEOMETRY);
CREATE OR REPLACE FUNCTION getQuad (centroid NUMBER) RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC IS
BEGIN
RETURN MDSYS.SDO_GEOMETRY(2003, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),MDSYS.SDO_ORDINATE_ARRAY(centroid-5,centroid-5,centroid+5,centroid-5,centroid+5,centroid+5,centroid-5,centroid+5,centroid-5,centroid-5));
END;
INSERT INTO USER_SDO_GEOM_METADATA VALUES('quad','tiedge.getQuad(centroid)',MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', -100, 100, .0000001), MDSYS.SDO_DIM_ELEMENT('Y', -100, 100, .0000001)),NULL);
CREATE INDEX quad_idx on quad(getQuad(centroid)) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
INSERT INTO quad VALUES (0);
INSERT INTO quad VALUES (5);
INSERT INTO quad VALUES (10);
INSERT INTO points VALUES (1, MDSYS.SDO_GEOMETRY(1001,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1),MDSYS.SDO_ORDINATE_ARRAY(4,4)));
ALTER SESSION SET QUERY_REWRITE_INTEGRITY=TRUSTED;
ALTER SESSION SET QUERY_REWRITE_ENA[i]Long postings are being truncated to ~1 kB at this time.hi there,
For a better audience for this question, I'd look at the database forum.
guys on that will be a lot more familiar with FBIs
thanks
Barry -
Function-based index with OR in the wher-clause
We have some problems with functin-based indexes and
the or-condition in a where-clause.
--We use Oracle 8i (8.1.7)
create table TPERSON(ID number(10),NAME varchar2(20),...);
create index I_NORMAL_TPERSON_NAME on TPERSON(NAME);
create index I_FUNCTION_TPERSON_NAME on TPERSON(UPPER(NAME));
The following two statements run very fast on a large table
and the execution-plan asure the usage of the indexes
(-while the session is appropriate configured and the table is analyzed):
1) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%';
2) select count(ID) from TPERSON where NAME like 'Mil%' or (3=5);
In particular we see that a normal index is used while the where-clause contains
an OR-CONDITION.
But if we try the similarly select-statement
3) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%' or (3=5);
the CBO will not use the function-index I_FUNCTION_TPERSON_NAME and we have a full table scan in the execution-plan.
(This behavior we only expect with views but not with indexes.)
We ask for an advice like a hint, which enable the CBO-usage
of function-based indexes in connection with OR.
This problem seems to be artificial because it contains this dummy logic:
or (3=5).
This steams from an prepared statement, where this kind of boolean
flag reduce the amount of different select-statements needed for
covering the hole business-logic, while using bind-variables for the
concrete query-parameters.
A more realistic (still boild down) version of our select-statement is:
select * FROM TPERSON
where (upper(NAME) like 'MIL%' or (NAME is null))
and (upper(FIRSTNAME) like 'MICH% or (FIRSTNAME is null))
and ...;
thank you for time..
email: [email protected]In the realistic statement you write :
select * FROM TPERSON
where (upper(NAME) like 'MIL%' or (NAME is null))
and (upper(FIRSTNAME) like 'MICH% or (FIRSTNAME is null))
and ...;
as far as i know, NULL values are not indexed, "or (NAME is NULL)" have to generate a full table scan.
HTH
We have some problems with functin-based indexes and
the or-condition in a where-clause.
--We use Oracle 8i (8.1.7)
create table TPERSON(ID number(10),NAME varchar2(20),...);
create index I_NORMAL_TPERSON_NAME on TPERSON(NAME);
create index I_FUNCTION_TPERSON_NAME on TPERSON(UPPER(NAME));
The following two statements run very fast on a large table
and the execution-plan asure the usage of the indexes
(-while the session is appropriate configured and the table is analyzed):
1) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%';
2) select count(ID) from TPERSON where NAME like 'Mil%' or (3=5);
In particular we see that a normal index is used while the where-clause contains
an OR-CONDITION.
But if we try the similarly select-statement
3) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%' or (3=5);
the CBO will not use the function-index I_FUNCTION_TPERSON_NAME and we have a full table scan in the execution-plan.
(This behavior we only expect with views but not with indexes.)
We ask for an advice like a hint, which enable the CBO-usage
of function-based indexes in connection with OR.
This problem seems to be artificial because it contains this dummy logic:
or (3=5).
This steams from an prepared statement, where this kind of boolean
flag reduce the amount of different select-statements needed for
covering the hole business-logic, while using bind-variables for the
concrete query-parameters.
A more realistic (still boild down) version of our select-statement is:
select * FROM TPERSON
where (upper(NAME) like 'MIL%' or (NAME is null))
and (upper(FIRSTNAME) like 'MICH% or (FIRSTNAME is null))
and ...;
thank you for time..
email: [email protected] -
Function-based Index and an OR-condition in the WHERE-clause
We have some problems with functin-based indexes and
the or-condition in a where-clause.
(We use oracle 8i (8.1.7))
create table TPERSON(ID number(10),NAME varchar2(20),...);
create index I_NORMAL_TPERSON_NAME on TPERSON(NAME);
create index I_FUNCTION_TPERSON_NAME on TPERSON(UPPER(NAME));
The following two statements run very fast on a large table
and the execution-plan asure the usage of the indexes
(-while the session is appropriate configured and the table is analyzed):
1) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%';
2) select count(ID) from TPERSON where NAME like 'Mil%' or (3=5);
In particular we see that a normal index is used while the where-clause contains
an OR-CONDITION.
But if we try the similarly select-statement
3) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%' or (3=5);
the CBO will not use the function-index.
(This behavior we only expect with views but not with indexes.)
We ask for an advice like an hint, which enable the CBO-usage
of function-based indexes in connection with OR.
This problem seems to be artificial because it contains this dummy logic:
or (3=5).
This steams from an prepared statement, where this kind of boolean
flag reduce the amount of different select-statements needed for
covering the hole business-logic, while using bind-variables for the
concrete query-parameters.
A more realistic (still boild down) version of our prepared select-statement run in
SQL Plus:
define x_name = 'MIL%';
define x_firstname = '';
select * FROM TPERSON
where (upper(NAME) like '&x_name' or ( '&x_name' = ''))
and (upper(FIRSTNAME) like '&x_firstname' or ('&x_firstname' = ''))
and ...;
In particular we dont refernce the tablecolumn , but the QUERY-Parameter
yield the second boolean value in the or-condition.
The problem is that this condition ('&x_name' = '') dont use any index.
thanks a lot for spending your time with this problemTry
SELECT /*+ RULE */
as your hint. I don't have the book with me, but this last weekend I read a section about your very problem. The book was a Oracle Press gold cover about Oracle 8i Performance tuning. If you e-mail me I can quote you the chapter when I get home Friday. -
Query not considering function based index in oracle 11g
I have a query which used Function Based Index when run in oracle 9i but when I run the same query
without any changes, it does not consider index. Below is the query:
SELECT distinct patient_role.domain_key, patient_role.patient_role_key,
patient_role.emergency_contact_name,
patient_role.emergency_contact_phone, patient_role.emergency_contact_note,
patient_role.emergency_contact_relation_id,
patient_role.financial_class_desc_id, no_known_allergies, patient_role.CREATED_BY,
patient_role.CREATED_TIMESTAMP,
patient_role.CREATED_TIMESTAMP_TZ, patient_role.UPDATED_BY, patient_role.UPDATED_TIMESTAMP,
patient_role.UPDATED_TIMESTAMP_TZ,
patient_role.discontinued_date
FROM encounter, patient_role
WHERE patient_role.patient_role_key = encounter.patient_role_key
AND UPPER(TRIM(leading :SYS_B_0 from encounter.account_number)) = UPPER(TRIM(leading :SYS_B_1 from
:SYS_B_2))
AND patient_role.discontinued_date IS null
AND encounter.discontinued_date IS null ;
Index definition:
CREATE INDEX "user1"."IX_TRIM_ACCOUNT_NUMBER" ON "user1."ENCOUNTER" (UPPER(TRIM(LEADING
'0' FROM "ACCOUNT_NUMBER")), "PATIENT_ROLE_KEY", "DOMAIN_KEY", "DISCONTINUED_DATE")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT)
TABLESPACE "user1"
Database : Oracle 11g (11.2.0.3)
O/S : Linux 64 bit (the query does not consider index even on windows os)
Any suggestions?
-Onkar
Edited by: onkar.nath on Jul 2, 2012 3:32 PMOnkar,
I don't appreciate you posting this question in several forums at the same time.
If I would know you also posted this on Asktom, I wouldn't even have bothered.
As to your 'issue':
First of all: somehow cursor_sharing MUST have been set to FORCE. Oracle is a predictable system, not a fruitmachine.
Your statement the '0' is replaced by a bind variable anyway is simply false. If you really believe it is not false, SUBMIT a SR.
But your real issue is not Oracle: it is your 'application', which is a mess anyway. Allowing for alphanumeric numbers is a really bad idea.
Right now you are already putting workaround on workaround on workaround on workaround.
Issue is the application: it is terminal., and you either need to kill it, or to replace it.
Sybrand Bakker
Senior Oracle DBA -
Hi All,
select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - ProductionI have a 10GB partitioned table which has INVOICE_DUE_DATE column. Table is partitioned on CREATION_DATE. All records which has CREATION_DATE less than 01-jan-2010 have INVOICE_DUE_DATE set to NULL and new records (for year 2011)are updated with recent date(i.e. sysdate) by 'due_date_update' process. Some developers want indexing on INVOICE_DUE_DATE column as they have SLA critical reports running against INVOICE_DUE_DATE column. (where INVOICE_DUE_DATE > :B1) B1 could be any date in 2011.
As of now, ~85% records are having INVOICE_DUE_DATE set to NULL.
Given above scenarios,Can i use function based index to index all rows where INVOICE_DUE_DATE is any date in 2011 ?
Edited by: OraDBA02 on Jan 11, 2011 4:00 AMOraDBA02 wrote:
Given above scenarios,Can i use function based index to index all rows where INVOICE_DUE_DATE is any date in 2011 ?I suppose you could, but you might not need to. If you had an index that just contained the INVOICE_DUE_DATE column it wouldn't index the NULL values anyways. -
Oracle 8i Function-based index
Hi,
i have problem with making Oracle8i to use function-based index. I am using version 8.1.6 Enterprise Edition.
So here is the test I did
CREATE INDEX first_name_index ON customer ( UPPER(first_name)) ;
alter session set QUERY_REWRITE_ENABLED = TRUE;
alter session set QUERY_REWRITE_INTEGRITY=TRUSTED;
ANALYZE TABLE customer COMPUTE STATISTICS;
alter index first_name_index compute statistics;
Everything seemed to be as required by Oracle but it doesn't use this function-based index when I make
select *
from customer
where upper(first_name) like 'J%';
I test it on large table and with table with few hundred rows. I don't have NULLs in that field.
Can anyone help me with this.I would not create an index to have it prepared for an ORDER BY. An index is quite costly in DML opperations and space as well. More, a function based index will be costlier as the function has to be called for every read and/or write.
Do not forget that indexes a created for a direct access to data and not for sorting purposes.
George -
Intermedia and function-based indexes
Is it valid to use function-based indexing to create an intermedia index type ?
I am interested in this, what's your motivation for function-based index in interMedia text? What kind of function are you going to design?
Honglin -
URGENT - Function based indexes
Hi,
I have a table with huge amount of data and hence I have created
a function-based (Upper) index on one of the character NOT
NULL field which is very likely to be used for query purposes.
First of all though I can create ordinary normal field based
indexes in my user I cannot create a function-based index, why
That had to be created thru SYS user. Secondly I my query
invloving this function is not using the index and instead doing
a full-table scan. Problem outlined below :
Table : PLZPOST, USER / OWNER : PARTNER, FIELD : ORT
INDEX created on UPPER(ORT) in SYS user -
Create index upper_plz_ort on partner.plzpost (upper(ort))
When I give any of the following queries instead of using the
resp. index as mentioned in Oracle DOC it just does a full table
scan (checked thru Explain Plan) :
select * from PLZPOST where upper(ort) is not null;
select * from PLZPOST where upper(ort) like upper('saar%')
select * from PLZPOST where upper(ort) = 'SAARBRUECKEN'
etc etc
If anyone has used Function-based indexes in Oracle 8i could you
please tell me where am I going wrong. Is it because my Table
belongs to PARTNER and Index to SYS (tried running the above
queries under SYS user also but still did not work) ?? If so how
can I grant access on an Index to PARTNER from SYS ??
Your help would be greatly appreciated.
Thanks in advance,
Cheers
Rashmi
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Rashmi Rungta ([email protected]):
Hi,
I have a table with huge amount of data and hence I have created
a function-based (Upper) index on one of the character NOT
NULL field which is very likely to be used for query purposes.
First of all though I can create ordinary normal field based
indexes in my user I cannot create a function-based index, why
That had to be created thru SYS user. Secondly I my query
invloving this function is not using the index and instead doing
a full-table scan. Problem outlined below :
Table : PLZPOST, USER / OWNER : PARTNER, FIELD : ORT
INDEX created on UPPER(ORT) in SYS user -
Create index upper_plz_ort on partner.plzpost (upper(ort))
When I give any of the following queries instead of using the
resp. index as mentioned in Oracle DOC it just does a full table
scan (checked thru Explain Plan) :
select * from PLZPOST where upper(ort) is not null;
select * from PLZPOST where upper(ort) like upper('saar%')
select * from PLZPOST where upper(ort) = 'SAARBRUECKEN'
etc etc
If anyone has used Function-based indexes in Oracle 8i could you
please tell me where am I going wrong. Is it because my Table
belongs to PARTNER and Index to SYS (tried running the above
queries under SYS user also but still did not work) ?? If so how
can I grant access on an Index to PARTNER from SYS ??
Your help would be greatly appreciated.
Thanks in advance,
Cheers
Rashmi<HR></BLOCKQUOTE>
null -
Function Based Indexes - negative performance
Has anyone run across any cases where they have had issues with Function Based Indexes negatively impacting performance??
We are trying to use function based indexes in 9i (NLS_SORT=GENERIC_BASELETTER) and 10g (NLS_SORT=BINARY_CI) for case insensitivity.
We thought this was a decent solution until recently when testing with larger datasets. Any info is appreciated.
Thanks,Just to clarify rreynoldson's first point:
All indexes will negatively impact inserts. Indexes, including function-based indexes, may or may not improve update and delete performance depending on whether the overhead of maintaining the index outweighs the benefit of being able to use the index to find the row(s) to update relatively quickly.
For user564260:
Assuming those parameters are set, make sure that you've gathered statistics on the function based index. If that doesn't resolve the problem, can you post a small test case that demonstrates the problem where you
- Create the table
- Create the indexes
- Populate it with data
- Run the query that you'd expect to use the FBI
- Post the explain plan
that would help us immensely.
Justin -
How can I enable function-based indexes on a already created
database. Is an Installation/Db Creation setting?
On another database I am able to create function-based indexes.
Any help appreciated.
Ashish
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Rashmi Rungta ([email protected]):
Hi,
I have a table with huge amount of data and hence I have created
a function-based (Upper) index on one of the character NOT
NULL field which is very likely to be used for query purposes.
First of all though I can create ordinary normal field based
indexes in my user I cannot create a function-based index, why
That had to be created thru SYS user. Secondly I my query
invloving this function is not using the index and instead doing
a full-table scan. Problem outlined below :
Table : PLZPOST, USER / OWNER : PARTNER, FIELD : ORT
INDEX created on UPPER(ORT) in SYS user -
Create index upper_plz_ort on partner.plzpost (upper(ort))
When I give any of the following queries instead of using the
resp. index as mentioned in Oracle DOC it just does a full table
scan (checked thru Explain Plan) :
select * from PLZPOST where upper(ort) is not null;
select * from PLZPOST where upper(ort) like upper('saar%')
select * from PLZPOST where upper(ort) = 'SAARBRUECKEN'
etc etc
If anyone has used Function-based indexes in Oracle 8i could you
please tell me where am I going wrong. Is it because my Table
belongs to PARTNER and Index to SYS (tried running the above
queries under SYS user also but still did not work) ?? If so how
can I grant access on an Index to PARTNER from SYS ??
Your help would be greatly appreciated.
Thanks in advance,
Cheers
Rashmi<HR></BLOCKQUOTE>
null -
Hi Guys,
We are running Oracle 8.1.7 Database on Solaris server. We created function based indexes, while executing queries the function based indexes are not being used. Only if we use a hint in the query the indexes are being used. Is this a bug in oracle 8.1.7 or is this is how the function based indexes have to be used. Can somebody clarify this issue, I will appreciate your help. Thanks in advance.First, have you analyzed the tables recently? I believe you have to be using the CBO if you're using function based indexes. If the CBO has bad statistics, it may be generating bad plans.
Second, can you post the query & the plan (with and without the hint)? Is it possible that the CBO is finding a better plan than using the index?
Justin -
Function Based Index - Query Performance
HI,
Good Day to All..
I'd like to use function based indexes on following column(to_char(ps.user_pc_id)).
Whereas this column is part of PRIMARY KEY.
Is it possible to create a function based index on PRIMARY KEY Column?
Attached below is the query with the explain plan ...
TO_CHAR Expression - Performance
Thanks for your reply.DTYLER_APP@pssdev2> create table dt_fbi_pk(id varchar2(20));
Table created.
DTYLER_APP@pssdev2> drop table dt_fbi_pk;
Table dropped.
DTYLER_APP@pssdev2> create table dt_fbi(id number);
Table created.
DTYLER_APP@pssdev2> create index dt_fbi_idx on dt_fbi(to_char(id));
Index created.
DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_pk primary key (id);
Table altered.
DTYLER_APP@pssdev2> select constraint_name,constraint_type, index_name from user_constraints where table_name='DT_FBI';
CONSTRAINT_NAME C INDEX_NAME
DT_FBI_PK P DT_FBI_PK
1 row selected.When we created the primary key constraint, Oracle created a new index rather than using the existing one because....
DTYLER_APP@pssdev2> alter table dt_fbi drop primary key;
Table altered.
DTYLER_APP@pssdev2> select index_name from user_indexes where table_name ='DT_FBI';
INDEX_NAME
DT_FBI_IDX
1 row selected.
DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_pk primary key (id) using index dt_fbi_idx;
alter table dt_fbi add constraint dt_fbi_pk primary key (id) using index dt_fbi_idx
ERROR at line 1:
ORA-14196: Specified index cannot be used to enforce the constraint.
DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_uk unique(id) using index dt_fbi_idx;
alter table dt_fbi add constraint dt_fbi_uk unique(id) using index dt_fbi_idx
ERROR at line 1:
ORA-14196: Specified index cannot be used to enforce the constraint.We can't use a function based index to enforce a unique or primary key constraint. Changing the syntax does not help..
DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_uk unique(TO_CHAR(id)) using index dt_fbi_idx;
alter table dt_fbi add constraint dt_fbi_uk unique(TO_CHAR(id)) using index dt_fbi_idx
ERROR at line 1:
ORA-00904: : invalid identifierWe can create a unique index however
DTYLER_APP@pssdev2> drop index dt_fbi_idx;
Index dropped.
DTYLER_APP@pssdev2> create unique index dt_fbi_idx on dt_fbi(to_char(id));
Index created.but we still can't use it to enforce a unique or primary key constraint
DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_pk primary key (id) using index dt_fbi_idx;
alter table dt_fbi add constraint dt_fbi_pk primary key (id) using index dt_fbi_idx
ERROR at line 1:
ORA-14196: Specified index cannot be used to enforce the constraint.
DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_uk unique(id) using index dt_fbi_idx;
alter table dt_fbi add constraint dt_fbi_uk unique(id) using index dt_fbi_idx
ERROR at line 1:
ORA-14196: Specified index cannot be used to enforce the constraint.So no, you can't use it for a primary key. If you just want to enforce uniqueness then yes, you can do it with a unique index, but not a constraint.
DTYLER_APP@pssdev2> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
5 rows selected.HTH
Daviid -
How to create function based index on REGEXP_LIKE funtion
Dear Gurus,
I have below table CDR
Name Null Type
STARTTIME NOT NULL DATE
SUBSCRIBERNUMBER NOT NULL NUMBER
CALLINGNUMBER NOT NULL VARCHAR2(20)
CALLEDNUMBER NOT NULL VARCHAR2(20)
I am regularly firing below query
SELECT count(*)
FROM CDR data
WHERE STARTTIME BETWEEN '01-Jul-2009 00:00:00' and '31-May-2012 23:59:59'
AND REGEXP_LIKE(data.SUBSCRIBERNUMBER, '^98721[0-9]*[5]+[0-9]*$');
since there is REGEXP_LIKE is being used, Can I use function based index to improve performance.
Thanking in advance
SanjeevHi,
you can do it that way :Scott@my11g SQL>create table test (name varchar2(30));
Table created.
Scott@my11g SQL>create index myfbi on test(case when regexp_like(name,'^98721[0-9]*[5]+[0-9]*$') then 1 else 0 end);
Index created.
Scott@my11g SQL>explain plan for
2 select * from test where case when regexp_like(name,'^98721[0-9]*[5]+[0-9]*$') then 1 else 0 end = 1;
Explained.
Scott@my11g SQL>/
PLAN_TABLE_OUTPUT
Plan hash value: 140237472
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 20 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TEST | 1 | 20 | 1 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | MYFBI | 1 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access(CASE WHEN REGEXP_LIKE ("NAME",'^98721[0-9]*[5]+[0-9]*$')
THEN 1 ELSE 0 END =1)
Note
- dynamic sampling used for this statement (level=2)
19 rows selected. -
Creation of function based index using escape
Hello,
I have the following SQL, sometimes performing bad:
SELECT DISTINCT UPPER(A.PROCESSIDCODE), UPPER(A.RULENAME), CHARSET
FROM XIB_DETECT A, XIB_PROCESSIDPROPERTIES B, XIB_RULES C
WHERE ( A.KEY1 = :P1 OR ( :P1 like REPLACE(REPLACE(REPLACE(REPLACE(KEY1,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\' AND A.REGFLAGS1 = 'Y') OR A.KEY1 = '*' AND A.REGFLAGS1 = 'Y')
AND (A.KEY2 = :P2 OR ( :P2 like REPLACE(REPLACE(REPLACE(REPLACE(KEY2,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\' AND A.REGFLAGS2 = 'Y') OR (A.KEY2 IS NULL AND A.REGFLAGS2 IS NULL ) )
AND (A.KEY3 = :P3 OR ( :P3 like REPLACE(REPLACE(REPLACE(REPLACE(KEY3,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\' AND A.REGFLAGS3 = 'Y') OR (A.KEY3 IS NULL AND A.REGFLAGS3 IS NULL ) )
AND (A.KEY4 = :P4 OR ( :P4 like REPLACE(REPLACE(REPLACE(REPLACE(KEY4,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\' AND A.REGFLAGS4 = 'Y') OR (A.KEY4 IS NULL AND A.REGFLAGS4 IS NULL ) )
AND (A.KEY5 = :P5 OR ( :P5 like REPLACE(REPLACE(REPLACE(REPLACE(KEY5,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\' AND A.REGFLAGS5 = 'Y') OR (A.KEY5 IS NULL AND A.REGFLAGS5 IS NULL ) )
AND (A.KEY6 IS NULL OR A.KEY6 = '*' AND REGFLAGS6 = 'Y')
AND (A.KEY7 IS NULL OR A.KEY7 = '*' AND REGFLAGS7 = 'Y')
AND (A.KEY8 IS NULL OR A.KEY8 = '*' AND REGFLAGS8 = 'Y')
AND (A.KEY9 IS NULL OR A.KEY9 = '*' AND REGFLAGS9 = 'Y')
AND (A.KEY10 IS NULL OR A.KEY10 = '*' AND REGFLAGS10 = 'Y')
AND ( ( A.PROCESSIDCODE IS NOT NULL AND UPPER(A.PROCESSIDCODE) = UPPER(B.PROCESSIDCODE) AND A.XLEVEL = B.XLEVEL AND B.ACTIVEFLAG = 'Y' )
OR ( A.RULENAME IS NOT NULL AND UPPER(A.RULENAME) = UPPER(C.RULENAME) AND A.XLEVEL = C.XLEVEL AND C.ACTIVEFLAG = 'Y' ) );
Now I want to create a function based index on the key1 column:
CREATE INDEX xib_detect_ix ON xib_detect (REPLACE(REPLACE(REPLACE(REPLACE(KEY1,'%', '\%'),'_', '\_'),'?', '_'),'*','%') escape '\') TABLESPACE ... ONLINE;
However, this is not working with "escape" '\', throwing: ORA-00907: missing right parenthesis
Any idea how to create an index on this construct with "escape"?
Database version is 10.2.0.3.
Thanks a lot.
Regards
OliverHi,
You can get the "missing right parenthesis" error for many different syntax errors.
In this case, you really are missing a right parenthesis. Your statement has 5 left '('s, but only 4 right ')'s. It's easy to see this if you format your code:
CREATE INDEX xib_detect_ix
ON xib_detect ( REPLACE ( REPLACE ( REPLACE ( REPLACE ( KEY1
escape '\'
ESCAPE is an option that you can use with the LIKE operator. It gives you a mechanism for cancelling the special meaning of symbols like '%'. You're not using the LIKE operator to create the index. You're only using REPLACE, and no characters have any special meaning in REPLACE, so there's no way (or reason) to escape them. Use ESCAPE in queries that use LIKE, when appropriate.
Maybe you are looking for
-
There are people on the same wifi network as me but I want my printer to only be connected to my products
-
We have a payment method Electronic Check and ACH. Electronic check means we sent the payment file via EDI to the bank and the bank will print and mail the checks to the vendors directly. It is also sometimes called 3rd party printing. Now, we cr
-
can somebody plz help me to convert ps files to pdf files through java.
-
What is the best way to analye a long running utility to see what changes I shuild make to improve efficiency?
-
Why when I take photos with my iPad do only a few of them appear on my MacBook Pro?
I have noticed that when I take photos with my iPad only some of them transfer automatically to my MacBook Pro. Can anyone explain why this is happening please?