Interface DatabaseResource

All Superinterfaces:
Element, Resource, java.io.Serializable

public interface DatabaseResource
extends Resource
The DatabaseResource interface represents a Database Resource which provides the ability to execute SQL statements. Each resource can operate in one of two modes: table mode or non-table mode.

In table mode, methods on this interface are not used. Instead, the Database Resource is configured as the backing resource for a Table. SQL statements are issued as a result of fetchTable()and updateTable()methods issued against the table.

In non-table mode, SQL statements are executed as a result of method calls to this interface. In general, these methods are intended to retrieve, update, insert or delete a single database row.

Further documentation.
Since:
V4.4
  • Method Summary

    Modifier and Type Method Description
    int delete()
    Builds and executes a delete SQL statement.
    int fetch()
    Builds and executes a select SQL statement and sets the value of mapped form fields with column values retrieved from the database.
    int insert()
    Builds and executes an insert SQL statement and inserts a table row with values obtained from mapped form fields.
    int update()
    Builds and executes an update SQL statement and updates the database with values obtained from mapped form fields.

    Methods inherited from interface com.ebasetech.xi.api.Element

    getElementName, getElementType

    Methods inherited from interface com.ebasetech.xi.api.Resource

    isDebug, setDebug
  • Method Details

    • fetch

      int fetch() throws com.ebasetech.xi.exceptions.FormRuntimeException
      Builds and executes a select SQL statement and sets the value of mapped form fields with column values retrieved from the database. This method is designed to be used to read a single database row. If multiple rows are returned by the database, only the last row retrieved will be returned to the form. To read multiple records, first create a table, then use the Table.fetchTable() method.

      If any of the resource fields in the Database Resource is marked as required but has no value, a FormRuntimeException is thrown.

      Further documentation.

      Returns:
      the number of records retrieved from the database
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs during execution, including a SQL error
      Since:
      V4.4
      See Also:
      Table.fetchTable()
    • update

      int update() throws com.ebasetech.xi.exceptions.FormRuntimeException, com.ebasetech.xi.exceptions.OptimisticLockingException
      Builds and executes an update SQL statement and updates the database with values obtained from mapped form fields. This method is primarily intended to be used to update a single database row. To perform operations on multiple records, first create a table, load the data, then use the Table.updateTable() method.

      If any of the resource fields in the Database Resource is marked as required but has no value, a FormRuntimeException is thrown.

      If the Optimistic Locking option has been activated in the form's properties, the system will check that the database record to be updated has not been altered by an external system since it was originally fetched. If this check fails, an OptimisticLockingException exception is thrown.

      Further documentation.

      Returns:
      the number of records updated in the database
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs during execution, including a SQL error
      com.ebasetech.xi.exceptions.OptimisticLockingException - if the database record to be updated has been altered by an external system since it was originally fetched
      Since:
      V4.4
      See Also:
      Table.updateTable()
    • delete

      int delete() throws com.ebasetech.xi.exceptions.FormRuntimeException
      Builds and executes a delete SQL statement. This method is primarily intended to be used to delete a single database row. To perform operations on multiple records, first create a table, load the data, then use the Table.updateTable() method.

      If any of the resource fields in the Database Resource is marked as required but has no value, a FormRuntimeException is thrown.

      Further documentation.

      Returns:
      the number of records deleted in the database
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs during execution, including a SQL error
      Since:
      V4.4
      See Also:
      Table.updateTable()
    • insert

      int insert() throws com.ebasetech.xi.exceptions.FormRuntimeException
      Builds and executes an insert SQL statement and inserts a table row with values obtained from mapped form fields. To perform operations on multiple records, first create a table, load the data, then use the Table.updateTable() method.

      Further documentation.

      Returns:
      the number of records inserted in the database - this is expected to be 1
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs during execution, including a SQL error
      Since:
      V4.4
      See Also:
      Table.updateTable()