11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER <strong>11</strong> ■ APPLICATION DEVELOPMENT 487XMLIndex Secondary IndexesYou can create one or more secondary indexes on the VALUE column of the path table. If you donot explicitly specify a secondary index on the VALUE column, a default secondary is created foryou. The default secondary index is created based on the text data only. Optionally, you canindex the VALUE column to be of another datatype. If you create a secondary index of NUMBERtype, this index is used only when it is necessary. In addition to different datatype indexes, youcan also create secondary indexes to be function-based or <strong>Oracle</strong> Text indexes. Let’s look atexamples of creating secondary indexes using function-based indexes on the path table:SQL> create index edba_po_xmlindex_upper_idxon sys71294_edba_po_xm_path_table(upper(substr(value, 1,120)));Index created.If the values are compared for uppercase values for the first 120 bytes, the UPPER(SUBSTR())function can become useful.You can also create <strong>Oracle</strong> Text context-based indexes on the VALUE column for full-textqueries that utilize ora:contains XPath functions:SQL> create index edba_secxmlindex_ctxon edba_security_path_table(value)indextype is ctxsys.contextparameters('TRANSACTIONAL');Index created.In the previous example, <strong>Oracle</strong> will utilize the VALUE column during predicate evaluation.The secondary index is by default a text-based index on the VALUE column of the path table.If all the data in the VALUE column happens to be numeric, you will want to change the datatype ofthe secondary index to NUMBER using the function-based index with the to_number(VALUE)clause. If there are any text values, you will receive an ORA-01722, “invalid number,” errorduring index creation. If you get this error, you can still create an index but must use the DBMS_XMLINDEX stored package. <strong>Oracle</strong> provides a CreateNumberIndex procedure to allow the creationof a numeric index.As you see here, the CreateNumberIndex procedure takes three parameters. The thirdparameter is the name of the numeric datatype index you want to name.procedure createnumberindexargument name type in/out default?----------------------- ----------- ---------------xml_index_schema varchar2 inxml_index_name varchar2 innum_index_name varchar2 inLet’s see this in action:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!