Difference between revisions of "Documentation/DevGuide/Database/Column Service"
From Apache OpenOffice Wiki
< Documentation | DevGuide
(Initial author Sun Microsystems, Inc.) |
m (1 revision(s)) |
(No difference)
|
Revision as of 12:37, 15 February 2008
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:
- The normal
Column
service is used for the table object. - com.sun.star.sdbcx.KeyColumn extends the "normal" com.sun.star.sdbcx.Column service with an extra property named
RelatedColumn
. This property is the name of a referenced column out of the referenced table. - com.sun.star.sdbcx.IndexColumn extends the com.sun.star.sdbcx.Column service with an extra boolean property named
IsAscending
. This property is true when the index is ascending, otherwise it is false.
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). |