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

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
 
Line 59: Line 59:
 
The Column object also supports the <idl>com.sun.star.sdbcx.XDataDescriptorFactory</idl> interface that creates a copy of this object.  
 
The Column object also supports the <idl>com.sun.star.sdbcx.XDataDescriptorFactory</idl> interface that creates a copy of this object.  
 
<!--[SOURCE:Database/sdbcx.java]-->
 
<!--[SOURCE:Database/sdbcx.java]-->
 
+
<syntaxhighlight lang="java">
 
   // column properties
 
   // column properties
 
   public static void printColumnProperties(Object column) throws com.sun.star.uno.Exception,SQLException {
 
   public static void printColumnProperties(Object column) throws com.sun.star.uno.Exception,SQLException {
Line 80: Line 80:
 
       System.out.println("DefaultValue: " + xProp.getPropertyValue("DefaultValue"));
 
       System.out.println("DefaultValue: " + xProp.getPropertyValue("DefaultValue"));
 
   }
 
   }
 
+
</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 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