Key Service

From Apache OpenOffice Wiki
Jump to: navigation, search

The Key service provides the foreign and primary keys behavior through the following properties. The Name property is the name of the key. It could happen that the primary key does not have a name. The property Type contains the kind of the key, that could be PRIMARY, UNIQUE, or FOREIGN, as specified by the constant group The property ReferencedTable contains a value when the key is a foreign key and it designates the table to which a foreign key points. The DeleteRule and UpdateRule properties determine what happens when a primary key is deleted or updated. The possibilities are defined in CASCADE, RESTRICT, SET_NULL, NO_ACTION and SET_DEFAULT.


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

 // key properties
 public static void printKeyProperties(Object key) throws Exception, SQLException {
     System.out.println("Example printKeyProperties");
     XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, key);
     System.out.println("Name: " + xProp.getPropertyValue("Name"));
     System.out.println("Type: " + xProp.getPropertyValue("Type"));
     System.out.println("ReferencedTable: " + xProp.getPropertyValue("ReferencedTable"));
     System.out.println("UpdateRule: " + xProp.getPropertyValue("UpdateRule"));
     System.out.println("DeleteRule: " + xProp.getPropertyValue("DeleteRule"));
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages