Interface BBjAdminTable

All Superinterfaces:
BBjAdminCommitPropertyWriter, BBjAdminCommitWriter, BBjAdminPropertyReader, BBjAdminPropertyWriter, Remote, Serializable
All Known Subinterfaces:
BBjAdminBBjTable, BBjAdminESQLTable, BBjAdminLegacyTable

public interface BBjAdminTable extends BBjAdminCommitPropertyWriter, Serializable

Represents an individual table in a database. The BBjAdminTable contains the properties describing the various parts of the table as well as methods to get the list of available columns, indexes, etc. Note that table definitions can differ from the actual structure of the table's data file so it is important to make sure that the definition matches the data file to eliminate confusion. For example a table definition can contain index definitions that are not actually present on the table's data file. This means that while the table definition says a particular set of columns are indexed, unless those are actually present on the data file, that index is not usable by the SQL engine's optimizer.

There are several ways to make changes to table definitions. One is using the Enterprise Manager. You can also make changes programmatically. The easiest way to change table structure is to use the SQL ALTER TABLE statement. The ALTER TABLE docs can be found here: ALTER TABLE.

ALTER TABLE statements are executed from an SQL tools such as the Enterprise Manager or your JDBC/ODBC program and look something like this:

ALTER TABLE my_table ADD COLUMN my_col VARCHAR(25)
ALTER TABLE my_table DROP COLUMN my_old_col
ALTER TABLE my_table ALTER COLUMN last_name VARCHAR (100)

Note that each ALTER TABLE statement will rewrite the entire data file to adjust the record layout/size so keep that in mind when using ALTER TABLE.

An alternative approach is to use the Admin API. With this method you can make numerous changes to the structure at one time and then only rewrite the data file once. This is more complex but more flexible as well (this is used by the Enterprise Manager). This can be done from a BBj or Java program. There is a handy method to change a table definition using a string template which many may find helpful. Here is a short example to give you an idea of how you could do this in BBj. One thing to keep in mind is that the Admin API gives you the ability to change the table definition without changing the data file, or to change the data file as well. Make sure to use the correct method to get the desired effect. The example below shows how you could add a new column to the CATEGORY table in the ChileCompany database, and also change the size of another column at the same time. You can play around with the ChileCompany DB to get a feel for it. Note the string template. We changed DESC to 130 characters and added NEW_COL at the end:

BBj Sample Code

declare BBjAdminBase admin!
declare BBjAdminDatabase db!
declare BBjAdminTable table!

REM Get a connection to the Admin system and then grab the database object
admin! = BBjAdminFactory.getBBjAdmin("admin","admin123")
db! = admin!.getDatabase("ChileCompany")

REM Get the table instance and change the column definitions.
table! = db!.getTable("CATEGORY")
tmpl$ = "PROD_CAT:C(2),DESC:C(130),COST_METHOD:C(5),COST_ACCOUNT:C(8),SALE_ACCOUNT:C(8),INV_ACCOUNT:C(8),NEW_COL:C(10**)"
table!.setTemplate(tmpl$)

REM This call tells the call to commit() to rewrite the data file. If you don't want
REM to rewrite the data file, set this to 0 (false)
table!.setShouldCommitUpdateDataFile(1)

REM Write your changes and update the data file.
table!.commit()

BBj Sample - Create FULLTEXT Index

The easiest way is with SQL using:
CREATE FULLTEXT INDEX ON my_table(col1, col2)

With the Admin API you can do it as well. To use the Admin API use the following example:

api! = BBjAdminFactory.getBBjAdmin("admin", "admin123")
db! = api!.getDatabase("MyDatabase")
table! = db!.getTable("MY_TABLE")

REM Specify the list of columns to include in the FULLTEXT index
indexCols! = api!.createBBjList()
indexCols!.add("COL1")
indexCols!.add("COL2")
table!.setList(BBjAdminTable.FULLTEXT_COLUMNS, indexCols!)

REM Save the table definition which will create the FULLTEXT index. Note, this
REM may take a while if the table large.
table!.commit()

REM Make sure to cleanup the API instance.
api!.release()
  • Field Details

    • ENCRYPTION_PLACEHOLDER

      static final String ENCRYPTION_PLACEHOLDER
      A placeholder value returned for tables that use an encryption string for the table. We don't return the actual encryption string for security purposes. If the value for ENCRYPTION_STRING contains this value, that means it is encrypted.
      See Also:
    • FILE_PASSWORD_PLACEHOLDER

      static final String FILE_PASSWORD_PLACEHOLDER
      A placeholder value returned for tables that use a password (not encrypted) for the table. We don't return the actual password for security purposes. If the value for FILE_PASSWORD contains this value, that means it is password protected.
      See Also:
    • NAME

      static final String NAME
      Name of the table.
      See Also:
    • ORIGINAL_NAME

      static final String ORIGINAL_NAME
      Original name of the table. This is read-only.
      See Also:
    • DESCRIPTION

      static final String DESCRIPTION
      Description of the table.
      See Also:
    • DATA_FILE

      static final String DATA_FILE
      Path to the data file. This should usually be relative to the DATA global or another user defined property. For example, do not use /mydata/CUSTOMER, instead use (DATA)CUSTOMER. This makes the database much more portable.
      See Also:
    • DATA_FILE_FULL_PATH

      static final String DATA_FILE_FULL_PATH
      Read-only full path to the data file.
      See Also:
    • TEMPLATE

      static final String TEMPLATE
      String template used to define the table.
      See Also:
    • LAST_ANALYSIS

      static final String LAST_ANALYSIS
      Date of the last time this table was successfully analyzed.
      See Also:
    • LAST_ANALYSIS_EXCEPTION

      static final String LAST_ANALYSIS_EXCEPTION
      If table analysis failed on the table, this is the exception that was generated.
      See Also:
    • ROW_COUNT

      static final String ROW_COUNT
      Number of rows in the table.
      See Also:
    • SCHEMA

      static final String SCHEMA
      Schema name for the table.
      See Also:
    • FILE_TYPE

      static final String FILE_TYPE
      File type defined for this table.
      See Also:
    • FILE_PASSWORD

      static final String FILE_PASSWORD
      File password to use for this table if it is password protected.
      See Also:
    • ENCRYPTION_STRING

      static final String ENCRYPTION_STRING
      File encryption string if this table's data file is encrypted.
      See Also:
    • ALERT_TYPE

      static final String ALERT_TYPE
      See Also:
    • KEY_SIZE

      static final String KEY_SIZE
      Key size if this is a single keyed file or 0 if it is multi-keyed.
      See Also:
    • RECORD_SIZE

      static final String RECORD_SIZE
      Record size of the table's data file.
      See Also:
    • MAX_ROW_COUNT

      static final String MAX_ROW_COUNT
      Maximum number of rows allowed in the table's data file or 0 if no limit.
      See Also:
    • FULLTEXT_COLUMNS

      static final String FULLTEXT_COLUMNS
      List of the columns that make up the FULLTEXT index if one is present.
      See Also:
    • FULLTEXT_INDEX_ENABLED

      static final String FULLTEXT_INDEX_ENABLED
      True if the FULLTEXT index on this table (if there is one) is enabled. If disabled, the index will not build automatically or remain in sync.
      See Also:
    • ANALYZER

      static final String ANALYZER
      Lucene analyzer class to use on the FULLTEXT index if one is present on this table.
      See Also:
    • STOPWORDS_LANG

      static final String STOPWORDS_LANG
      Lucene stopwords language code to use for the FULLTEXT index if one is present on this table.
      See Also:
    • FILE_TYPE_DIRECT_SORT

      static final int FILE_TYPE_DIRECT_SORT
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_STRING

      static final int FILE_TYPE_STRING
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_PROGRAM

      static final int FILE_TYPE_PROGRAM
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_DIRECTORY

      static final int FILE_TYPE_DIRECTORY
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_MKEYED

      static final int FILE_TYPE_MKEYED
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_MKEYED_RECOVERABLE

      static final int FILE_TYPE_MKEYED_RECOVERABLE
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_MKEYED_64BIT

      static final int FILE_TYPE_MKEYED_64BIT
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_MKEYED_64BIT_RECOVERABLE

      static final int FILE_TYPE_MKEYED_64BIT_RECOVERABLE
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_XKEYED

      static final int FILE_TYPE_XKEYED
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_XKEYED_RECOVERABLE

      static final int FILE_TYPE_XKEYED_RECOVERABLE
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_VKEYED

      static final int FILE_TYPE_VKEYED
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
    • FILE_TYPE_ESQL

      static final int FILE_TYPE_ESQL
      Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.
      See Also:
  • Method Details

    • shouldCommitUpdateDataFile

      boolean shouldCommitUpdateDataFile()
      Should commit update the data file?
      Returns:
      True if the definition is currently set to update the data file to match the definition on a call to the BBjAdminCommitWriter.commit() method.
    • shouldCommitUpdateDataFile

      @Deprecated void shouldCommitUpdateDataFile(boolean p_update)
      Sets whether a commit should also update/create the data file, or if is should only make changes to the data dictionary.
      Parameters:
      p_update -
    • setShouldCommitUpdateDataFile

      void setShouldCommitUpdateDataFile(boolean p_update)
      Sets whether a commit should also update/create the data file, or if is should only make changes to the data dictionary.
      Parameters:
      p_update -
    • getType

      Get the data file type of the data file used by the table.
      Returns:
      The type of the file. One of the BBjAdminTable.Type enum.
      Throws:
      BBjAdminException
    • getTemplate

      String getTemplate() throws BBjAdminException
      Get a BBj string template from the column definitions.
      Returns:
      BBj string template that matches the column definitions.
      Throws:
      BBjAdminException
    • getTemplate

      String getTemplate(boolean p_detailed) throws BBjAdminException
      Get a BBj string template from the column definitions.
      Parameters:
      p_detailed - True if you want the detailed attributes filled in as well.
      Returns:
      The string template defining the columns that make up the table.
      Throws:
      BBjAdminException
    • setTemplate

      void setTemplate(String p_template) throws BBjAdminException
      Very powerful, helpful method to set all the column definitions at one time from a standard BBj string template. This method can save a lot of busy work coding column definitions and is a great way to make multiple changes quickly and succinctly.
      Parameters:
      p_template - Standard BBj string template to use to define the columns for the table.
      Throws:
      BBjAdminException
    • getColumns

      Get a list of the columns in the table. Add/remove columns to/from this list to make changes to the table definition. Call the BBjAdminCommitWriter.commit() method to save the changes. Call the setShouldCommitUpdateDataFile(boolean) passing in true to have the BBjAdminCommitWriter.commit() call update the table's data file structure to match the definitions.
      Returns:
      The list of BBjAdminColumn objects that define the table.
      Throws:
      BBjAdminException
    • getCrossReferences

      Returns a list of the cross references (foreign keys) on this table.
      Returns:
      List of all the BBjAdminCrossReference objects on this table. This will not return anything on legacy data dictionaries unless the table is an ESQL table. Enhanced dictionaries support cross references (foreign keys).
      Throws:
      BBjAdminException
    • setColumns

      void setColumns(BBjAdminList<BBjAdminColumn> p_columns) throws BBjAdminException
      Set a new list of columns for this table (not committed).
      Parameters:
      p_columns -
      Throws:
      BBjAdminException
    • setCrossReferences

      void setCrossReferences(BBjAdminList<BBjAdminCrossReference> p_crossReferences) throws BBjAdminException
      Sets the list of cross references (foreign keys) on this table.
      Parameters:
      p_crossReferences -
      Throws:
      BBjAdminException
    • getIndexes

      Get a list of the indexes in the table.
      Returns:
      The list of indexes defined on the table. This returns the indexes from the data dictionary and may be different than those defined on the data file. Call getIndexesFromDataFile() to return the indexes actually present on the table's data file.
      Throws:
      BBjAdminException
    • setIndexes

      void setIndexes(BBjAdminList<BBjAdminIndex> p_indexes) throws BBjAdminException
      Set a new list of indexes for this table (not committed).
      Parameters:
      p_indexes -
      Throws:
      BBjAdminException
    • createIndex

      BBjAdminIndex createIndex() throws BBjAdminException
      Creates a new instance of a BBjAdminIndex on the table. The index needs to be added to the list returned in getIndexes().
      Returns:
      The new BBjAdminIndex created. Make sure to add the returned object to the list returned in getIndexes().
      Throws:
      BBjAdminException
    • createColumn

      BBjAdminColumn createColumn() throws BBjAdminException
      Creates a new instance of a BBjAdminColumn on the table. You still need to add the column to the list returned in a call to getColumns().
      Returns:
      New BBjAdminColumn object created.
      Throws:
      BBjAdminException
    • createCrossReference

      BBjAdminCrossReference createCrossReference() throws BBjAdminException
      Creates a new instance of a BBjAdminCrossReference (foreign key). You still need to add the cross reference to the list returned by a call to getCrossReferences().
      Returns:
      The newly created BBjAdminCrossReference.
      Throws:
      BBjAdminException
    • getColumn

      BBjAdminColumn getColumn(String p_column) throws BBjAdminException
      Gets an instance of BBjAdminColumn from the table for the specified column name. If the column is not valid, returns null.
      Parameters:
      p_column - Name of the column.
      Returns:
      Column instance for the specified column.
      Throws:
      BBjAdminException
    • getMaxColumnValueLength

      int getMaxColumnValueLength(String p_column) throws BBjAdminException
      Throws:
      BBjAdminException
    • startAnalysis

      void startAnalysis() throws BBjAdminException
      Starts table analysis on this table.
      Throws:
      BBjAdminException
    • getTriggers

      BBjAdminTriggers getTriggers() throws BBjAdminException
      Returns the triggers on this table's data file if there are any, or null if there are none.
      Returns:
      The triggers currently defined on this table.
      Throws:
      BBjAdminException
    • getIndexesFromDataFile

      BBjAdminList<BBjAdminIndex> getIndexesFromDataFile() throws BBjAdminException
      Derives and returns a list of indexes from the data file associated with this table even before the table has ever been committed to the database. This call examines the physical data file and its current key structure.
      Returns:
      List of the indices currently present on the table's data file. This only uses the data dictionary information for index names.
      Throws:
      BBjAdminException
    • getDescriptiveProperties

      BBjAdminList<BBjAdminProperty> getDescriptiveProperties() throws BBjAdminException
      Used primarily by GUI applications like the Enterprise Manager to dynamically generate an admin UI. To get property values for general purposes, you should call the getXXX() methods.
      Returns:
      BBjAdminList containing BBjAdminProperty objects for each available property.
      Throws:
      BBjAdminException
    • setDescriptiveProperties

      void setDescriptiveProperties(BBjAdminList<BBjAdminProperty> p_descriptiveProps) throws BBjAdminException
      Used primarily by GUI applications like the Enterprise Manager to dynamically generate an admin UI. To set property values for general purposes, you should call the setXXX() methods.
      Throws:
      BBjAdminException
    • rebuildFullTextIndex

      void rebuildFullTextIndex() throws BBjAdminException
      Rebuilds the current FULLTEXT index if one is present. This call should really only be called if there is known synchronization issues between the data in the data file and the data in the FULLTEXT index, or if you restore a data file from backup but do not also restore the MY_FILE.textsearch directory at the same time.
      Throws:
      BBjAdminException