Difference between revisions of "Documentation/DevGuide/Database/Index Service"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
 
Line 14: Line 14:
 
The following code fragment displays the properties of a given index object:  
 
The following code fragment displays the properties of a given index object:  
 
<!--[SOURCE:Database/sdbcx.java]-->
 
<!--[SOURCE:Database/sdbcx.java]-->
 
+
<syntaxhighlight lang="java">
 
   // index properties
 
   // index properties
 
   public static void printIndexProperties(Object index) throws Exception, SQLException {
 
   public static void printIndexProperties(Object index) throws Exception, SQLException {
Line 25: Line 25:
 
       System.out.println("IsClustered: " + xProp.getPropertyValue("IsClustered"));
 
       System.out.println("IsClustered: " + xProp.getPropertyValue("IsClustered"));
 
   }
 
   }
 
+
</syntaxhighlight>
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Database Access]]
 
[[Category:Documentation/Developer's Guide/Database Access]]

Latest revision as of 15:09, 21 December 2020



The Index service encapsulates indexes at a table object. An index is described through the properties Name, Catalog, IsUnique, IsPrimaryKeyIndex, and IsClustered. All properties are read-only if an index has not been added to a tables index container. The last three properties are boolean values that indicate an index object only allows unique values, is used for the primary key, and if it is clustered. The property IsPrimaryKeyIndex is only available after the index has been created because it defines a special index that is created by the database while creating a primary key for a table object. Not all databases currently available in OpenOffice.org API support primary keys.

Index

The following code fragment displays the properties of a given index object:

  // index properties
  public static void printIndexProperties(Object index) throws Exception, SQLException {
      System.out.println("Example printIndexProperties");
      XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, index);
      System.out.println("Name: " + xProp.getPropertyValue("Name"));
      System.out.println("Catalog: " + xProp.getPropertyValue("Catalog"));
      System.out.println("IsUnique: " + xProp.getPropertyValue("IsUnique"));
      System.out.println("IsPrimaryKeyIndex: " + xProp.getPropertyValue("IsPrimaryKeyIndex"));
      System.out.println("IsClustered: " + xProp.getPropertyValue("IsClustered"));
  }
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages