Unable to create function based Index

Hi All,
I created a function as below:
create or replace function eqx_oklb_term_date_nvl(pin_term_date date)
return date
deterministic
is
l_sub_date date := sysdate+1;
l_return_value date := l_sub_date;
begin
l_return_value := nvl(pin_term_date, l_sub_date);
return l_return_value;
exception
when others
then
l_return_value := l_sub_date;
return l_return_value;
end eqx_oklb_term_date_nvl;
Now trying to create a function based index using below code:
create index EQX_OKC_K_LINES_B_N4 on OKC.OKC_K_LINES_B(EQX_OKLB_TERM_DATE_NVL(DATE_TERMINATED))
logging
tablespace EQIXDATA
noparallel;
Encountered Error:
SQL Error: ORA-00904: "EQX_OKLB_TERM_DATE_NVL": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:   
*Action:
I can successfully query dba_objects for the function.
Owner Object_name object_id object_type last_ddl_time status
APPS     EQX_OKLB_TERM_DATE_NVL     11764623     FUNCTION     3/4/2013 9:44:57 PM     VALID
I can also query the function using dual.
select eqx_oklb_term_date_nvl(null) nvl_date from dual;
nvl_date
3/5/2013 9:53:59 PM
I have given grants of the function to both schemas APPS/OKC
grant all on eqx_oklb_term_date_nvl to okc;
grant all on eqx_oklb_term_date_nvl to apps;
The column date_terminated in table okc_k_lines_b is a date. I've checked that.
Stuck here. Please help.
Thanks in advance,
Rahul

Hi,
To follow up, the below code resolved the issue:
create index EQX_OKC_K_LINES_B_N4 on okc_k_lines_b(apps.eqx_oklb_term_date_nvl(date_terminated))
logging
tablespace eqixdata
noparallel;
-- qualifying the custom function name with schema name resolved the issue.
Thanks,
Rahul

Similar Messages

  • ORA-00439 while creating function based indexes.

    Hi everybody
    I'm working on Oracle 8.1.7 database, and try to create a function based index on a table.
    Unfortunately I get the ORA-00439 error, that recommends me not to use this feature :-(
    What should I do to activate this feature ?
    Thanx

    Try.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bi
    PL/SQL Release 10.1.0.2.0 - Production
    CORE    10.1.0.2.0      Production
    TNS for Solaris: Version 10.1.0.2.0 - Production
    NLSRTL Version 10.1.0.2.0 - Production

  • Creating function-based indexes

    I'm trying to create a function-based index in one of the user's schemas and am getting an insufficient privilege error. Below are the examples:
    connect scott/tiger ;
    CREATE INDEX emp_ename_idx ON ename( emp ) ;
    Index created.
    CREATE INDEX upper_ename_idx ON ename( upper(ename)) ;
    ERROR at line1:
    ORA-01031: insufficient privileges
    The DBA granted the CREATE ANY INDEX privilege to user scott already. Any ideas???
    Thanks,
    SY

    Hi, all.
    I didn't hear about function-based index before, so I did some testing. Instead of using Oracle predefined functions (upper, lower, substr etc.), I created my own function and tried to create an index on it. I received an error that function is not deterministic. The definition of deterministic from Oracle docs:
    DETERMINISTIC
    This hint helps the optimizer avoid redundant function calls. If a stored function was called previously with the same arguments, the optimizer can elect to use the previous result. The function result should not depend on the state of session variables or schema objects. Otherwise, results might vary across calls. Only DETERMINISTIC functions can be called from a function-based index or a materialized view that has query-rewrite enabled.
    So, I put word deterministic in function declaration and everything works OK. Then I modified function to use some of the tables (I used tables across different schemas), recreated the index and it also worked fine.
    Question - is this statement correct: You can use schema objects in function which is in turn used for indexes as long as you put word deterministic in function declaration and all objects (function, index) will be valid, but ORACLE doesn't guarantee that result produced using that index will be correct?
    Thank you.

  • Error creating function based index

    i keep getting ORA-13203 errors when creating a function-based index. The function is owned by another schema but the the user creating the function has execute privileges
    [email protected]> create index mpp_nc_sidx on MPP_NONCOMPLETE(GIS.DD832UTM(LON*-1,LAT))
    2 indextype is mdsys.spatial_index
    3 parameters('tablespace=sde4_idx sdo_indx_dims=2');
    create index mpp_nc_sidx on MPP_NONCOMPLETE(GIS.DD832UTM(LON*-1,LAT))
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA table
    ORA-13203: failed to read USER_SDO_GEOM_METADATA table
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_9I", line 7
    ORA-06512: at line 1
    [email protected]> select table_name,column_name from user_sdo_geom_metadata;
    TABLE_NAME COLUMN_NAME
    MPP_NONCOMPLETE GIS.DD832UTM(LON*-1,LAT)
    [email protected]> select GIS.DD832UTM(LON*-1,LAT) from mpp_noncomplete where rownum < 3;
    GIS.DD832UTM(LON*-1,LAT)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO_GEOMETRY(2001, 82212, SDO_POINT_TYPE(864941.804, 3916953.95, NULL), NULL, NULL)
    SDO_GEOMETRY(2001, 82212, SDO_POINT_TYPE(568560.541, 4181497.56, NULL), NULL, NULL)
    [email protected]> select text from all_source where name = 'DD832UTM';
    TEXT
    FUNCTION dd832utm(x number, y number)
    RETURN mdsys.sdo_geometry DETERMINISTIC
    IS
    geom mdsys.sdo_geometry;
    BEGIN
    geom := sdo_cs.transform
    (mdsys.sdo_geometry (2001,8265,mdsys.sdo_point_type
    (x,y, null),null,null),82212);
    return geom;
    END;
    any help appreciated
    --kassim

    Hi, try to use a view:
    create or replace view v_dd832utm as
    select
    mdsys.sdo_geometry(2001,8265,
    mdsys.sdo_point_type((LON*-1),LAT, null),null,null),
    82212)as GEOMETRY
    from
    mpp_noncomplete;
    provide metadata for that view (column: GEOMETRY) and create a spatial index. your way is more sophisticated ;o)
    regards, Andreas

  • How to create function based index for TO_CHAR

    i need to create a function based index for the function to_char.when i tried ,i got an error,"only pure function can be indexed".what the error really means, help me in creating the index to reduce my query cost.

    It works fine on my database. version 9iR2
    create index IDX_TO_CHAR on emp(to_char(hiredate,'YYYY-MM-DD HH24:MI:SS'));
    explain plan for
    select hiredate from emp where to_char(hiredate,'YYYY-MM-DD HH24:MI:SS')='1981-05-01 00:00:00';
    | Id  | Operation                   |  Name        | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT            |              |     1 |     8 |     2  (50)|
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP          |     1 |     8 |     2  (50)|
    |*  2 |   INDEX RANGE SCAN          | IDX_TO_CHAR  |     1 |       |     2  (50)|
    Predicate Information (identified by operation id):
       2 - access(TO_CHAR("EMP"."HIREDATE",'YYYY-MM-DD HH24:MI:SS')='1981-05-01 00
                  :00:00')Yours seem like a tuning issue, so why not give us your sql and execution plan and so on.
    maybe there is other ways to tune your sql than creating a function based index?

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

    Hi,
    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.

  • Unable to create function based spatial index

    Maybe someone can help me. I can't seem to find the answer for what I'm doing here.
    I'm trying to create a function based spatial index - so that I can utilize coordinates in tables when I have no SDO_GEOMETRY column.
    Is there a fundamental problem with trying to do this or is it something syntactical?
    Executing the following sql is giving me this error, while I'm trying to create the spatial index:
    --create some table
    CREATE TABLE "ZZ_ACTIVITIES"
    ( "DESCRIPTION" VARCHAR2(50 BYTE),
    "CREW" VARCHAR2(50 BYTE),
    "LATITUDE" NUMBER DEFAULT 0.0,
    "LONGITUDE" NUMBER DEFAULT 0.0
    ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS NOLOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "MAP_NA_Q406" ;
    --create the function that takes an srid, and x/y and returns an SDO_GEOMETRY
    create or replace function get_geometry(p_srid in number,
    p_x in number,
    p_y in number)
    return mdsys.sdo_geometry deterministic;
    Is
    Begin
    Return MDSYS.SDO_GEOMETRY(2001,p_srid,mdsys.sdo_point_type(p_x,p_y,NULL),NULL,NULL);
    End observation;
    --insert sdo metadata
    INSERT INTO USER_SDO_GEOM_METADATA(
    TABLE_NAME,
    COLUMN_NAME,
    DIMINFO,
    SRID
    ) VALUES (
    'ZZ_ACTIVITIES',
    'GET_GEOMETRY(8307,LATITUDE,LONGITUDE)',
    MDSYS.SDO_DIM_ARRAY(
    SDO_DIM_ELEMENT
    'LONGITUDE',
    -180,
    180,
    0.5
    SDO_DIM_ELEMENT
    'LATITUDE',
    -90,
    90,
    0.5
    8307
    --create the index. (THIS IS WHERE THE ERROR IS THROWN)
    CREATE INDEX zz_activities_location_sidx ON ZZ_ACTIVITIES(GET_GEOMETRY(8307,LATITUDE,LONGITUDE)) INDEXTYPE IS MDSYS.SPATIAL_INDEX parameters('layer_gtype=POINT');
    The error returned is;
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 10

    Hi,
    To follow up, the below code resolved the issue:
    create index EQX_OKC_K_LINES_B_N4 on okc_k_lines_b(apps.eqx_oklb_term_date_nvl(date_terminated))
    logging
    tablespace eqixdata
    noparallel;
    -- qualifying the custom function name with schema name resolved the issue.
    Thanks,
    Rahul

  • 10.1.3 - Create Table Wizard - function based indexes?

    Is the ability to create function based indexes via the Create Table Wizard planned for the 10.1.3 production release?
    It appears the Wizard under step 7 has the ability to enter "function" expressions. However an error dialog appears if you enter anything but a column name.
    CM.

    Chris,
    Yes, this has been implemented for Production.
    Regards,
    Lisa Sherriff
    JDev QA

  • Function Based Index on Date Column

    Hi All,
    I need to execute a query like this :
    SELECT * FROM ORDERS WHERE APPROVE_DATE IS NULL
    I read anywhere that this will cause unnecessary FTS so that I should create function based index.
    I have tried one below , but not sure that this is correct approach :
    CREATE INDEX idx_1
    ON ORDERS (NVL(APPROVE_DATE, '01-JAN-1900'));
    SELECT * FROM ORDERS WHERE NVL(APPROVE_DATE, '01-JAN-1900') = '01-JAN-1900'
    Is this a correct approach ?
    Thank you,
    xtanto

    A SQL_TRACE output will explain clearly what Justin has stated.
    I have created a table T based on all_objects.
    SQL> desc t
    Name                                      Null?    Type
    OWNER                                     NOT NULL VARCHAR2(30)
    OBJECT_NAME                               NOT NULL VARCHAR2(30)
    SUBOBJECT_NAME                                     VARCHAR2(30)
    OBJECT_ID                                 NOT NULL NUMBER
    DATA_OBJECT_ID                                     NUMBER
    OBJECT_TYPE                                        VARCHAR2(19)
    CREATED                                            DATE
    LAST_DDL_TIME                             NOT NULL DATE
    TIMESTAMP                                          VARCHAR2(19)
    STATUS                                             VARCHAR2(7)
    TEMPORARY                                          VARCHAR2(1)
    GENERATED                                          VARCHAR2(1)
    SECONDARY                                          VARCHAR2(1)
    CASE I_
    SQL> select count(1) from t
      2  /
      COUNT(1)
        934320
    SQL> select count(1) from t where created is null
      2  /
      COUNT(1)
          2376The number of null values in CREATED column is proportionately very small.
    Now i execute the query without function based index.
    select *
      from t
    where created is null
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.09          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch      160      0.04       0.10          0      12662          0        2376
    total      162      0.04       0.19          0      12662          0        2376
    Rows     Execution Plan
          0  SELECT STATEMENT   GOAL: ALL_ROWS
       2376   TABLE ACCESS   GOAL: ANALYZED (FULL) OF 'T' (TABLE)And here is the query that uses the function based index
    select *
      from t
    where nvl(created,to_date('01-01-1900','DD-MM-YYYY')) = to_date('01-01-1900','DD-MM-YYYY')
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch      160      0.01       0.01          0        698          0        2376
    total      162      0.03       0.01          0        698          0        2376
    Rows     Execution Plan
          0  SELECT STATEMENT   GOAL: ALL_ROWS
       2376   TABLE ACCESS   GOAL: ANALYZED (BY INDEX ROWID) OF 'T' (TABLE)
       2376    INDEX   GOAL: ANALYZED (RANGE SCAN) OF 'T_FN_IDX' (INDEX)Its very obvious from the above output that the Function Based Index as increased the performance.
    CASE II_
    SQL> select count(1) from t
      2  /
      COUNT(1)
        934320
    SQL> select count(1) from t where created is null
      2  /
      COUNT(1)
        202168Now the null values in the CREATED column is proportionately large than the first test case.
    Now lets see without using the function based index
    select *
      from t
    where created is null
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch    13479      0.46       0.71          2      25832          0      202168
    total    13481      0.46       0.71          2      25832          0      202168
    Rows     Execution Plan
          0  SELECT STATEMENT   GOAL: ALL_ROWS
    202168   TABLE ACCESS   GOAL: ANALYZED (FULL) OF 'T' (TABLE)Now iam trying to use the function based index
    select *
      from t
    where nvl(created,to_date('01-01-1900','DD-MM-YYYY')) = to_date('01-01-1900','DD-MM-YYYY')
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch    13479      0.54       0.84          0      33826          0      202168
    total    13481      0.54       0.84          0      33826          0      202168
    Rows     Execution Plan
          0  SELECT STATEMENT   GOAL: ALL_ROWS
    202168   TABLE ACCESS   GOAL: ANALYZED (FULL) OF 'T' (TABLE)Its obvious from the result that oracle has decided to go for a FULL TABLE SCAN even when an index was available.
    So just having a function based index is not going to increase the query performance. There are lot of other factors to be considered as stated above.
    Thanks,
    Karthick.

  • Dilemma regarding function based indexes

    Hello,
    I have a dilemma regarding function based indexes.
    I have read Note:66277.1 on the Metalink discussing thoroughly the subject of “Concepts and Usage of Function Based Indexes”.
    This doc was revised on 30-May-2006 so I was sure it referred to 9i and 10g.
    This doc as well as other docs on the web claim that in order to use FBI (function based indexes) one must set the following parameters (can be done also at session level)
    QUERY_REWRITE_ENABLED = TRUE
    QUERY_REWRITE_INTEGRITY = TRUSTED
    Also the schema that is owner of the FBI should be granted with QUERY REWRITE sys priv and statistics should be collected since FBI is usable only by CBO (cost based optimizer).
    I have tested it and it works, my problem was that it worked
    (1)     Without granting the QUERY REWRITE to the owning schema.
    (2)     QUERY_REWRITE_ENABLED was set to false.
    (3)     QUERY_REWRITE_INTEGRITY was set to enforced.
    I have conducted my tests on 9.2.0.6 and found no evidence in the docs (10g) saying the above is required or not.
    I found at http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1197786003246 the following:
    “Oracle9iR2 relaxed this so that the FBI on the builtin function may be used.”
    so I have tested it with my own function:
    create or replace function upper2( p_str in varchar2 ) return
    varchar2 DETERMINISTIC
    as
    begin
    return upper(p_str);
    end;
    =>
    Also (yes you guessed right), without any privilege granted nor parameter setting the optimizer picked my FBI.
    Can anyone refer me to a place documenting this behavior as a correct one?
    Other comments?
    Regards,
    Tal Olier ([email protected])

    Got an answer from Oracle support:
    19-DEC-06 18:04:31 GMT
    (Update for record id(s): 101017780,101017796)
    QUESTION
    ========
    Questions about the options required in 10g related to Function Based Indexes, and the correct
    behaviors associated with them.
    ANSWER
    ======
    For 10g:
    These requirements are no longer true in 10g. This has already clarified by
    development in the Bug 3999326 which is available on metalink.
    For 9I:
    For the creation of a function-based index in your own schema, you must be
    granted the QUERY REWRITE system privileges. To create the index in another
    schema or on another schema's tables, you must have the CREATE ANY INDEX
    and GLOBAL QUERY REWRITE privileges.
    You must have the following initialization parameters defined to create a
    function-based index:
    QUERY_REWRITE_INTEGRITY set to TRUSTED
    QUERY_REWRITE_ENABLED set to TRUE
    COMPATIBLE set to 8.1.0.0.0 or a greater value
    Additionally, to use a function-based index:
    The table must be analyzed after the index is created.
    The query must be guaranteed not to need any NULL values from the indexed
    expression, since NULL values are not stored in indexes.
    However, in 9.2.0.4 patchset, these prerequisites do not apply and one can
    create function-based indexes without any of the above to be true. This is not
    the case in 9.2.0.3, not in 8.1.7.
    Reference: Oracle 9i R2 Administrators Guide
    So as mentioned above that is why you didnt have any errors
    Please back to us if any further information is need, and we will be pleased to
    assist you further.
    Thank You,
    Best Regards,
    Mina Anes

  • Function Based Indexes Errors

    Hi
    I am trying to create function based indexes based on the examples in the b10826 Spatial Users guide --
    The Create index statement is failing because it says it cannot read the metadata
    create index EMITTER_LOB_WIDX ON EMITTER (OWNER1.WT_GEOMETRY_PACKAGE.LINEOFBEARING(EQUIP_X, EQUIP_Y, LOB_BEARING, LOB_RANGE)) INDEXTYPE IS MDSYS.SPATIAL_INDEX LOCAL;
    create index EMITTER_LOB_WIDX ON EMITTER (EMITTER.WT_GEOMETRY_PACKAGE.LINEOFBEARING(EQUIP_X, EQUIP_Y, LOB_BEARING, LOB_RANGE)) INDEXTYPE IS MDSYS.SPATIAL_INDEX LOCAL
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 10
    Here is the USER_SDO_GEOM_METADATA ENTRY:
    TABLE_NAME
    COLUMN_NAME
    DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SRID
    EMITTER
    OWNER1.WT_GEOMETRY_PACKAGE.LINEOFBEARING(EQUIP_X, EQUIP_Y, LOB_BEARING,
    LOB_RANGE)
    SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -180, 180, .00005), SDO_DIM_ELEMENT('Y', -90,
    90, .000005))
    TABLE_NAME
    COLUMN_NAME
    DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SRID
    8307
    The package is owned by OWNER1 - the Table is in OWNER2's schema - not that that matters - what are the known issues with Function Based Indexes
    Am I missing something Obvious?

    I think its a bug
    I moved the function to the local schema - I also pulled it out of the package -
    So I look in USER_SDO_GEOM_METADATA no records for select * from USER_SDO_GEOM_METADATA
    Not being satisfied with that I look in ALL_SDO_GEOM_METADATA
    SELECT * FROM ALL_SDO_GEOM_METADATA WHERE OWNER = 'OWNER2';
    no rows selected
    So I should be good for insert
    INSERT INTO USER_SDO_GEOM_METADATA VALUES ('EMITTER','OWNER2.EQUIPMENTPOINT(EQUIP_X, EQUIP_Y)', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.005),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.005)), 8307);
    INSERT INTO USER_SDO_GEOM_METADATA VALUES ('EMITTER','LOCUST2.EQUIPMENTPOINT(EQUIP_X, EQUIP_Y)', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.005),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.005)), 8307)
    ERROR at line 1:
    ORA-13223: duplicate entry for EMITTER.OWNER2.EQUIPMENTPOINT(EQUIP_X, EQUIP_Y)
    in SDO_GEOM_METADATA
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 17
    ORA-06512: at "MDSYS.SDO_GEOM_TRIG_INS1", line 21
    ORA-04088: error during execution of trigger 'MDSYS.SDO_GEOM_TRIG_INS1'
    If I insert to all_sdo_geom_metadata it takes but the index create fails b/c it cannot read user_sdo_geom_metadata
    INSERT INTO ALL_SDO_GEOM_METADATA VALUES (OWNER2','EMITTER','OWNER2.EQUIPMENTPOINT(EQUIP_X, EQUIP_Y)', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.005),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.005)), 8307);
    1 row created.
    SQL> CREATE INDEX EMITTER_EQUIP_WIDX ON EMITTER(OWNER2.EQUIPMENTPOINT(EQUIP_X, EQUIP_Y)) INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS ('layer_gtype=point tablespace=EMITTER_IDX_TBS');
    CREATE INDEX EMITTER_EQUIP_WIDX ON EMITTER(OWNER2.EQUIPMENTPOINT(EQUIP_X, EQUIP_Y)) INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS ('layer_gtype=point tablespace=EMITTER_IDX_TBS')
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 10
    select table_name, column_name from user_sdo_geom_metadata;
    TABLE_NAME
    COLUMN_NAME
    EMITTER
    OWNER2.EQUIPMENTPOINT(EQUIP_X, EQUIP_Y)
    Arghhh!!!
    Anyone else encounter a similar problem?
    I know that I have to be careful regarding owner.packager.function naming convention
    I have followed the oracle examples from here
    http://www.oracle.com/technology/obe/obe10gdb/content/spatial/files/add_metadata_fi.sql
    are they broken? Is this a bug ?

  • Function based indexes on object tables

    Hi,
    I am trying to create a function based index on an object table. I am getting the following error:
    SQL> create index cell1_indx on cell1(create_cell1(id)) indextype is mdsys.spatial_index;
    create index cell1_indx on cell1(create_cell1(id)) indextype is mdsys.spatial_index
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13249: internal error in Spatial index: [mdidxrbd]
    ORA-13249: Error in Spatial index: index build failed
    ORA-13249: Stmt-Execute Failure: SELECT num_rows from all_tables where owner='ASHE' and table_name=
    'CELL1'
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_9I", line 7
    ORA-06512: at line 1
    Here cell1 is an object table.
    Is the procedure for creating function based indexes on object tables different from relational tables?
    Chinni

    One of the many new features in Oracle 8i is the Function-Based Index (we will refrain from using FBI, but only just). This allows the DBA to create indexes on functions or expressions; these functions can be user generated pl/sql functions, standard SQL functions (non-aggregate only) or even a C callout.
    A classic problem the DBA faces in SQL Tuning is how to tune those queries that use function calls in the where clause, and result in indexes created on these columns not to be used.
    Example
    Standard B-Tree index on SURNAME with cost based optimizer
    create index non_fbi on sale_contacts (surname);
    analyze index non_fbi compute statistics;
    analyze table sale_contacts compute statistics;
    SELECT count(*) FROM sale_contacts
    WHERE UPPER(surname) = 'ELLISON';
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=17)
    1 0 SORT (AGGREGATE)
    2 1 TABLE ACCESS (FULL) OF 'SALES_CONTACTS' (Cost=3 Card=16 Bytes=272)
    Now we use a function based index
    create index fbi on sale_contacts (UPPER(surname));
    analyze index fbi compute statistics;
    analyze table sale_contacts compute statistics;
    SELECT count(*) FROM sale_contacts WHERE UPPER(surname) = 'ELLISON';
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=17)
    1 0 SORT (AGGREGATE)
    2 1 INDEX (RANGE SCAN) OF 'FBI' (NON-UNIQUE) (Cost=2 Card=381 Bytes=6477)
    The function-based index has forced the optimizer to use index range scans (retuning zero or more rowids) on the surname column rather than doing a full table scan (non-index lookup). Optimal performance does vary depending on table size, uniqueness and selectivity of columns, use of fast full table scans etc. Therefore try both methods to gain optimal performance in your database.
    It is important to remember that the function-based B*Tree index does not store the expression results in the index but uses an "expression tree". The optimizer performs expression matching by parsing the expression used in the SQL statement and comparing the results against the expression-tree values in the function-based index. This comparison IS case sensitive (ignores spaces) and therefore your function-based index expressions should match expressions used in the SQL statement where clauses.
    Init.ora Parameters
    The following parameter must be set in your parameter file: QUERY_REWRITE_INTEGRITY = TRUSTED
    QUERY_REWRITE_ENABLED = TRUE
    COMPATIBLE = 8.1.0.0.0 (or higher)
    Grants
    Grants To create function-based indexes the user must be granted CREATE INDEX and QUERY REWRITE, or alternatively be granted CREATE ANY INDEX and GLOBAL QUERY REWRITE. The index owner must have EXECUTE access on the function used for the index. If execute access is revoked then the function-based index will be "disabled" (see dba_indexes).
    Disabled Indexes
    If your function-based index has a status of "disabled" the DBA can do one of the following:
    a) drop and create the index (take note of its current settings)
    b) alter index enable, function-based indexes only, also use disable keyword as required
    c) alter index unusable.
    Queries on a DISABLED index fail if the optimizer chooses to use the index.Here is an example ORA error:
    ERROR at line 1: ORA-30554: function-based index MYUSER.FBI is disabled.
    All DML operations on a DISABLED index also fail unless the index is also marked UNUSABLE and the initialization parameter SKIP_UNUSABLE_INDEXES is set to true.
    Some more Examples
    CREATE INDEX expression_ndx
    ON mytable ((mycola + mycolc) * mycolb);
    SELECT mycolc FROM mytable
    WHERE (mycola + mycolc) * mycolb <= 256;
    ..or a composite index..
    CREATE INDEX example_ndx
    ON myexample (mycola, UPPER(mycolb), mycolc);
    SELECT mycolc FROM myexample
    WHERE mycola = 55 AND UPPER(mycolb) = 'JONES';
    Restriction & Rule Summary
    The following restrictions apply to function based indexes. You may not index:
    a) LOB columns
    b) REF
    c) Nested table column
    d) Objects types with any of the above data types.
    Function-based indexes must always follow these rules:
    a) Cost Based optimizer only, must generate statistics after the index is created
    b) Can not store NULL values (function can not return NULL under any circumstance)
    c) If a user defined pl/sql routine is used for the function-based index, and is invalidated, the index will become "disabled"
    d) Functions must be deterministic (always return the same value for a known input)
    e) The index owner must have "execute" access on function used in the function-based index. Revocation of the privilege will render the index "disabled"
    f) May have a B-Tree and Bitmap index type only
    g) Can not use expressions that are based on aggregate functions, ie. SUM, AVG etc.
    h) To alter a function-based index as enabled, the function used must be valid, deterministic and the signature of the function matches the signature of the function when it was created.
    Joel P�rez

  • Function based indexes doing full table scan

    Guys,
    I am testing function based indexes and whatever I do
    it is doing a full table scan.
    1)I have set the following init parameters as
    QUERY_REWRITE_ENABLED=TRUE
    QUERY_REWRITE_INTEGRITY=TRUSTED
    2)CREATE INDEX i3 ON emp(UPPER(ename));
    3) ANALYZE TABLE emp COMPUTE STATISTICS
    ANALYZE INDEX I3 COMPUTE STATISTICS
    4) DELETE plan_table;
    5) EXPLAIN PLAN SET statement_id='Test1' FOR
    SELECT ename FROM emp WHERE UPPER(ename) = 'KING';
    6) SELECT LPAD(' ',2*level-2)||operation||' '||options||' '||object_name
    query_plan
    FROM plan_table
    WHERE statement_id='Test1'
    CONNECT BY prior id = parent_id
    START WITH id = 0 order by id
    7) And the query plan shows as
    SELECT STATEMENT
    TABLE ACCESS FULL EMP
    I am using 9.0.1.4 !!!
    Any help is appreciated !!!
    Regards,
    A.Kishore

    One of the many new features in Oracle 8i is the Function-Based Index (we will refrain from using FBI, but only just). This allows the DBA to create indexes on functions or expressions; these functions can be user generated pl/sql functions, standard SQL functions (non-aggregate only) or even a C callout.
    A classic problem the DBA faces in SQL Tuning is how to tune those queries that use function calls in the where clause, and result in indexes created on these columns not to be used.
    Example
    Standard B-Tree index on SURNAME with cost based optimizer
    create index non_fbi on sale_contacts (surname);
    analyze index non_fbi compute statistics;
    analyze table sale_contacts compute statistics;
    SELECT count(*) FROM sale_contacts
    WHERE UPPER(surname) = 'ELLISON';
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=17)
    1 0 SORT (AGGREGATE)
    2 1 TABLE ACCESS (FULL) OF 'SALES_CONTACTS' (Cost=3 Card=16 Bytes=272)
    Now we use a function based index
    create index fbi on sale_contacts (UPPER(surname));
    analyze index fbi compute statistics;
    analyze table sale_contacts compute statistics;
    SELECT count(*) FROM sale_contacts WHERE UPPER(surname) = 'ELLISON';
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=17)
    1 0 SORT (AGGREGATE)
    2 1 INDEX (RANGE SCAN) OF 'FBI' (NON-UNIQUE) (Cost=2 Card=381 Bytes=6477)
    The function-based index has forced the optimizer to use index range scans (retuning zero or more rowids) on the surname column rather than doing a full table scan (non-index lookup). Optimal performance does vary depending on table size, uniqueness and selectivity of columns, use of fast full table scans etc. Therefore try both methods to gain optimal performance in your database.
    It is important to remember that the function-based B*Tree index does not store the expression results in the index but uses an "expression tree". The optimizer performs expression matching by parsing the expression used in the SQL statement and comparing the results against the expression-tree values in the function-based index. This comparison IS case sensitive (ignores spaces) and therefore your function-based index expressions should match expressions used in the SQL statement where clauses.
    Init.ora Parameters
    The following parameter must be set in your parameter file: QUERY_REWRITE_INTEGRITY = TRUSTED
    QUERY_REWRITE_ENABLED = TRUE
    COMPATIBLE = 8.1.0.0.0 (or higher)
    Grants
    Grants To create function-based indexes the user must be granted CREATE INDEX and QUERY REWRITE, or alternatively be granted CREATE ANY INDEX and GLOBAL QUERY REWRITE. The index owner must have EXECUTE access on the function used for the index. If execute access is revoked then the function-based index will be "disabled" (see dba_indexes).
    Disabled Indexes
    If your function-based index has a status of "disabled" the DBA can do one of the following:
    a) drop and create the index (take note of its current settings)
    b) alter index enable, function-based indexes only, also use disable keyword as required
    c) alter index unusable.
    Queries on a DISABLED index fail if the optimizer chooses to use the index.Here is an example ORA error:
    ERROR at line 1: ORA-30554: function-based index MYUSER.FBI is disabled.
    All DML operations on a DISABLED index also fail unless the index is also marked UNUSABLE and the initialization parameter SKIP_UNUSABLE_INDEXES is set to true.
    Some more Examples
    CREATE INDEX expression_ndx
    ON mytable ((mycola + mycolc) * mycolb);
    SELECT mycolc FROM mytable
    WHERE (mycola + mycolc) * mycolb <= 256;
    ..or a composite index..
    CREATE INDEX example_ndx
    ON myexample (mycola, UPPER(mycolb), mycolc);
    SELECT mycolc FROM myexample
    WHERE mycola = 55 AND UPPER(mycolb) = 'JONES';
    Restriction & Rule Summary
    The following restrictions apply to function based indexes. You may not index:
    a) LOB columns
    b) REF
    c) Nested table column
    d) Objects types with any of the above data types.
    Function-based indexes must always follow these rules:
    a) Cost Based optimizer only, must generate statistics after the index is created
    b) Can not store NULL values (function can not return NULL under any circumstance)
    c) If a user defined pl/sql routine is used for the function-based index, and is invalidated, the index will become "disabled"
    d) Functions must be deterministic (always return the same value for a known input)
    e) The index owner must have "execute" access on function used in the function-based index. Revocation of the privilege will render the index "disabled"
    f) May have a B-Tree and Bitmap index type only
    g) Can not use expressions that are based on aggregate functions, ie. SUM, AVG etc.
    h) To alter a function-based index as enabled, the function used must be valid, deterministic and the signature of the function matches the signature of the function when it was created.
    Joel P�rez

  • Function Based Indexes in Primary Key Definition

    Hello.
    I have been looking into function based indexes. I have been able to create them using unique indexes. However, when I try to create them on primary keys, the engine complains.
    Any ideas? Does anyone know if you can create function based indexes on primary keys?
    An example would be great!
    Thanks,
    Brad

    Hi,
    You can create a function-based Index by going to the Properties dialog for the Index in the Relational model (not the Physical model). If you select the Index Expression tick box, you can then enter the expression into the Expression text area.
    David

  • Function-based indexes in 8i

    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

Maybe you are looking for

  • Exception importing and running PS3 application in different machine

    Hi,We have created a application in PS3 11.1.1.4.0 Jdev .When I am running the same application it is showing the below exception and skins is not applying to the application ............ rn match that hides other cpx files. <NavigationPreferences> <

  • Exposure inconsistent relative to PS

    Some images look way brighter in bridge than they open in PS, some darker, some the same. I can't make heads or tails of it, I'm not seeing a pattern yet, I just know not to expect a shot viewed in bridge to look the same in PS. And I'm talking about

  • I downloaded Mountain Lion and my mac gets very hot

    Is this normal?

  • Vista x64 and 6GB RAM?

    Howdy, I've had the new 2.8GHz 8 Core Mac Pro since launch, and only, today, got another 4GB of RAM for it, bringing it to a total of 6GB. Well upon installing the RAM, OS X saw all 6GB of ram which was great, but my Boot Camp installation of Windows

  • Data in table control not seen for the Standard Transaction Iview

    Hi I am creating one Standard Transaction Iview for CATS . While doing print preview in IE 6 , I am not able to see data in Table control(Data Entry Area ). Can you please provide me the solution for how I can see the data in Table Control Regards Ru