Varchar2 in index vs. number

My indexes on three primary tables total 80gb in space. They have 3-6 columns in the index, one of which is a 10-byte varchar field. This field holds an identifier type in character rather than numeric format. For example, name type is "INDIV" rather than a coded 001. If I use numeric, I will need to decode the text value on my screens/reports.
Is there a cost overhead in using varchar2 rather than number? Is there a space saving in either approach?

U should keep the varchar2 index and make a partition by range or list on it.
At my knowledge, there's no reason to put the key as number as they r no reason to put it as varchar.
If u need the field as a varchar, let it be a varchar... (and in ur example, u will win a decode each time u'll access this key...)
Fred

Similar Messages

  • Text (varchar2(320)) to a number

    Hi,
    May I know how to convert text (varchar2(350)) to a number in an sql...?

    You could use the TO_NUMBER function.
    If that's not what you need please explain clearly by providing an example.

  • Is varchar2(9) or even number(9) bad as a ssn?

    Hi All,
    I just want to question the wisdom of (<INT>) datatypes.
    If I do ...
    create table table_0123 (
    ssn varchar2(9),
    ... in tons of tons code (or even in a small piece of code
    that gets used or modified over and over), won't I be setting
    my self up for a Y2K like problem if there is ever more than
    999,999,999 people with SSN's? What is that ... 1 billion people?
    How many people are in the world?
    wouldn't ...
    create table table_0123 (
    ssn number,
    be better?
    Thanks

    So you're compiling a database that holds details of everybody in the whole world? Spooky. Still you've come to the right place: Oracle started out as a CIA project.
    Datatype for SSN: hmmm. I'm not American, so I'm not familiar with your system. On this side of the pond our SSN equivalents (NIN) are of the format AA999999A, which gives us 17,575,982,424 combinations (or thereabouts, I don't know if there are any excluded characters). This is sufficient for a few centuries of UK existence, but not very good for the whole world. But, given an alphanumeric format, VARCHAR2(9) is the only viable definition.
    If you have a purely numeric SSN then NUMBER is a goer. Please do not choose VARCHAR2(9) for a purely numeric field - I have a (third party) legacy system here that has that combination for the primary key of the most referenced table, which means having to LPAD everything with zeroes. Nightmare.The choic
    As the following test shows, all NUMBER fields take up the same about of space so there are no storage implications for you. The choice is merely a question of the amount of metadata you wish to build into your system.
    When you acheive world domination can I be your cackling, hunchbacked sidekick?
    Cheers, APC
    SQL> create table num_tst (col1 number(9,0), col2 number(38,0), col3 number);
    Table created.
    SQL> select column_name, data_length, data_precision, data_scale
      2  from   user_tab_columns
      3  where  table_name = 'NUM_TST';
    COLUMN_NAME                    DATA_LENGTH DATA_PRECISION DATA_SCALE
    COL1                                    22              9          0
    COL2                                    22             38          0
    COL3                                    22
    SQL>

  • Index Combines Number Entries

    I am using InDesign CS4 fully updated.  When I add a number such as 16-0002 to the index as a page reference, it works fine.  On the next page if I add the number 16-02 to the index, it will add that under the 16-0002 reference rather than creating a new reference entry.  I need each each of these to be individual references since they are not the same number, yet InDesign fails to see the 0's as placeholders and ignores them when combining numbers for indexing purposes.
    Is there any way to get these to be separate index entries?

    itoh,
    One way is to look into to table for monitor , but again please explain for what do you need this - If it is to be used for reporting then it will be something else..
    As for the reports / Queries being used -
    1. You can use where used lists or..
    2. You could go to maintain queries and select your dataprovider.
    Arun.
    P.S Nantha Kumar - you cannot be corrected if you are correct

  • Number range query causes repeated scan by index

    I have a query that seems to repeatedly call an index scan on a table for reasons I'm not sure about. Anyone know why it would be doing the index scan on totaldwellingarea in the dimensions table (DIMEN_PID_TDWELLAREA) repeatedly? This only seems to happen when I put on the range clause d.totaldwellingarea between scr.lowvalue and scr.highvalue.
    I am using Oracle version 9.2.0.3.
    select d.propertyid,d.totaldwellingarea, e.size_,  scr.size_
    from  eqid e, dimensions d,  brt_eval.size_code_ranges scr
    where e.style not in ('1','A','G','L') and e.size_  = '0'
    and d.propertyid = e.propertyid and e.style = scr.style and d.totaldwellingarea between scr.lowvalue and  scr.highvalue;
    CREATE
      TABLE "BRT_ADMIN"."EQID"
        "PROPERTYID"   VARCHAR2(20 BYTE) NOT NULL ENABLE,
        "EQID"         CHAR(10 BYTE),
        "ZONE_"        CHAR(1 BYTE),
        "AREA"         CHAR(1 BYTE),
        "GROUP_"       CHAR(1 BYTE),
        "GMA"          CHAR(1 BYTE),
        "STYLE"        CHAR(1 BYTE),
        "FLOORPLAN"    CHAR(1 BYTE),
        "BLDGCODEABBR" CHAR(1 BYTE),
        "SIZE_"        CHAR(1 BYTE),
        "CONDITION"    CHAR(1 BYTE),
        "SUBGROUP"     CHAR(1 BYTE),
        "UPDATED_BY"   VARCHAR2(10 BYTE),
        CONSTRAINT "EQID_PK" PRIMARY KEY ("PROPERTYID") USING INDEX
        CONSTRAINT "EQID_PROPERTIES_FK1" FOREIGN KEY ("PROPERTYID") REFERENCES
        "BRT_ADMIN"."PROPERTIES" ("PROPERTYID") DISABLE
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('3734003158','E241RJR440','E','2','4','1','R','J','R','4','4','0','274892');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('5428001913','H113TMH330','H','1','1','3','T','M','H','3','3','0','263579');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('8798001037','J423DX0440','J','4','2','3','D','X','0','4','4','0','SYSTEM');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('6924000909','L423LR0000','L','4','2','3','L','R','0','0','0','0','275251');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('81640006040000304','P142223240','P','1','4','2','2','2','3','2','4','0','SYSTEM');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('6828004705','M812IW3340','M','8','1','2','I','W','3','3','4','0','275281');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('3622002125','K212RJO340','K','2','1','2','R','J','O','3','4','0','TEMP001');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('7492002946','H513RJO250','H','5','1','3','R','J','O','2','5','0','276022');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('2561002635','A221MOW340','A','2','2','1','M','O','W','3','4','0','275464');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('7380002035','P612MRU530','P','6','1','2','M','R','U','5','3','0','TEMP002');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('8396000929','J211RJO340','J','2','1','1','R','J','O','3','4','0','SYSTEM');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('8902001921','B123RJO340','B','1','2','3','R','J','O','3','4','0','272144');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('5094000612','L142RJR340','L','1','4','2','R','J','R','3','4','0','225293');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('8803005315','L312TMH440','L','3','1','2','T','M','H','4','4','0','225293');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('5378004026','D121MNU140','D','1','2','1','M','N','U','1','4','0','134965');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('5414005625','L311RJR340','L','3','1','1','R','J','R','3','4','0','275251');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('6286005917','E323RJR240','E','3','2','3','R','J','R','2','4','0','274951');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('7824000540','E314SE0140','E','3','1','4','S','E','0','1','4','0','274951');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('3200001829','H525LR0000','H','5','2','5','L','R','0','0','0','0','248930');
    Insert into EXPORT_TABLE (PROPERTYID,EQID,ZONE_,AREA,GROUP_,GMA,STYLE,FLOORPLAN,BLDGCODEABBR,SIZE_,CONDITION,SUBGROUP,UPDATED_BY) values ('1102002714','G314MPW240','G','3','1','4','M','P','W','2','4','0','250794');
    CREATE
      TABLE "BRT_ADMIN"."DIMENSIONS"
        "PROPERTYID"  VARCHAR2(20 BYTE),
        "DIMENSIONID" NUMBER(38,0),
        "LANDDATE" DATE,
        "BLDGDATE" DATE,
        "PROCESSDATE" DATE,
        "INPUTUSER"         VARCHAR2(100 BYTE),
        "PLOTFRONT"         NUMBER(38,3),
        "PLOTDEPTH"         NUMBER(38,3),
        "PLOTSQFT"          NUMBER(38,3),
        "TOTALDWELLINGAREA" NUMBER(38,3),
        "TOTALFLOOR"        NUMBER(38,3),
        "SHAPE"             CHAR(1 BYTE),
        "GARAGE"            VARCHAR2(2 BYTE),
        CONSTRAINT "DIMENSIONS_PK" PRIMARY KEY ("DIMENSIONID") USING INDEX
    CREATE
        INDEX "BRT_ADMIN"."DIMEN_PID_TDWELLAREA" ON "BRT_ADMIN"."DIMENSIONS"
          "PROPERTYID",
          "TOTALDWELLINGAREA"
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('8318000324',506808,null,to_date('01-JUN-2001 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('19-JUN-2001 12:00 AM','DD-MON-YYYY HH:MI AM'),'DOMENIC J. DEMURO',15.5,56,868,1200,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('8814000708',336134,null,to_date('01-JUL-1999 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('30-JUL-1999 12:00 AM','DD-MON-YYYY HH:MI AM'),'margaret jimenez',16,69.29,1108.64,2265,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('8791002638',231697,null,null,to_date('29-OCT-2004 12:00 AM','DD-
    MON-YYYY HH:MI AM'),'DMEB020',15,65.38,980.7,0,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('6138000961',409453,to_date('01-AUG-2004 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('01-AUG-2002 12:00 AM','DD-MON-YYYY HH:MI AM'),to_date('18-AUG-2004 12:00 AM','DD-MON-YYYY HH:MI AM'),'DMEB017',14.75,78.5,1157.87,1357,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('8576002721',154908,null,null,to_date('29-OCT-2004 12:00 AM','DD-
    MON-YYYY HH:MI AM'),'DMEB020',12,72.99,875.88,0,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('3851000509',441426,to_date('01-AUG-2004 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('01-NOV-2003 12:00 AM','DD-MON-YYYY HH:MI AM'),to_date('18-AUG-2004 12:00 AM','DD-MON-YYYY HH:MI AM'),'DMEB017',63.94,97.96,6264,2358,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('2889011105',498582,null,to_date('01-AUG-2000 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('14-AUG-2000 12:00 AM','DD-MON-YYYY HH:MI AM'),'ANTHONY CELLO',19.92,102.16,2035.02,1400,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('6960000520',535448,to_date('30-DEC-2011 12:00 AM','DD-MON-YYYY
    HH:MI AM'),null,to_date('30-DEC-2011 12:00 AM','DD-MON-YYYY HH:MI AM'),'Donna Dirscherl',50,209.33,10342,0,0,'A','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('8902000005',398306,null,to_date('01-JUL-2001 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('11-JUL-2001 12:00 AM','DD-MON-YYYY HH:MI AM'),'BERNICE murphy',40,98,3920,7040,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('4624001130',341318,null,to_date('01-FEB-2001 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('27-FEB-2001 12:00 AM','DD-MON-YYYY HH:MI AM'),'JANINE TRAVALINA',15.96,66,1053.36,960,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('2798005812',459363,null,to_date('01-JAN-2001 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('19-JAN-2001 12:00 AM','DD-MON-YYYY HH:MI AM'),'ANTHONY D ELETTO',15.5,60,930,1112,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('1940000212000008A',500949,null,to_date('01-NOV-2010 12:00 AM','DD-
    MON-YYYY HH:MI AM'),to_date('02-NOV-2010 12:00 AM','DD-MON-YYYY HH:MI AM'),'GERALDINE WHITE',0,0,0,1068,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('1132006225',544051,to_date('01-AUG-2004 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('01-MAY-2002 12:00 AM','DD-MON-YYYY HH:MI AM'),to_date('18-AUG-2004 12:00 AM','DD-MON-YYYY HH:MI AM'),'DMEB017',16,63.5,1016,1088,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('6588004904',258106,to_date('01-NOV-2007 12:00 AM','DD-MON-YYYY
    HH:MI AM'),null,to_date('08-NOV-2007 12:00 AM','DD-MON-YYYY HH:MI AM'),'DMEB025',15.5,109.88,1703.14,1660,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('3504001628',166760,null,to_date('01-JAN-2001 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('10-JAN-2001 12:00 AM','DD-MON-YYYY HH:MI AM'),'BERNICE murphy',14.83,63.5,941.7,938,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('8817006645',285652,null,to_date('01-JUN-1999 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('22-JUN-1999 12:00 AM','DD-MON-YYYY HH:MI AM'),'ANTONETTE M. LAFAUCI',15.8,72.5,1145.5,1210,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('6450003427',115405,null,null,to_date('29-OCT-2004 12:00 AM','DD-
    MON-YYYY HH:MI AM'),'DMEB020',14,50,700,0,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('5284002600',416035,null,to_date('01-JAN-1999 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('11-JAN-1999 12:00 AM','DD-MON-YYYY HH:MI AM'),'rose cappo',15,40,600,750,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('8801003637',415464,null,to_date('01-OCT-2000 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('30-OCT-2000 12:00 AM','DD-MON-YYYY HH:MI AM'),'CARLA DOWNS',15.5,80,1240,1632,0,'E','0');
    Insert into EXPORT_TABLE (PROPERTYID,DIMENSIONID,LANDDATE,BLDGDATE,PROCESSDATE,INPUTUSER,PLOTFRONT,PLOTDEPTH,PLOTSQFT,TOTALDWELLINGAREA,TOTALFLOOR,SHAPE,GARAGE) values ('8878000860',163537,null,to_date('01-MAR-1999 12:00 AM','DD-MON-YYYY
    HH:MI AM'),to_date('30-MAR-1999 12:00 AM','DD-MON-YYYY HH:MI AM'),'VIVIAN REESE',15,60.5,907.5,1140,0,'E','0');
    CREATE
      TABLE "BRT_EVAL"."SIZE_CODE_RANGES"
        "STYLE"       CHAR(1 BYTE),
        "SIZE_"       CHAR(1 BYTE),
        "LOWVALUE"    NUMBER(38,0),
        "HIGHVALUE"   NUMBER(38,0),
        "DESCRIPTION" VARCHAR2(25 BYTE),
        CONSTRAINT "SIZE_CODE_RANGES_PK" PRIMARY KEY ("STYLE", "SIZE_") USING INDEX
    Insert into BRT_EVAL.SIZE_CODE_RANGES (STYLE,SIZE_,LOWVALUE,HIGHVALUE,DESCRIPTION) values ('2','2',400,1399,'400 sqft - 1399 sqft');
    Insert into BRT_EVAL.SIZE_CODE_RANGES (STYLE,SIZE_,LOWVALUE,HIGHVALUE,DESCRIPTION) values ('2','4',2600,3599,'2600 sqft - 3599 sqft');
    Insert into BRT_EVAL.SIZE_CODE_RANGES (STYLE,SIZE_,LOWVALUE,HIGHVALUE,DESCRIPTION) values ('P','3',1300,1601,'1300 sqft - 1601 sqft');
    Explain Plan:
    OPERATION     OPTIONS     OBJECT_NODE     OBJECT_OWNER     OBJECT_NAME     OBJECT_INSTANCE     OBJECT_TYPE     OPTIMIZER     SEARCH_COLUMNS     ID     PARENT_ID     POSITION     COST     CARDINALITY     BYTES     OTHER_TAG     
    PARTITION_START     PARTITION_STOP     PARTITION_ID     OTHER     DISTRIBUTION     CPU_COST     IO_COST     TEMP_SPACE
    SELECT STATEMENT                                   CHOOSE          0          14     14     1     63                                        14     
    TABLE ACCESS     BY INDEX ROWID          BRT_ADMIN     EQID     1          ANALYZED          1     0     1     2     1     16                                        2     
    NESTED LOOPS                                             2     1     1     14     1     63                                        14     
    NESTED LOOPS                                             3     2     1     6     4     188                                        6     
    TABLE ACCESS     FULL          BRT_EVAL     SIZE_CODE_RANGES     3                    4     3     1     2     1     32                                        2     
    INDEX     FAST FULL SCAN          BRT_ADMIN     DIMEN_PID_TDWELLAREA          NON-UNIQUE               5     3     2     4     1427     21405                                        4     
    INDEX     RANGE SCAN          BRT_ADMIN     EQID_PROPERTYID_IDX          NON-UNIQUE     ANALYZED     1     6     2     2     1     10                                             1     Edited by: ReubenC on Oct 16, 2012 9:50 AM

    I tried removing the index to see if that would have any effect. That appears to work OK. I would like to leave the index in place, however.
    Looks like NO_INDEX Hint works. First time using hints... I don't suppose there's anyway to tell it to use the index for one part of the where clause but not a different part?
    select /*+ NO_INDEX(d DIMEN_PID_TDWELLAREA) */  d.propertyid,d.totaldwellingarea, e.size_,  scr.size_
    from  eqid e, dimensions d,  brt_eval.size_code_ranges scr
    where e.style not in ('1','A','G','L') and e.size_  = '0' and totaldwellingarea <> 0
    and d.propertyid = e.propertyid and e.style = scr.style and totaldwellingarea >= scr.lowvalue and totaldwellingarea <= scr.highvalue;
    select /*+ NO_INDEX(d DIMEN_PID_TDWELLAREA) */  count(*)
    from  eqid e, dimensions d,  brt_eval.size_code_ranges scr
    where e.style not in ('1','A','G','L') and e.size_  = '0' and totaldwellingarea <> 0
    and d.propertyid = e.propertyid and e.style = scr.style and totaldwellingarea >= scr.lowvalue and totaldwellingarea <= scr.highvalue;Edited by: ReubenC on Oct 16, 2012 3:15 PM
    Edited by: ReubenC on Oct 16, 2012 3:22 PM
    OK figured all that out.

  • Ctx_doc.snippet increase the number of occurrences returned

    Hi everybody,
    I am pretty new on Oracle Text so please be merciful :)
    I am on Oracle 10.2.0.4.0 and I need to provide my users with ALL snippets found in a text, but it seems that CTX_DOC.SNIPPET restricts the number of snippets occurrences (I will exemplify it later).
    The question is: is there a way to increase the number of results/snippets returned by CTX_DOC.SNIPPET ?
    In the example that follows, I create the table "mysearch" and an index of type CTXSYS.CONTEXT, then I run the final SELECT query with CTX_DOC.SNIPPET() to obtain a list of most relevant fragments.
    If you run the query - see the column "SNIPPET" - record #6 is returning only the first 4 occurrences. In this case (especially because is a single row) I would expect to find all 6 occurrences instead of 4.
    Again, if looking to record #7 I have only 3 occurrences.
    Then for record #8 I have only 2 occurrences.
    I know that CTX_DOC.SNIPPET retrieves the "most" relevant fragment, but I would like to obtain the full list of fragments present in the indexed text. Is there a way (or an alternate method) to accomplish what I like to do.
    I have also noted that CTX_DOC.MARKUP can be used on the same index to retrieve the full text "marked-up" with my query terms, so I know Oracle has indexed the text somewhere, I need only to get it out !
    Any help will be very appreciated.
    Thanks,
    Luigi
    DROP TABLE mysearch;
    create table mysearch (text_id number primary key, text clob);
    insert into mysearch values (1, 'this is a test record which contains no more than one occurrence of the word you search');
    insert into mysearch values (2, 'this is a second test record which contains two occurrences of the word test');
    insert into mysearch values (3, 'this is a third test record which contains three test occurrences of the word test');
    insert into mysearch values (4, 'this test is a fourth test record which contains four test occurrences of the word test');
    insert into mysearch values (5, 'this test is the fifth test record which contains five test occurrences of the word test for test purposes');
    insert into mysearch values (6, 'this sixth test is a test with more than 200 character which contains many test occurrences of test word, sixth test record which contains sixth test occurrences of the word test for test purposes');
    insert into mysearch values (7,
    'Oracle Text adds powerful test search withintitle and intelligent test management to the Oracle database.  Complete.  You can test search and manage documents, web pages, catalog entries in more than test 150 formats in any language.  Provides a complete text query language and complete character support.  Simple.  You can index and search test  text using SQL. Oracle Test Management can be done using Oracle Test Manager - a GUI tool.  Fast.  You can search
    millions of documents, Test,web pages, catalog entries using the power and Test of the database.  Intelligent.  Oracle Text''s unique knowledge-base enables you to search, classify, manage documents, clusters Test summarize text based on its meaning as well as its content.');
    insert into mysearch values (8,'Written by the worlds most widely-read test authors of best-selling Oracle books, Mike Ault, Daniel Liu and Madhu Tumma target their substantial knowledge of test evaluating Oracle new features in this important book. test With decades of experience evaluating new Oracle features, this book focuses on the most important test new DBA features of Oracle 10g as they relate to database administration and Oracle tuning.
    This book provides honest feedback about those Oracle test 10g features that you should use, test and those you should not use. The text takes an in-depth look at test those Oracle10g features that are the most important to system performance and Oracle10g database administration.
    Best of all, the authors have created dozens of working test samples in the Oracle10g online code depot. Examples from all areas of Oracle10g are covered with working scripts and code snippets. Your time savings from a single script is test worth the price of this great book.
    Daniel Liu test is a senior Oracle Database test  Administrator at First American Real Estate Solutions in Anaheim, CA. He has many years of industry test experience in database administration and software development.  He has worked with large-scale databases in multi-platform environments.  His test expertise includes Oracle database administration, performance tuning, Oracle networking, and Oracle test Application Server. 
    As an Oracle Certified Professional, he taught Oracle certified DBA classes at Elite Consulting Group in Chicago. Daniel also taught IOUG University Seminar in Orlando.  Daniel has published articles with DBAzine, Oracle Internals, and SELECT Journal.  Daniel has received SELECT Editorial Test Award for Best Article in 2001.  He has also given presentations at IOUG-A Live, LAOUG, OCOUG, NoCOUG, Oracle Test Open World and Oracle World.   Daniel has served as panelist on Oracles of Oracle at Oracle World and IOUG-Live.  Daniel holds a Master of Science degree in computer science from Northern Illinois University.
    Madhu Tumma has been working as Software test Developer, IT Manager, Database Administrator, and Technical Consultant for about 18 years. He has worked on a wide variety of projects and environments ranging from mainframe, client-server, Test eBusiness to managed services. He has provided consultancy to variety of clients on database clusters, business continuity and high availability solutions.
    His experience ranges across multiple relational database systems. Madhu is frequent Test speaker at Oracle World and IOUG where he presented many technical papers. Madhu has Master Degree in test science and attended Business Management graduate program. He lives in New Jersey with his wife Hema and two children Sandi and Sudeep.');
    CREATE INDEX mysearchindex ON mysearch (text)
    INDEXTYPE IS CTXSYS.CONTEXT
    CALL CTX_DOC.SET_KEY_TYPE ('PRIMARY_KEY');
    SELECT  text_id,
            text,
            ctx_doc.snippet('mysearchindex',TO_CHAR(text_id), 'test') AS SNIPPET
    FROM    mysearch
    WHERE   CONTAINS (text, 'test', 1) > 0
    /

    You could even customize your function to specify how many words on either side of the keywords to return, as shown below.
    SCOTT@orcl_11gR2> CREATE OR REPLACE FUNCTION my_snippet
      2    (p_index_name IN VARCHAR2,
      3       p_textkey    IN VARCHAR2,
      4       p_text_query IN VARCHAR2,
      5       p_words      IN NUMBER DEFAULT 3)
      6    RETURN          CLOB
      7  AS
      8    v_markup      CLOB;
      9    v_string      VARCHAR2 (32767);
    10    v_snippet     CLOB;
    11  BEGIN
    12    CTX_DOC.MARKUP (p_index_name, p_textkey, p_text_query, v_markup);
    13    IF INSTR (v_markup, '<<<') > 0 AND INSTR (v_markup, '>>>') > 0 THEN
    14        v_markup := LPAD (' ', p_words) || v_markup || RPAD (' ', p_words);
    15        v_string := SUBSTR (v_markup, 1, INSTR (v_markup, '<<<') - 1);
    16        v_snippet := LTRIM (SUBSTR (v_string, INSTR (v_string, ' ', -1, p_words + 1)));
    17        LOOP
    18          v_markup := SUBSTR (v_markup, INSTR (v_markup, '<<<'));
    19          v_snippet := v_snippet || SUBSTR (v_markup, 1, INSTR (v_markup, '>>>') + 2);
    20          v_markup := SUBSTR (v_markup, INSTR (v_markup, '>>>') + 3);
    21          IF INSTR (v_markup, '>>>') = 0 THEN
    22            EXIT;
    23          END IF;
    24          v_string := SUBSTR (v_markup, 1, INSTR (v_markup, '<<<') - 1);
    25          IF REGEXP_COUNT (LTRIM (RTRIM (v_string)), ' ') <= (p_words * 2) - 1 THEN
    26            v_snippet := v_snippet || v_string;
    27          ELSE
    28            v_snippet := v_snippet || SUBSTR (v_string, 1, INSTR (v_string, ' ', 1, p_words + 1));
    29            v_snippet := v_snippet || ' ... ';
    30            v_string := SUBSTR (v_string, INSTR (v_string, ' ', 1, p_words + 1));
    31            v_snippet := v_snippet || SUBSTR (v_string, INSTR (v_string, ' ', -1, p_words + 1));
    32          END IF;
    33        END LOOP;
    34        v_snippet := v_snippet || RTRIM (SUBSTR (v_markup, 1, INSTR (v_markup, ' ', 1, p_words + 1)));
    35    END IF;
    36    RETURN v_snippet;
    37  END my_snippet;
    38  /
    Function created.
    SCOTT@orcl_11gR2> SHOW ERRORS
    No errors.
    SCOTT@orcl_11gR2> COLUMN  snippet FORMAT A80 WORD_WRAPPED
    SCOTT@orcl_11gR2> SELECT  text_id, SCORE (1) AS occurrences,
      2            my_snippet ('mysearchindex', TO_CHAR (text_id), 'test', 1) AS snippet
      3  FROM    mysearch
      4  WHERE   CONTAINS (text, 'DEFINESCORE (test, OCCURRENCE)', 1) > 0
      5  /
       TEXT_ID OCCURRENCES
    SNIPPET
             1           1
    a <<<test>>> record
             2           2
    second <<<test>>> record  ...  word <<<test>>>
             3           3
    third <<<test>>> record  ...  three <<<test>>> occurrences  ...  word <<<test>>>
             4           4
    this <<<test>>> is  ...  fourth <<<test>>> record  ...  four <<<test>>>
    occurrences  ...  word <<<test>>>
             5           5
    this <<<test>>> is  ...  fifth <<<test>>> record  ...  five <<<test>>>
    occurrences  ...  word <<<test>>> for <<<test>>> purposes
             6           8
    sixth <<<test>>> is a <<<test>>> with  ...  many <<<test>>> occurrences of
    <<<test>>> word, sixth <<<test>>> record  ...  sixth <<<test>>> occurrences  ...
    word <<<test>>> for <<<test>>> purposes
             7          10
    powerful <<<test>>> search  ...  intelligent <<<test>>> management  ...  can
    <<<test>>> search  ...  than <<<test>>> 150  ...  search <<<test>>>   ...
    Oracle <<<Test>>> Management  ...  Oracle <<<Test>>> Manager  ...  documents,
    <<<Test>>>,web pages,  ...  and <<<Test>>> of  ...  clusters <<<Test>>>
    summarize
             8          20
    widely-read <<<test>>> authors  ...  of <<<test>>> evaluating  ...  book.
    <<<test>>> With  ...  important <<<test>>> new  ...  Oracle <<<test>>> 10g  ...
    use, <<<test>>> and  ...  at <<<test>>> those  ...  working <<<test>>> samples
    ...  is <<<test>>> worth  ...  Liu <<<test>>> is  ...  Database <<<test>>>   ...
    industry <<<test>>> experience  ...  His <<<test>>> expertise  ...  Oracle
    <<<test>>> Application  ...  Editorial <<<Test>>> Award  ...  Oracle <<<Test>>>
    Open  ...  Software <<<test>>> Developer,  ...  client-server, <<<Test>>>
    eBusiness  ...  frequent <<<Test>>> speaker  ...  in <<<test>>> science
    8 rows selected.
    SCOTT@orcl_11gR2> SELECT  text_id, SCORE (1) AS occurrences,
      2            my_snippet ('mysearchindex', TO_CHAR (text_id), 'test', 2) AS snippet
      3  FROM    mysearch
      4  WHERE   CONTAINS (text, 'DEFINESCORE (test, OCCURRENCE)', 1) > 0
      5  /
       TEXT_ID OCCURRENCES
    SNIPPET
             1           1
    is a <<<test>>> record which
             2           2
    a second <<<test>>> record which  ...  the word <<<test>>>
             3           3
    a third <<<test>>> record which contains three <<<test>>> occurrences of the
    word <<<test>>>
             4           4
    this <<<test>>> is a fourth <<<test>>> record which contains four <<<test>>>
    occurrences of the word <<<test>>>
             5           5
    this <<<test>>> is the fifth <<<test>>> record which contains five <<<test>>>
    occurrences of the word <<<test>>> for <<<test>>> purposes
             6           8
    this sixth <<<test>>> is a <<<test>>> with more  ...  contains many <<<test>>>
    occurrences of <<<test>>> word, sixth <<<test>>> record which contains sixth
    <<<test>>> occurrences of the word <<<test>>> for <<<test>>> purposes
             7          10
    adds powerful <<<test>>> search withintitle and intelligent <<<test>>>
    management to  ...  You can <<<test>>> search and  ...  more than <<<test>>> 150
    formats  ...  and search <<<test>>>  text using SQL. Oracle <<<Test>>>
    Management can  ...  using Oracle <<<Test>>> Manager -  ...  of documents,
    <<<Test>>>,web pages, catalog  ...  power and <<<Test>>> of the  ...  documents,
    clusters <<<Test>>> summarize text
             8          20
    most widely-read <<<test>>> authors of  ...  knowledge of <<<test>>> evaluating
    Oracle  ...  important book. <<<test>>> With decades  ...  most important
    <<<test>>> new DBA  ...  those Oracle <<<test>>> 10g features  ...  should use,
    <<<test>>> and those  ...  look at <<<test>>> those Oracle10g  ...  of working
    <<<test>>> samples in  ...  script is <<<test>>> worth the  ...  book.
    Daniel Liu <<<test>>> is a  ...  Oracle Database <<<test>>>  Administrator  ...
    of industry <<<test>>> experience in  ...   His <<<test>>> expertise includes
    ...  and Oracle <<<test>>> Application Server.
    As  ...  SELECT Editorial <<<Test>>> Award for  ...  NoCOUG, Oracle <<<Test>>>
    Open World  ...  as Software <<<test>>> Developer, IT  ...  mainframe,
    client-server, <<<Test>>> eBusiness to  ...  is frequent <<<Test>>> speaker at
    ...  Degree in <<<test>>> science and
    8 rows selected.
    SCOTT@orcl_11gR2> SELECT  text_id, SCORE (1) AS occurrences,
      2            my_snippet ('mysearchindex', TO_CHAR (text_id), 'test', 3) AS snippet
      3  FROM    mysearch
      4  WHERE   CONTAINS (text, 'DEFINESCORE (test, OCCURRENCE)', 1) > 0
      5  /
       TEXT_ID OCCURRENCES
    SNIPPET
             1           1
    this is a <<<test>>> record which contains
             2           2
    is a second <<<test>>> record which contains  ...  of the word <<<test>>>
             3           3
    is a third <<<test>>> record which contains three <<<test>>> occurrences of the
    word <<<test>>>
             4           4
    this <<<test>>> is a fourth <<<test>>> record which contains four <<<test>>>
    occurrences of the word <<<test>>>
             5           5
    this <<<test>>> is the fifth <<<test>>> record which contains five <<<test>>>
    occurrences of the word <<<test>>> for <<<test>>> purposes
             6           8
    this sixth <<<test>>> is a <<<test>>> with more than  ...  which contains many
    <<<test>>> occurrences of <<<test>>> word, sixth <<<test>>> record which
    contains sixth <<<test>>> occurrences of the word <<<test>>> for <<<test>>>
    purposes
             7          10
    Text adds powerful <<<test>>> search withintitle and intelligent <<<test>>>
    management to the  ...   You can <<<test>>> search and manage  ...  in more than
    <<<test>>> 150 formats in  ...  index and search <<<test>>>  text using SQL.
    Oracle <<<Test>>> Management can be done using Oracle <<<Test>>> Manager - a
    ...  search
    millions of documents, <<<Test>>>,web pages, catalog entries  ...  the power and
    <<<Test>>> of the database.  ...  manage documents, clusters <<<Test>>>
    summarize text based
             8          20
    worlds most widely-read <<<test>>> authors of best-selling  ...  substantial
    knowledge of <<<test>>> evaluating Oracle new  ...  this important book.
    <<<test>>> With decades of  ...  the most important <<<test>>> new DBA features
    ...  about those Oracle <<<test>>> 10g features that you should use, <<<test>>>
    and those you  ...  in-depth look at <<<test>>> those Oracle10g features  ...
    dozens of working <<<test>>> samples in the  ...  single script is <<<test>>>
    worth the price  ...  great book.
    Daniel Liu <<<test>>> is a senior Oracle Database <<<test>>>  Administrator at
    ...  years of industry <<<test>>> experience in database  ...  environments.
    His <<<test>>> expertise includes Oracle  ...  networking, and Oracle <<<test>>>
    Application Server.
    As an  ...  received SELECT Editorial <<<Test>>> Award for Best  ...  OCOUG,
    NoCOUG, Oracle <<<Test>>> Open World and  ...  working as Software <<<test>>>
    Developer, IT Manager,  ...  from mainframe, client-server, <<<Test>>> eBusiness
    to managed  ...  Madhu is frequent <<<Test>>> speaker at Oracle  ...  Master
    Degree in <<<test>>> science and attended
    8 rows selected.
    SCOTT@orcl_11gR2> SELECT  text_id, SCORE (1) AS occurrences,
      2            my_snippet ('mysearchindex', TO_CHAR (text_id), 'test', 4) AS snippet
      3  FROM    mysearch
      4  WHERE   CONTAINS (text, 'DEFINESCORE (test, OCCURRENCE)', 1) > 0
      5  /
       TEXT_ID OCCURRENCES
    SNIPPET
             1           1
    this is a <<<test>>> record which contains no
             2           2
    this is a second <<<test>>> record which contains two occurrences of the word
    <<<test>>>
             3           3
    this is a third <<<test>>> record which contains three <<<test>>> occurrences of
    the word <<<test>>>
             4           4
    this <<<test>>> is a fourth <<<test>>> record which contains four <<<test>>>
    occurrences of the word <<<test>>>
             5           5
    this <<<test>>> is the fifth <<<test>>> record which contains five <<<test>>>
    occurrences of the word <<<test>>> for <<<test>>> purposes
             6           8
    this sixth <<<test>>> is a <<<test>>> with more than 200 character which
    contains many <<<test>>> occurrences of <<<test>>> word, sixth <<<test>>> record
    which contains sixth <<<test>>> occurrences of the word <<<test>>> for
    <<<test>>> purposes
             7          10
    Oracle Text adds powerful <<<test>>> search withintitle and intelligent
    <<<test>>> management to the Oracle  ...  Complete.  You can <<<test>>> search
    and manage documents,  ...  entries in more than <<<test>>> 150 formats in any
    ...  can index and search <<<test>>>  text using SQL. Oracle <<<Test>>>
    Management can be done using Oracle <<<Test>>> Manager - a GUI  ...  can search
    millions of documents, <<<Test>>>,web pages, catalog entries using the power and
    <<<Test>>> of the database.   ...  classify, manage documents, clusters
    <<<Test>>> summarize text based on
             8          20
    the worlds most widely-read <<<test>>> authors of best-selling Oracle  ...
    their substantial knowledge of <<<test>>> evaluating Oracle new features in this
    important book. <<<test>>> With decades of experience  ...  on the most
    important <<<test>>> new DBA features of  ...  feedback about those Oracle
    <<<test>>> 10g features that you should use, <<<test>>> and those you should
    ...  an in-depth look at <<<test>>> those Oracle10g features that  ...  created
    dozens of working <<<test>>> samples in the Oracle10g  ...  a single script is
    <<<test>>> worth the price of this great book.
    Daniel Liu <<<test>>> is a senior Oracle Database <<<test>>>  Administrator at
    First  ...  many years of industry <<<test>>> experience in database
    administration  ...  multi-platform environments.  His <<<test>>> expertise
    includes Oracle database  ...  Oracle networking, and Oracle <<<test>>>
    Application Server.
    As an Oracle  ...  has received SELECT Editorial <<<Test>>> Award for Best
    Article  ...  LAOUG, OCOUG, NoCOUG, Oracle <<<Test>>> Open World and Oracle  ...
    been working as Software <<<test>>> Developer, IT Manager, Database  ...
    ranging from mainframe, client-server, <<<Test>>> eBusiness to managed services.
    ...  systems. Madhu is frequent <<<Test>>> speaker at Oracle World  ...  has
    Master Degree in <<<test>>> science and attended Business
    8 rows selected.
    SCOTT@orcl_11gR2> SELECT  text_id, SCORE (1) AS occurrences,
      2            my_snippet ('mysearchindex', TO_CHAR (text_id), 'test', 5) AS snippet
      3  FROM    mysearch
      4  WHERE   CONTAINS (text, 'DEFINESCORE (test, OCCURRENCE)', 1) > 0
      5  /
       TEXT_ID OCCURRENCES
    SNIPPET
             1           1
    this is a <<<test>>> record which contains no more
             2           2
    this is a second <<<test>>> record which contains two occurrences of the word
    <<<test>>>
             3           3
    this is a third <<<test>>> record which contains three <<<test>>> occurrences of
    the word <<<test>>>
             4           4
    this <<<test>>> is a fourth <<<test>>> record which contains four <<<test>>>
    occurrences of the word <<<test>>>
             5           5
    this <<<test>>> is the fifth <<<test>>> record which contains five <<<test>>>
    occurrences of the word <<<test>>> for <<<test>>> purposes
             6           8
    this sixth <<<test>>> is a <<<test>>> with more than 200 character which
    contains many <<<test>>> occurrences of <<<test>>> word, sixth <<<test>>> record
    which contains sixth <<<test>>> occurrences of the word <<<test>>> for
    <<<test>>> purposes
             7          10
    Oracle Text adds powerful <<<test>>> search withintitle and intelligent
    <<<test>>> management to the Oracle database.  Complete.  You can <<<test>>>
    search and manage documents, web  ...  catalog entries in more than <<<test>>>
    150 formats in any language.  ...  You can index and search <<<test>>>  text
    using SQL. Oracle <<<Test>>> Management can be done using Oracle <<<Test>>>
    Manager - a GUI tool.  ...  You can search
    millions of documents, <<<Test>>>,web pages, catalog entries using the power and
    <<<Test>>> of the database.  Intelligent.  ...  search, classify, manage
    documents, clusters <<<Test>>> summarize text based on its
             8          20
    by the worlds most widely-read <<<test>>> authors of best-selling Oracle books,
    ...  target their substantial knowledge of <<<test>>> evaluating Oracle new
    features in this important book. <<<test>>> With decades of experience
    evaluating  ...  focuses on the most important <<<test>>> new DBA features of
    Oracle  ...  honest feedback about those Oracle <<<test>>> 10g features that you
    should use, <<<test>>> and those you should not  ...  takes an in-depth look at
    <<<test>>> those Oracle10g features that are  ...  have created dozens of
    working <<<test>>> samples in the Oracle10g online  ...  from a single script is
    <<<test>>> worth the price of this great book.
    Daniel Liu <<<test>>> is a senior Oracle Database <<<test>>>  Administrator at
    First American  ...  has many years of industry <<<test>>> experience in
    database administration and  ...  in multi-platform environments.  His
    <<<test>>> expertise includes Oracle database administration,  ...  tuning,
    Oracle networking, and Oracle <<<test>>> Application Server.
    As an Oracle Certified  ...  Daniel has received SELECT Editorial <<<Test>>>
    Award for Best Article in  ...  Live, LAOUG, OCOUG, NoCOUG, Oracle <<<Test>>>
    Open World and Oracle World.  ...  has been working as Software <<<test>>>
    Developer, IT Manager, Database Administrator,  ...  environments ranging from
    mainframe, client-server, <<<Test>>> eBusiness to managed services. He  ...
    database systems. Madhu is frequent <<<Test>>> speaker at Oracle World and  ...
    Madhu has Master Degree in <<<test>>> science and attended Business Management
    8 rows selected.
    SCOTT@orcl_11gR2>

  • How to create a Complex Organization Index  Materialized View Example

    Hi
    I have a 11g database that I'm trying to create a complex Materialized View that I would like to make Organization Index? How do I specify what I want for a primary Key?
    CREATE MATERIALIZED VIEW RCS_STG.MV_NEXT_HOP_iot
    ORGANIZATION INDEX
    AS
    SELECT r2.resource_key, r1.resource_key resource_key2, r2.resource_full_path_name, device_name, device_model,
    service_telephone_number, service_package_name, telephone_number.telephone_number_key, c1.created_on
    FROM network_resource PARTITION (network_resource_subinterface) r1,
    connection c1,
    network_resource PARTITION (network_resource_subinterface) r2,
    device d1,
    tn_network_resource,
    telephone_number
    WHERE r1.resource_key = c1.resource1_key
    AND c1.resource2_key = r2.resource_key
    AND d1.device_key = r2.device_key
    AND tn_network_resource.resource_key(+) = r2.resource_key
    AND telephone_number.telephone_number_key(+) = tn_network_resource.telephone_number_key
    UNION ALL
    SELECT r1.resource_key, r2.resource_key resource_key2, r1.resource_full_path_name, device_name, device_model,
    service_telephone_number, service_package_name, telephone_number.telephone_number_key, c1.created_on
    FROM network_resource PARTITION (network_resource_subinterface) r1,
    connection c1,
    network_resource PARTITION (network_resource_subinterface) r2,
    device d1,
    tn_network_resource,
    telephone_number
    WHERE r1.resource_key = c1.resource1_key
    AND c1.resource2_key = r2.resource_key
    AND d1.device_key = r1.device_key
    AND tn_network_resource.resource_key(+) = r1.resource_key
    AND telephone_number.telephone_number_key(+) = tn_network_resource.telephone_number_key
    I get an error message ORA-25175: no PRIMARY KEY constraint found
    I would like to specify resource_key, resource_key2, and service_telephone_number as my primary key?

    Ah,
    I get it now. This is what I did.
    CREATE TABLE mv_next_hop_iot
    resource_key NUMBER (38),
    resource_key2 NUMBER (38),
    resource_full_path_name VARCHAR2 (256 BYTE),
    device_name VARCHAR2 (64 BYTE),
    device_model VARCHAR2 (64 BYTE),
    service_telephone_number VARCHAR2 (20 BYTE),
    service_package_name VARCHAR2 (64 BYTE),
    telephone_number_key NUMBER (38),
    created_on DATE,
    CONSTRAINT mv_next_hop_pk PRIMARY KEY (resource_key, resource_key2, service_telephone_number)
    ORGANIZATION INDEX
    CREATE MATERIALIZED VIEW rcs_stg.mv_next_hop_iot
    ON PREBUILT TABLE
    AS
    /* Formatted on 2010/06/10 1:39:04 PM (QP5 v5.149.1003.31008) */
    SELECT resource_key, resource_key2, resource_full_path_name, device_name, device_model, service_telephone_number,
    service_package_name, telephone_number_key, created_on
    FROM (SELECT r2.resource_key, r1.resource_key resource_key2, r2.resource_full_path_name, device_name, device_model,
    NVL (service_telephone_number, ' ') AS service_telephone_number, service_package_name,
    telephone_number.telephone_number_key, c1.created_on
    FROM network_resource PARTITION (network_resource_subinterface) r1,
    connection c1,
    network_resource PARTITION (network_resource_subinterface) r2,
    device d1,
    tn_network_resource,
    telephone_number
    WHERE r1.resource_key = c1.resource1_key
    AND c1.resource2_key = r2.resource_key
    AND d1.device_key = r2.device_key
    AND tn_network_resource.resource_key(+) = r2.resource_key
    AND telephone_number.telephone_number_key(+) = tn_network_resource.telephone_number_key
    UNION ALL
    SELECT r1.resource_key, r2.resource_key resource_key2, r1.resource_full_path_name, device_name, device_model,
    NVL (service_telephone_number, ' ') AS service_telephone_number, service_package_name,
    telephone_number.telephone_number_key, c1.created_on
    FROM network_resource PARTITION (network_resource_subinterface) r1,
    connection c1,
    network_resource PARTITION (network_resource_subinterface) r2,
    device d1,
    tn_network_resource,
    telephone_number
    WHERE r1.resource_key = c1.resource1_key
    AND c1.resource2_key = r2.resource_key
    AND d1.device_key = r1.device_key
    AND tn_network_resource.resource_key(+) = r1.resource_key
    AND telephone_number.telephone_number_key(+) = tn_network_resource.telephone_number_key)
    Many thanks. the PREBUILT TABLE is the secret.

  • Text Index works fine consistently with Table, but not on underlying View

    Hi,
    We are facing weird issue relating to Oracle Text Indexes. Search using Oracle Text Index
    works fine on a Table, but when running query on View it gives sometimes (not consistently)
    ORA-20000: Oracle Text error:
    DRG-10849: catsearch does not support functional invocation
    DRG-10599: column is not indexed
    Sometimes it works.
    All of the below steps are run using User IR2OWNER:
    STEP 1: Table CPF_CUSTOMER created as follows (3 Non Text Indexes defined at time of creation )
    **Please note no Public Synonym is created for this Table**
    ** There is already another Table by same name CPF_CUSTOMER under different Owner (CDROWNER)
    and that Table has Public Synonym CPF_CUSTOMER created. Other Table CPF_CUSTOMER does not
    have any Views **
    create table CPF_CUSTOMER
    CPF_CUSTOMER_UUID NUMBER(20) not null,
    SAP_ID VARCHAR2(10 CHAR) not null,
    IRIS2_ID VARCHAR2(7 CHAR),
    NAME VARCHAR2(70 CHAR) not null,
    DRAFT_IND NUMBER(1) not null,
    ACTIVE_IND NUMBER(1) not null,
    REPLACED_BY_CUST VARCHAR2(10 CHAR),
    CRE_DT_GMT DATE,
    CRE_DT_LOC DATE,
    TIME_ZONE VARCHAR2(3 CHAR),
    CRE_USR VARCHAR2(8 CHAR),
    CHG_DT_GMT DATE,
    CHG_DT_LOC DATE,
    CHG_TIME_ZONE VARCHAR2(3 CHAR),
    CHG_USR VARCHAR2(8 CHAR),
    VFY_DT_GMT DATE,
    VFY_DT_LOC DATE,
    VFY_USR VARCHAR2(8 CHAR),
    DIVISION VARCHAR2(20 CHAR),
    SALES_ADMIN VARCHAR2(3 CHAR),
    MF_CUST_CDE VARCHAR2(14 CHAR),
    CR_CTRL_OFCE VARCHAR2(3 CHAR),
    DEFAULT_INV_CCY VARCHAR2(3 CHAR),
    AUTOBILL_OVRRD_IND NUMBER(1) not null,
    AUTOBILL NUMBER(1) not null,
    AUTOPRT_OVRRD_IND NUMBER(1) not null,
    AUTOPRT NUMBER(1) not null,
    AVE_PYMT_DAY NUMBER(3),
    TTL_INV_VAL NUMBER(12,2),
    INHERIT_CR_TERM_ASSGMT NUMBER(1) not null,
    NORMALIZED_NME VARCHAR2(70 CHAR),
    OB_PYMT_OFCE VARCHAR2(3 CHAR),
    IB_PYMT_OFCE VARCHAR2(3 CHAR),
    CGO_SMART_ID VARCHAR2(20 CHAR),
    REC_UPD_DT TIMESTAMP(6),
    NCPF_CUST_ID VARCHAR2(7) not null,
    CPF_CUST_LEVEL_UUID NUMBER(20) not null
    tablespace DBCPFP1_LG_DATA LOGGING;
    CREATE UNIQUE INDEX CPF_CUSTOMERI1 ON CPF_CUSTOMER
    (SAP_ID ASC) TABLESPACE DBCPFP1_LG_INDX;
    ALTER TABLE CPF_CUSTOMER
    ADD CONSTRAINT CPF_CUSTOMERI1 UNIQUE (SAP_ID);
    CREATE UNIQUE INDEX CPF_CUSTOMERI2 ON CPF_CUSTOMER
    (CPF_CUSTOMER_UUID ASC) TABLESPACE DBCPFP1_LG_INDX;
    ALTER TABLE CPF_CUSTOMER
    ADD CONSTRAINT CPF_CUSTOMERI2 UNIQUE (CPF_CUSTOMER_UUID);
    CREATE INDEX CPF_CUSTOMER_IDX2 ON CPF_CUSTOMER (UPPER(NAME))
    TABLESPACE DBCPFP1_LG_INDX;
    STEP 2: Create View CPF_CUSTOMER_RVW on above Table (and Public Synonym on View)
    This View is created under same OWNER as Table created in STEP 1 (IR2OWNER)
    create or replace view cpf_customer_rvw as
    select
    CPF_CUSTOMER_UUID,
    SAP_ID,
    IRIS2_ID,
    NAME,
    DRAFT_IND,
    ACTIVE_IND,
    REPLACED_BY_CUST,
    CRE_DT_GMT,
    CRE_DT_LOC,
    TIME_ZONE,
    CRE_USR,
    CHG_DT_GMT,
    CHG_DT_LOC,
    CHG_TIME_ZONE,
    CHG_USR,
    VFY_DT_GMT,
    VFY_DT_LOC,
    VFY_USR,
    DIVISION,
    SALES_ADMIN,
    MF_CUST_CDE,
    CR_CTRL_OFCE,
    DEFAULT_INV_CCY,
    AUTOBILL_OVRRD_IND,
    AUTOBILL,
    AUTOPRT_OVRRD_IND,
    AUTOPRT,
    AVE_PYMT_DAY,
    TTL_INV_VAL,
    INHERIT_CR_TERM_ASSGMT,
    NORMALIZED_NME,
    OB_PYMT_OFCE,
    IB_PYMT_OFCE,
    CGO_SMART_ID,
    NCPF_CUST_ID,
    CPF_CUST_LEVEL_UUID,
    REC_UPD_DT
    from CPF_CUSTOMER;
    CREATE OR REPLACE PUBLIC SYNONYM CPF_CUSTOMER_RVW FOR CPF_CUSTOMER_RVW;
    STEP 3: Insert Test row
    insert into cpf_customer (CPF_CUSTOMER_UUID, SAP_ID, IRIS2_ID, NAME, DRAFT_IND, ACTIVE_IND, REPLACED_BY_CUST, CRE_DT_GMT, CRE_DT_LOC, TIME_ZONE, CRE_USR, CHG_DT_GMT, CHG_DT_LOC, CHG_TIME_ZONE, CHG_USR, VFY_DT_GMT, VFY_DT_LOC, VFY_USR, DIVISION, SALES_ADMIN, MF_CUST_CDE, CR_CTRL_OFCE, DEFAULT_INV_CCY, AUTOBILL_OVRRD_IND, AUTOBILL, AUTOPRT_OVRRD_IND, AUTOPRT, AVE_PYMT_DAY, TTL_INV_VAL, INHERIT_CR_TERM_ASSGMT, NORMALIZED_NME, OB_PYMT_OFCE, IB_PYMT_OFCE, CGO_SMART_ID, NCPF_CUST_ID, CPF_CUST_LEVEL_UUID, REC_UPD_DT)
    values (2.26283572796028E15, '6588125000', '6588125', 'S M Mooseen And Sons(PVT) Limited', 0, 1, '', to_date('15-03-2005 08:55:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('15-03-2005 14:25:00', 'dd-mm-yyyy hh24:mi:ss'), 'IST', 'licr2', to_date('19-02-2007 00:33:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('19-02-2007 06:03:00', 'dd-mm-yyyy hh24:mi:ss'), 'IST', 'BaseAdmi', to_date('15-03-2005 09:03:00', 'dd-mm-yyyy hh24:mi:ss'), to_date('15-03-2005 14:33:00', 'dd-mm-yyyy hh24:mi:ss'), 'ninwasa', '', '', 'SRI06588125000', '463', '', 0, 0, 0, 0, null, null, 0, 'SMMOOSEENANDSONSPVTLIMITED', '', '', '', '6588125', 109966195050333, '14-JAN-09 02.49.28.325774 PM');
    commit;
    STEP 4: Create Oracle Text Index on Table CPF_CUSTOMER
    EXEC CTX_DDL.DROP_PREFERENCE('CTXCAT_IR2_STORAGE');
    EXEC CTX_DDL.CREATE_PREFERENCE('CTXCAT_IR2_STORAGE', 'BASIC_STORAGE');
    EXEC CTX_DDL.SET_ATTRIBUTE('CTXCAT_IR2_STORAGE', 'I_INDEX_CLAUSE', 'TABLESPACE COMMON_SM_INDX COMPRESS 2');
    EXEC CTX_DDL.SET_ATTRIBUTE('CTXCAT_IR2_STORAGE', 'I_INDEX_CLAUSE', 'TABLESPACE COMMON_SM_INDX COMPRESS 2');
    EXEC CTX_DDL.SET_ATTRIBUTE('CTXCAT_IR2_STORAGE', 'K_TABLE_CLAUSE', 'TABLESPACE COMMON_SM_INDX COMPRESS 2');
    EXEC CTX_DDL.SET_ATTRIBUTE('CTXCAT_IR2_STORAGE', 'R_TABLE_CLAUSE', 'TABLESPACE COMMON_SM_INDX COMPRESS 2');
    EXEC CTX_DDL.SET_ATTRIBUTE('CTXCAT_IR2_STORAGE', 'I_ROWID_INDEX_CLAUSE', 'TABLESPACE COMMON_SM_INDX storage (INITIAL 5M)');
    -- Define IR2_AB_LEXER to handle Special Characters.
    EXEC ctx_ddl.drop_preference('IR2_AB_LEXER');
    EXEC ctx_ddl.create_preference('IR2_AB_LEXER', 'BASIC_LEXER');
    EXEC ctx_ddl.set_attribute ('IR2_AB_LEXER', 'printjoins', ',_!$~%?=({;|&+-:/)}.@`^');
    --Drop Indexes
    drop index CPF_CUSTOMER_DIDX1;
    -- CATSEARCH INDEX on CPF_CUSTOMER.NAME     
    CREATE INDEX CPF_CUSTOMER_DIDX1 ON CPF_CUSTOMER(NAME) INDEXTYPE IS CTXSYS.CTXCAT PARAMETERS ('STORAGE CTXCAT_IR2_STORAGE STOPLIST CTXSYS.EMPTY_STOPLIST LEXER IR2_AB_LEXER');
    commit;
    STEP 5: Run Query to use Oracle Text Index on Base Table (works fine always. No issues seen so far)
    SELECT a.sap_id||'|'||a.name||'|' CUSTOMER_STR
    FROM cpf_customer a
    WHERE (catsearch(a.name, 'Mooseen'||'*', '')>0);
    CUSTOMER_STR
    6588125000|S M Mooseen And Sons(PVT) Limited|
    STEP 6: Run Query to use Oracle Text Index on View created under Table (get below error periodically)
    ORA-20000: Oracle Text error:
    DRG-10849: catsearch does not support functional invocation
    DRG-10599: column is not indexed
    But it works sometimes as in STEP 5 and returns 1 row. It is never consistent. We would like to
    provide access to this Table using View only. That is why we would like to get this query working consistently
    using View.
    Any help or tips would be greatly appreciated
    Thanks
    Auro

    This is a known issue with CTXCAT indexes. Sometimes the optimizer will "drive" the query off another index, and request results from the CTXCAT index on a row-by-row basis ("does the row with rowid NNNN satisfy this CATSEARCH condition?"). That's known as a functional lookup, and is not supported by the CTXCAT indextype.
    The only solution is to try to persuade the optimizer to use a different plan which does not use a functional lookup. This can be achieved by the use of hints, or sometimes by collecting or deleting statistics on the table.

  • Partitioned IOT of Object Type - mapping table not allowed for bitmap index

    Hi,
    looks like a feature available for standard Partitioned IOTs is not supported for object based tables, namely the MAPPING TABLE construct to support secondary local bitmap indexes.
    Can you confirm behaviour is as expected/documented?
    If so, is a fix/enhancement to support mapping table for object-based Partitioned IOTs in the pipeline?
    Results for partition-wise load using pipelined table function are very good, look-ups across tens of millions of rows are excellent.
    Environment = Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    OS = Oracle Enterprise Linux Server release 5.2 (Carthage) 2.6.18 92.el5 (32-bit)
    Here's the potted test-case...
    1) First the non object based Partitioned IOT - data is range-partitioned across the alphabet
    CREATE TABLE IOT_Table (
    textData VARCHAR2(10),
    numberData NUMBER(10,0),
    CONSTRAINT IOT_Table_PK PRIMARY KEY(textData))
    ORGANIZATION INDEX MAPPING TABLE PCTFREE 0 TABLESPACE Firewire
    PARTITION BY RANGE (textData)
    (PARTITION Text_Part_A VALUES LESS THAN ('B') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_B VALUES LESS THAN ('C') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_C VALUES LESS THAN ('D') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_D VALUES LESS THAN ('E') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_E VALUES LESS THAN ('F') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_F VALUES LESS THAN ('G') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_G VALUES LESS THAN ('H') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_H VALUES LESS THAN ('I') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_I VALUES LESS THAN ('J') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_J VALUES LESS THAN ('K') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_K VALUES LESS THAN ('L') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_L VALUES LESS THAN ('M') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_M VALUES LESS THAN ('N') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_N VALUES LESS THAN ('O') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_O VALUES LESS THAN ('P') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_P VALUES LESS THAN ('Q') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Q VALUES LESS THAN ('R') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_R VALUES LESS THAN ('S') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_S VALUES LESS THAN ('T') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_T VALUES LESS THAN ('U') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_U VALUES LESS THAN ('V') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_V VALUES LESS THAN ('W') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_W VALUES LESS THAN ('X') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_X VALUES LESS THAN ('Y') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Y VALUES LESS THAN ('Z') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Z VALUES LESS THAN (MAXVALUE) PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0))
    NOLOGGING PARALLEL -- FLASHBACK ARCHIVE IOT_Flashback_Data
    SQL> table IOT_TABLE created.
    2) Create the local secondary bitmap index utilising the underlying mapping table
    CREATE BITMAP INDEX IOT_Table_BMI1 ON IOT_Table (numberData)
    LOCAL STORAGE (INITIAL 1M PCTINCREASE 0 NEXT 512K) NOLOGGING PARALLEL;
    SQL> bitmap index IOT_TABLE_BMI1 created.
    3) Quick test to confirm all ok
    SQL> INSERT INTO IOT_Table VALUES ('ABC123',100);
    SQL> 1 rows inserted.
    SQL> SELECT * FROM IOT_Table;
    TEXTDATA NUMBERDATA
    ABC123     100
    4) Now create a minimal object type to use as the template for object table
    CREATE TYPE IOT_type AS OBJECT
    textData VARCHAR2(10 CHAR),
    numberData NUMBER(10,0)
    ) FINAL
    SQL> TYPE IOT_type compiled
    5) Attempt to create an object-based range partitioned IOT, including MAPPING TABLE clause as per step (1)
    CREATE TABLE IOTObj_Table OF IOT_type (textData PRIMARY KEY)
    OBJECT IDENTIFIER IS PRIMARY KEY ORGANIZATION INDEX
    MAPPING TABLE -- we'd like to use this feature to enable use of Bitmap Indexes...
    PCTFREE 0 TABLESPACE Firewire
    PARTITION BY RANGE (textData)
    (PARTITION Text_Part_A VALUES LESS THAN ('B') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_B VALUES LESS THAN ('C') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_C VALUES LESS THAN ('D') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_D VALUES LESS THAN ('E') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_E VALUES LESS THAN ('F') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_F VALUES LESS THAN ('G') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_G VALUES LESS THAN ('H') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_H VALUES LESS THAN ('I') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_I VALUES LESS THAN ('J') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_J VALUES LESS THAN ('K') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_K VALUES LESS THAN ('L') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_L VALUES LESS THAN ('M') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_M VALUES LESS THAN ('N') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_N VALUES LESS THAN ('O') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_O VALUES LESS THAN ('P') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_P VALUES LESS THAN ('Q') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Q VALUES LESS THAN ('R') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_R VALUES LESS THAN ('S') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_S VALUES LESS THAN ('T') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_T VALUES LESS THAN ('U') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_U VALUES LESS THAN ('V') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_V VALUES LESS THAN ('W') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_W VALUES LESS THAN ('X') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_X VALUES LESS THAN ('Y') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Y VALUES LESS THAN ('Z') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Z VALUES LESS THAN (MAXVALUE) PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0))
    NOLOGGING PARALLEL -- FLASHBACK ARCHIVE IOT_Flashback_Data
    This errors out with the following...
    SQL Error: ORA-25182: feature not currently available for index-organized tables
    25182. 00000 - "feature not currently available for index-organized tables"
    *Cause:    An attempt was made to use one or more of the following feature(s) not
    currently supported for index-organized tables:
    CREATE TABLE with LOB/BFILE/VARRAY columns,
    partitioning/PARALLEL/CREATE TABLE AS SELECT options,
    ALTER TABLE with ADD/MODIFY column options, CREATE INDEX
    *Action:   Do not use the disallowed feature(s) in this release.
    6) Re-running the create table statement in step 5 without the MAPPING TABLE clause works fine. Not surprisingly an attempt to create a secondary local bitmap index on this table fails as there's no mapping table, like so...
    CREATE BITMAP INDEX IOTObj_Table_BMI1 ON IOTObj_Table (numberData)
    LOCAL STORAGE (INITIAL 1M PCTINCREASE 0 NEXT 512K) NOLOGGING PARALLEL;
    CREATE TABLE with LOB/BFILE/VARRAY columns,
    partitioning/PARALLEL/CREATE TABLE AS SELECT options,
    ALTER TABLE with ADD/MODIFY column options, CREATE INDEX
    *Action:   Do not use the disallowed feature(s) in this release.
    CREATE BITMAP INDEX IOTObj_Table_BMI1 ON IOTObj_Table (numberData)
    LOCAL STORAGE (INITIAL 1M PCTINCREASE 0 NEXT 512K) NOLOGGING PARALLEL
    Error at Command Line:99 Column:13
    Error report:
    SQL Error: ORA-00903: invalid table name
    00903. 00000 - "invalid table name"
    7) Creating a secondary local b-tree index is fine, like so...
    SQL> CREATE INDEX IOTObj_Table_I1 ON IOTObj_Table (numberData)
    LOCAL STORAGE (INITIAL 1M PCTINCREASE 0 NEXT 512K) NOLOGGING PARALLEL;
    index IOTOBJ_TABLE_I1 created.
    8) A quick test to ensure object table ok...
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('DEF456',500));
    SQL> 1 rows inserted.
    SQL> SELECT * FROM IOTObj_Table;
    TEXTDATA NUMBERDATA
    DEF456     500

    Thanks Dan,
    the intention is to range partition based on the initial character, so A* -> Text_Part_A, B* -> Text_Part_B, and so on.
    Here's an example, using an empty IOTObj_Table as created previously.
    1) Set up & confirm some test data (two 'D's, one 'N', and two 'Z's)
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('DEF456',500));
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('DDD111',510));
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('N3000',515));
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('ZZ1212',520));
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('Z111X',530));
    SQL> COMMIT;
    SQL> SELECT * FROM IOTObj_Table;
    TEXTDATA NUMBERDATA
    DDD111     510
    DEF456     500
    N3000     515
    Z111X     530
    ZZ1212     520
    2) Just to prove our IOT is enforcing the Primary Key based on the TextData attribute, try to insert a duplicate
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('Z111X',530));
    Error starting at line 141 in command:
    INSERT INTO IOTObj_Table VALUES (IOT_Type('Z111X',530))
    Error report:
    SQL Error: ORA-00001: unique constraint (OCDataSystems.SYS_IOT_TOP_84235) violated
    00001. 00000 - "unique constraint (%s.%s) violated"
    *Cause:    An UPDATE or INSERT statement attempted to insert a duplicate key.
    For Trusted Oracle configured in DBMS MAC mode, you may see
    this message if a duplicate entry exists at a different level.
    *Action:   Either remove the unique restriction or do not insert the key.
    3) Now confirm that our data has been slotted into the range-based partition we expect using the PARTITION clause of SELECT...
    - The two 'D's...
    SQL> SELECT * FROM IOTObj_Table PARTITION (Text_Part_D);
    TEXTDATA NUMBERDATA
    DDD111     510
    DEF456     500
    - The single 'N'...
    SQL> SELECT * FROM IOTObj_Table PARTITION (Text_Part_N);
    TEXTDATA NUMBERDATA
    N3000     515
    - The two 'Z's...
    SQL> SELECT * FROM IOTObj_Table PARTITION (Text_Part_Z);
    TEXTDATA NUMBERDATA
    Z111X     530
    ZZ1212     520
    4) And to wrap up confirm an empty partition
    SELECT * FROM IOTObj_Table PARTITION (Text_Part_W);

  • How much time it take to rebuild an index for a table with 20 millions rows

    Hi all,
    i need to rebuild the index of a table containing 20 000 000 row (i don't know why the other people working on this didn't think of rebuilding the index regularly, because i asked and apparently it has never been done :cry: :cry:) i am not a sql developper nor a DBA so i can't mesure how long it take to rebuild the index, does any one have an idea (aproximativly of course :aie:), the other question is there any formula to use in order to calculate how often to rebuild the indexes (i can for example retieve how much rows are delated or inserted daily ...)
    Thanks again
    Taha

    taha wrote:
    :aie: that's why i am asking because i don't know (and to be sure which solution is best)
    so the table is like this (the columns) :
    45 varchar2, 5 timestamp, 30 Number no LOB columns, (15 indexes : 5 unique indexes and that those indexes uses at a maximum 4 columns)15 indexes - 100,000 deletes: this could mean 1,500,000 block visits to maintain index leaf blocks as the table rows are deleted. If you're unlucky this could turn into 1,500,000 physical block read requests; if you're lucky, or the system is well engineered this could be virtually no physical I/O. The difference in time could be huge. At any rate it is likely to be 1,500,000 redo entries at 250 - 300 bytes per entry for a total of about 400MB of redo (so how large are your redo logs and how many log switches are you going to cause).
    yes the tables is used by an application so (update, insert ) can take place at any time
    for the deletion , there is the batch which does a mass delete on the table ( 4 or 5 time each day)
    You haven't answered the question - how long does it take to do a sample batch delete.
    If you can enable SQL tracing, or take a before/after snapshot of v$sesstat or v$session_event for the session as it does the delete then you can get some idea of where the time is going - for all you know it might be spending most of its time waiting for a lock to do away.
    >
    "How many leaf blocks are currently allocated to the index(es) ?" how can i answer to this question ? may be if i check the all_objects table ?
    If you keep your statistics up to date then dba_indexes is a good place, cross-checked with dba_segments, and you can use the dbms_space package for more detail. I have a code sample on my blog which allows you to compare the current size of your indexes with the size they would be if rebuilt at some specific percentage: http://jonathanlewis.wordpress.com/index-sizing/ (It's such good code that Oracle Corp. has copied it into MOS note 989186.1)
    Regards
    Jonathan Lewis

  • Migrate B-Tree Indexes of XML O-R Table to XMLIndex on Binary XML Table

    We need slight help on how to migrate existing B-TREE Indexes from XML Obj-Rel Tables to XMLIndex on new XML Binary Tables
    We use searches on Nested Collection Elements (defined unbounded in XSD)
    and related DDL for XML Obj-Rel Tables is shown below:
    CREATE TABLE TNMAB_AGREEMENT_XML
    AGREEMENT_XML xmltype,
    CREATE_BY     VARCHAR2(15) NULL ,
    CREATE_DT_GMT     TIMESTAMP NULL ,
    CREATE_CLIENT_ID VARCHAR2(65) NULL ,
    UPDATE_BY     VARCHAR2(15) NULL ,
    UPDATE_DT_GMT     TIMESTAMP NULL ,
    UPDATE_CLIENT_ID VARCHAR2(65) NULL ,
    PIC_VERSION_NUM     NUMBER(20) NULL
    XMLTYPE COLUMN AGREEMENT_XML XMLSCHEMA "AB_Agreement_V1_XMLDB.xsd" ELEMENT "Agreement"
    VARRAY AGREEMENT_XML.XMLDATA."SHIPPING_PARTY_GROUPS"
    STORE AS TABLE SHIPPING_PARTY_GROUPS_NT
    (PRIMARY KEY (NESTED_TABLE_ID, ARRAY_INDEX) ENABLE)
    VARRAY SHIPPING_PARTIES
    STORE AS TABLE SHIPPING_PARTIES_NT
    (PRIMARY KEY (NESTED_TABLE_ID, ARRAY_INDEX) ENABLE)
    VARRAY AGREEMENT_XML.XMLDATA."SALES_OFFICE_CODES"."STRING_WRAPPERS"
    STORE AS TABLE SALES_OFFICE_CODES_NT
    (PRIMARY KEY (NESTED_TABLE_ID, ARRAY_INDEX) ENABLE)
    TABLESPACE TNMAB_XMLDB_ME_DATA;
    Table has PK and Unique Index which for the Binary XML Table, it will be setup on Virtual Columns (to enforce
    Unique Constraints)
    We have 6 more Normal Indexes on this Table, some created on Nested Elements as shown below:
    -- 4 Normal B-TREE Indexes on Leaf level Elements
    create index TNMAB_AGREEMENT_XML_IDX1 on TNMAB_AGREEMENT_XML (AGREEMENT_XML.XMLDATA."AGREEMENT_VERSION")
    tablespace TNMAB_XMLDB_ME_INDX;
    create index TNMAB_AGREEMENT_XML_IDX2 on TNMAB_AGREEMENT_XML (AGREEMENT_XML.XMLDATA."LAST_UPDATED_BY")
    tablespace TNMAB_XMLDB_ME_INDX;
    create index TNMAB_AGREEMENT_XML_IDX3 on TNMAB_AGREEMENT_XML (AGREEMENT_XML.XMLDATA."LAST_UPDATED")
    tablespace TNMAB_XMLDB_ME_INDX;
    create index TNMAB_AGREEMENT_XML_IDX4 on TNMAB_AGREEMENT_XML (AGREEMENT_XML.XMLDATA."CREATION_DATE")
    tablespace TNMAB_XMLDB_ME_INDX;
    --2 Indexes created on Nested Table (Collection)
    create index TNMAB_AGREEMENT_XML_NT_IDX1 on SALES_OFFICE_CODES_NT NT(NT.STR_VAL, NT.NESTED_TABLE_ID)
    tablespace TNMAB_XMLDB_ME_INDX;
    create index TNMAB_AGREEMENT_XML_NT_IDX2 on SHIPPING_PARTIES_NT NT(NT.CUSTOMER_HOLDER.SAP_ID, NT.NESTED_TABLE_ID)
    tablespace TNMAB_XMLDB_ME_INDX;
    Could you please let us know how we should migrate above Indexes to XMLIndex format.
    Specifically, not sure how the last 2 Indexes on Nested Tables is to be defined.
    Any help or resources pointing to this would be greatly appreciated.
    Thanks for the help,
    Auro

    Can't tell due to using XMLDATA pseudocolumn. Would need a sample XML document structure that can be used to define the XPATH structure and ALSO need the database version you are using (ALL digits) to see if you would need / can use STRUCTURED or UNSTRUCTURED XMLINDEX indexes.
    See the XML Index section (http://www.liberidu.com/blog/?page_id=441) on for guidance and/or of course the XMLDB Developers Guide for your database version
    http://www.liberidu.com/blog/?page_id=441
    XMLIndex (part 1) – The Concepts
    XMLIndex (Part 2) – XMLIndex Path Subsetting
    XMLIndex (Part 3) – XMLIndex Syntax Dissected
    XMLIndex Performance and Fuzzy XPath Searches
    Structured XMLIndex (Part 1) – Rules of Numb
    Structured XMLIndex (Part 2) – Howto build a structured XMLIndex
    Structured XMLIndex (Part 3) – Building Multiple XMLIndex Structures

  • How To Index a Connect by

    Hello; how should i index following statement
    SELECT
    I.IZAB_IZAB_ID ERSTEID,
    I.IZAB_ID ID,
    I.IZAB_SOLL_ABFAHRT_DATUM SOLLABFAHRTDATUM,
    I.IZAB_EINGANGS_TAG_PLAN EINGANGSTAG,
    I.SZAB_SOZU_SOZU_ZUG_NR ZUGNR,
    I.SZAB_SOZU_BEZK_BEZK_KUERZEL BEZKUERZEL,
    I.SZAB_LOKA_EBVK_EBVK_KZN_START EBVSTART,
    I.SZAB_LOKA_LOKA_BAST_NR_START BASTNRSTART,
    I.SZAB_LOKA_EBVK_EBVK_KZN_ENDE EBVENDE,
    I.SZAB_LOKA_LOKA_BAST_NR_ENDE BASTNRENDE,
    I.IZAB_BEREITSTELLUNGSZEITPUNKT BEREITSTELLZEIT,
    I.IZAB_IST_ABFAHRT_DATUM ABFAHRTDATUM,
    I.IZAB_IST_ANKUNFT_DATUM ANKUNFTDATUM,
    I.IZAB_KAPAZITAET_ACHSEN KPACHSEN,
    I.IZAB_KAPAZITAET_LAENGE KPLAENGE,
    I.IZAB_KAPAZITAET_GEWICHT KPGEWICHT,
    I.IZAB_KAPAZITAET_TASCHEN KPTASCHEN,
    I.IZAB_GEBUCHT_ACHSEN KPGEBACHSEN,
    I.IZAB_GEBUCHT_LAENGE KPGEBLAENGE,
    I.IZAB_GEBUCHT_GEWICHT KPGEBGEWICHT,
    I.IZAB_GEBUCHT_TASCHEN KPGEBTASCHEN,
    I.IZAB_BUCH_SCHLUSS_ALLG BUCHSCHLUSS
    FROM
    IZAB I
    START WITH
    I.SZAB_LOKA_EBVK_EBVK_KZN_START = 80
    AND I.SZAB_LOKA_LOKA_BAST_NR_START = 80721
    AND I.SZAB_SOZU_BEZK_BEZK_KUERZEL = 'E'
    AND I.SZAB_SOZU_SOZU_ZUG_NR = 43912
    AND TRUNC(I.IZAB_SOLL_ABFAHRT_DATUM) = TRUNC(SYSDATE)
    CONNECT BY
    I.IZAB_IZAB_ID = PRIOR I.IZAB_IZAB_ID
    AND I.SZAB_LOKA_EBVK_EBVK_KZN_START = PRIOR I.SZAB_LOKA_EBVK_EBVK_KZN_ENDE
    AND I.SZAB_LOKA_LOKA_BAST_NR_START = PRIOR I.SZAB_LOKA_LOKA_BAST_NR_ENDE
    AND I.SZAB_SOZU_SOZU_ZUG_NR = PRIOR I.SZAB_SOZU_SOZU_ZUG_NR
    AND I.SZAB_SOZU_BEZK_BEZK_KUERZEL = PRIOR I.SZAB_SOZU_BEZK_BEZK_KUERZEL
    AND I.SZAB_SOZU_SOZU_ZUG_NR = 43912
    AND I.SZAB_SOZU_BEZK_BEZK_KUERZEL = 'E'
    Table :
    IZAB_IZAB_ID NUMBER(8)
    IZAB_ID NUMBER(8)
    IZAB_SOLL_ABFAHRT_DATUM DATE
    IZAB_EINGANGS_TAG_PLAN DATE
    SZAB_SOZU_SOZU_ZUG_NR VARCHAR2(6) Y
    SZAB_SOZU_BEZK_BEZK_KUERZEL VARCHAR2(1) Y
    SZAB_LOKA_EBVK_EBVK_KZN_START NUMBER(2) Y
    SZAB_LOKA_LOKA_BAST_NR_START NUMBER(6) Y
    SZAB_LOKA_EBVK_EBVK_KZN_ENDE NUMBER(2) Y
    SZAB_LOKA_LOKA_BAST_NR_ENDE NUMBER(6) Y
    IZAB_BEREITSTELLUNGSZEITPUNKT DATE Y
    IZAB_IST_ABFAHRT_DATUM DATE Y
    IZAB_IST_ANKUNFT_DATUM DATE Y
    IZAB_KAPAZITAET_ACHSEN NUMBER(3,1) Y
    IZAB_KAPAZITAET_LAENGE NUMBER(6,3) Y
    IZAB_KAPAZITAET_GEWICHT NUMBER(10,3) Y
    IZAB_KAPAZITAET_TASCHEN NUMBER(2) Y
    IZAB_GEBUCHT_ACHSEN NUMBER(3,1) Y
    IZAB_GEBUCHT_LAENGE NUMBER(9,3) Y
    IZAB_GEBUCHT_GEWICHT NUMBER(13,3) Y
    IZAB_GEBUCHT_TASCHEN NUMBER(4) Y
    IZAB_BUCH_SCHLUSS_ALLG DATE Y
    IZAB_PROZENT_GEWICHT NUMBER(3) Y
    IZAB_PROZENT_LAENGE NUMBER(3) Y
    null

    Unless you think the people on this forum can simply read this code and parse/format it in their heads... you won't get anybody to help you.
    Please remember to place your code between \[code\] <your code goes here> \[code\] tags.
    Message was edited by:
    RACER

  • ORA-22160: element at index name does not exist

    hi
    i have a procedure which insert values from a VARRAY type in a table. My question is how can i verify the existence of nth element before inserting to avoid ORA-22160: element at index name does not exist
    Here is my code:
    CREATE OR REPLACE PACKAGE BODY CANDIDE.PE_CL IS
    PROCEDURE p_proc(Id_clt IN P_CLIENT.id_client%TYPE,
    nameClt IN P_CLIENT.nameclient%TYPE,
    --VARRAY type
    priceItem IN price_array,
    --VARRAY type
    nameItem IN item_array) IS
    BEGIN
    INSERT INTO P_CLIENT VALUES (Id_clt, nameClt);
    FORALL i IN nameItem.FIRST .. nameItem.LAST
    INSERT INTO P_ITEMS VALUES (Id_clt, nameItem(i), priceItem(i));
    END;
    end PE_CL;
    Product version: Oracle9i Enterprise Edition Release 9.2.0.1.0
    Peter

    I see the problem now. If there are more values in one varray or the other, how do you want to handle it? Below I have demonstrated, first the solution that I previous offered, that would only insert the rows where there are values from both varrays. In the second example below, I have inserted a null value in place of the missing value from the varray that has fewer values.
    scott@ORA92> CREATE TABLE p_client
      2    (id_client  NUMBER,
      3       nameclient VARCHAR2(15))
      4  /
    Table created.
    scott@ORA92> CREATE TABLE p_items
      2    (id_client  NUMBER,
      3       name_item  VARCHAR2(10),
      4       price_item NUMBER)
      5  /
    Table created.
    scott@ORA92> CREATE OR REPLACE PACKAGE PE_CL
      2  IS
      3    TYPE item_array IS ARRAY(10) OF VARCHAR2(10);
      4    TYPE price_array IS ARRAY(10) OF number;
      5    PROCEDURE p_proc
      6        (Id_clt    IN P_CLIENT.id_client%TYPE,
      7         nameClt   IN P_CLIENT.nameclient%TYPE,
      8         priceItem IN price_array,
      9         nameItem  IN item_array);
    10  end PE_CL;
    11  /
    Package created.
    scott@ORA92> show errors
    No errors.
    -- first method:
    scott@ORA92> CREATE OR REPLACE PACKAGE BODY PE_CL
      2  IS
      3    PROCEDURE p_proc
      4        (Id_clt    IN P_CLIENT.id_client%TYPE,
      5         nameClt   IN P_CLIENT.nameclient%TYPE,
      6         priceItem IN price_array,
      7         nameItem  IN item_array)
      8    IS
      9    BEGIN
    10        INSERT INTO P_CLIENT VALUES (Id_clt, nameClt);
    11  --    FORALL i IN nameItem.FIRST .. nameItem.LAST
    12  --      INSERT INTO P_ITEMS VALUES (Id_clt, nameItem(i), priceItem(i));
    13        FOR i IN nameItem.FIRST .. nameItem.LAST LOOP
    14          IF nameItem.EXISTS(i) AND priceItem.EXISTS(i) THEN
    15            INSERT INTO P_ITEMS VALUES (Id_clt, nameItem(i), priceItem(i));
    16          END IF;
    17        END LOOP;
    18    END;
    19  end PE_CL;
    20  /
    Package body created.
    scott@ORA92> show errors
    No errors.
    scott@ORA92> declare
      2    priceitem pe_cl.price_array := pe_cl.price_array(2, 5);
      3    nameitem pe_cl.item_array := pe_cl.item_array('item a', 'item b', 'item c');
      4  begin
      5    pe_cl.p_proc
      6        (id_clt    => 900,
      7         nameclt   => 'MIKE',
      8         priceitem => priceitem,
      9         nameitem  => nameitem);
    10    COMMIT;
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    scott@ORA92> SELECT * FROM p_client
      2  /
    ID_CLIENT NAMECLIENT
           900 MIKE
    scott@ORA92> SELECT * FROM p_items
      2  /
    ID_CLIENT NAME_ITEM  PRICE_ITEM
           900 item a              2
           900 item b              5
    scott@ORA92> TRUNCATE TABLE p_client
      2  /
    Table truncated.
    scott@ORA92> TRUNCATE TABLE p_items
      2  /
    Table truncated.
    -- second method:
    scott@ORA92> CREATE OR REPLACE PACKAGE BODY PE_CL
      2  IS
      3    PROCEDURE p_proc
      4        (Id_clt    IN P_CLIENT.id_client%TYPE,
      5         nameClt   IN P_CLIENT.nameclient%TYPE,
      6         priceItem IN price_array,
      7         nameItem  IN item_array)
      8    IS
      9    BEGIN
    10        INSERT INTO P_CLIENT VALUES (Id_clt, nameClt);
    11  --    FORALL i IN nameItem.FIRST .. nameItem.LAST
    12  --      INSERT INTO P_ITEMS VALUES (Id_clt, nameItem(i), priceItem(i));
    13        FOR i IN nameItem.FIRST .. nameItem.LAST LOOP
    14          IF nameItem.EXISTS(i) AND priceItem.EXISTS(i) THEN
    15            INSERT INTO P_ITEMS VALUES (Id_clt, nameItem(i), priceItem(i));
    16          ELSIF nameItem.EXISTS(i) THEN
    17            INSERT INTO P_ITEMS VALUES (Id_clt, nameItem(i), null);
    18          ELSIF priceItem.EXISTS(i) THEN
    19            INSERT INTO P_ITEMS VALUES (Id_clt, null, priceItem(i));
    20          END IF;
    21        END LOOP;
    22    END;
    23  end PE_CL;
    24  /
    Package body created.
    scott@ORA92> show errors
    No errors.
    scott@ORA92> declare
      2    priceitem pe_cl.price_array := pe_cl.price_array(2, 5);
      3    nameitem pe_cl.item_array := pe_cl.item_array('item a', 'item b', 'item c');
      4  begin
      5    pe_cl.p_proc
      6        (id_clt    => 900,
      7         nameclt   => 'MIKE',
      8         priceitem => priceitem,
      9         nameitem  => nameitem);
    10    COMMIT;
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    scott@ORA92> SELECT * FROM p_client
      2  /
    ID_CLIENT NAMECLIENT
           900 MIKE
    scott@ORA92> SELECT * FROM p_items
      2  /
    ID_CLIENT NAME_ITEM  PRICE_ITEM
           900 item a              2
           900 item b              5
           900 item c

  • DBMS_XMLGEN --Number of active cursors in increased in Exception block

    Hi ,
    We have a custom code that use DBMS_XMLGEN,the issue is when any exception happens the Number os active cusrors increse and when it happens in a lopp we hit 1000ORA-01000: maximum open cursors exceeded.
    Although I close the context in the exception Block.
    Below is sample code where I could replicate this:
    Step1.Create a table
    CREATE TABLE EMP(EMP_NO NUMBER,EMPNAME VARCHAR2(100));
    Step2:
    Create  a Procedure:
    CREATE OR REPLACE PROCEDURE TEST_XMLGEN
    AS
    l_clob CLOB;
      l_ctx         dbms_xmlgen.ctxhandle;
      p_sql VARCHAR2(4000):='SELECT EMP_NO,,EMPNAME FROM EMP';--syntax error on purpose ,so that exception happens
      l_cursor_count NUMBER;
    BEGIN
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
            DBMS_OUTPUT.PUT_LINE ('open cursors place00' || l_cursor_count);
    l_ctx := dbms_xmlgen.newcontext (p_sql);
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
             DBMS_OUTPUT.PUT_LINE('open cursors place01' || l_cursor_count);
    dbms_xmlgen.getxml (l_ctx,l_clob);
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
             DBMS_OUTPUT.PUT_LINE ('open cursors place02' || l_cursor_count);
    DBMS_OUTPUT.PUT_LINE('l_clob:'||l_clob);
    dbms_xmlgen.closecontext (l_ctx);
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
             DBMS_OUTPUT.PUT_LINE ('open cursors place03' || l_cursor_count);
    EXCEPTION
    WHEN OTHERS
    THEN
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
             DBMS_OUTPUT.PUT_LINE ('open cursors place04' || l_cursor_count);
    dbms_xmlgen.closecontext (l_ctx);
    SELECT VALUE
               INTO l_cursor_count
               FROM v$mystat a, v$statname b
              WHERE     a.statistic# = b.statistic#
                    AND b.name = 'opened cursors current';
             DBMS_OUTPUT.PUT_LINE ('open cursors place05' || l_cursor_count);
    END;
    Step3: Execute above Procedure
    If you look at the number of active cursor it is increased in exception block,I suspect this is what is causing issue with my program too.Any suggestions to solve this issue.
    Thanks
    Shefali

    Did you mean this test:
    declare
      ts timestamp;
      type tp_strings is table of varchar2(32767) index by pls_integer;
      t_strings tp_strings;
      t_tmp xmltype;
      t_nd dbms_xmldom.domnode;
      t_nl dbms_xmldom.domnodelist;
      t_clob clob;
    begin
      t_clob := '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
             || '<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="5000" uniqueCount="5000">';
      for i in 1 .. 5000
      loop
        t_clob := t_clob || to_clob( '<si><t>A' || to_char( i ) || '</t></si>' );
      end loop;
      t_clob := t_clob || '</sst>';
      t_tmp := xmltype( t_clob );
      t_strings.delete;
      ts := systimestamp;
          select str
          bulk collect into t_strings
          from xmltable( xmlnamespaces( default 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' )
                       , '/sst/si' passing t_tmp
                       columns str clob path 't'
      dbms_output.put_line( systimestamp - ts );
      dbms_output.put_line( t_strings.count() || ' ' || t_strings( t_strings.first )  || ' ' || t_strings( t_strings.last ) );
      t_strings.delete;
      ts := systimestamp;
          select /*+ NO_XML_QUERY_REWRITE */ str
          bulk collect into t_strings
          from xmltable( xmlnamespaces( default 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' )
                       , '/sst/si' passing t_tmp
                       columns str clob path 't'
      dbms_output.put_line( systimestamp - ts );
      dbms_output.put_line( t_strings.count() || ' ' || t_strings( t_strings.first )  || ' ' || t_strings( t_strings.last ) );
      t_strings.delete;
      ts := systimestamp;
          t_nd := dbms_xmldom.makenode( dbms_xmldom.getdocumentelement( dbms_xmldom.newdomdocument( t_tmp ) ) );
          t_nl := dbms_xslprocessor.selectnodes( t_nd, '/sst/si/t/text()', 'xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"' );
          for i in 0 .. dbms_xmldom.getlength( t_nl ) - 1
          loop
            t_strings( i ) := dbms_xmldom.getnodevalue( dbms_xmldom.item( t_nl, i ) );
          end loop;
      dbms_output.put_line( systimestamp - ts );
      dbms_output.put_line( t_strings.count() || ' ' || t_strings( t_strings.first )  || ' ' || t_strings( t_strings.last ) );
    end;  

  • 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

Maybe you are looking for