Column Service

From Apache OpenOffice Wiki
Jump to: navigation, search



The Column object is the simplest object structure in the SDBCX layer. It is a collection of properties that define the Column object. The columns container exists for table, key, and index objects. The Column object is a different for these objects:

Column

The Column object is defined by the following properties:

Properties of com.sun.star.sdbcx.Column
Name string - The name of the column.
Type com.sun.star.sdbc.DataType, long - The SDBC data type.
TypeName string - The database name for this type.
Precision long - The column's number of decimal digits.
Scale long - The column's number of digits to the left of the decimal point.
IsNullable long - Indicates the nullification of values in the designated column. com.sun.star.sdbc.ColumnValue
IsAutoIncrement boolean - Indicates if the column is automatically numbered.
IsCurrency boolean - Indicates if the column is a cash value.
IsRowVersion boolean - Indicates that the column contains some kind of time or date stamp used to track updates (optional).
Description string - Keeps a description of the object (optional).
DefaultValue string - Keeps a default value for a column (optional).

The Column object also supports the com.sun.star.sdbcx.XDataDescriptorFactory interface that creates a copy of this object.

  // column properties
  public static void printColumnProperties(Object column) throws com.sun.star.uno.Exception,SQLException {
      System.out.println("Example printColumnProperties");
      XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,column);
      System.out.println("Name: " + xProp.getPropertyValue("Name"));
      System.out.println("Type: " + xProp.getPropertyValue("Type"));
      System.out.println("TypeName: " + xProp.getPropertyValue("TypeName"));
      System.out.println("Precision: " + xProp.getPropertyValue("Precision"));
      System.out.println("Scale: " + xProp.getPropertyValue("Scale"));
      System.out.println("IsNullable: " + xProp.getPropertyValue("IsNullable"));
      System.out.println("IsAutoIncrement: " + xProp.getPropertyValue("IsAutoIncrement"));
      System.out.println("IsCurrency: " + xProp.getPropertyValue("IsCurrency"));
      // the following property is optional so we first must check if it exists
      if(xProp.getPropertySetInfo().hasPropertyByName("IsRowVersion"))
      System.out.println("IsRowVersion: " + xProp.getPropertyValue("IsRowVersion"));
      if(xProp.getPropertySetInfo().hasPropertyByName("Description"))
      System.out.println("Description: " + xProp.getPropertyValue("Description"));
      if(xProp.getPropertySetInfo().hasPropertyByName("DefaultValue"))
      System.out.println("DefaultValue: " + xProp.getPropertyValue("DefaultValue"));
  }
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages