Interface DatabaseResource
public interface DatabaseResource extends Resource
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()
methods issued against the table.
and
updateTable()
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.
- select statements:
fetch()
- update statements:
update()
- insert statements:
insert()
- delete statements:
delete()
- 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
-
Method Details
-
fetch
int fetch() throws com.ebasetech.xi.exceptions.FormRuntimeExceptionBuilds 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 theTable.fetchTable()
method.If any of the resource fields in the Database Resource is marked as required but has no value, a FormRuntimeException is thrown.
- 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.OptimisticLockingExceptionBuilds 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 theTable.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.
- Returns:
- the number of records updated in the database
- Throws:
com.ebasetech.xi.exceptions.FormRuntimeException
- if any error occurs during execution, including a SQL errorcom.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.FormRuntimeExceptionBuilds 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 theTable.updateTable()
method.If any of the resource fields in the Database Resource is marked as required but has no value, a FormRuntimeException is thrown.
- 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.FormRuntimeExceptionBuilds 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 theTable.updateTable()
method.- 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()
-