DBWRITEFIELDS

Usage

TIBCO iProcess Workspace (Browser)

TIBCO iProcess Workspace (Windows)

Write specified fields within a work item to a table in the iProcess database on the server.

Warning: (iProcess only) This expression is not available to the TIBCO iProcess Script Server Plug-in. Therefore, even though you can successfully enter the expression in your iProcess Script plug-in definition, it will not be processed by the iProcess Engine. It will return SW_NA.

Syntax

DBWRITEFIELDS (TableName, IDString, fieldlist, ExcludeList, Flags)

where:

TableName is a text string giving the name of a table in the iProcess database.
IDString is user defined text that can be used to identify the records created in the database by this invocation of DBWRITEFIELDS.
fieldlist is a text string specifying the list of fields to be written, separated by commas. Wildcard characters * and ? can be included.
ExcludeList is a text string specifying the list of fields NOT to be written, even though selected in fieldlist. Wildcard characters * and ? can be included.
Flags is one or more of the following numeric values:

Value

Behavior

0

Default behavior

1

Write fields marked as changed only

2

Write fields with data only

4

Remove existing records first

8

Ignore step name

Returns

One of the following numeric values:

Value

Description

> 0

The number of field value records written to the table

Note: Note: Memo and attachment fields are not written to the database.

0

No fields matched include list and/or flags

-1

Function not supported by server

-2

Unspecified system error

-3

Failed to allocate FILDBWF session

-4

Function not supported in this context

Table Layout

The table that is written to by the DBWRITEFIELDS expression must have the following layout:

On a Windows SQL Server database:
TABLE swpro.DbFieldData(
node_id           INTEGER              NOT NULL,
proc_id           INTEGER              NOT NULL,
casenum           INTEGER              NOT NULL,
stepname          VARCHAR(8)           NULL,
id_string         VARCHAR(255)         NULL,
field_name        VARCHAR(31)          NOT NULL,
field_value       VARCHAR(255)         NULL,
field_flags       INTEGER              NOT NULL)
On an Oracle database:
TABLE swpro.DbFieldData(
node_id           NUMBER(5)            NOT NULL,
proc_id           NUMBER(5)            NOT NULL,
casenum           NUMBER(10)           NOT NULL,
stepname          VARCHAR2(8)          NULL,
id_string         VARCHAR2(255)        NULL,
field_name        VARCHAR2(31)         NOT NULL,
field_value       VARCHAR2(255)        NULL,
field_flags       NUMBER(10)           NOT NULL)

The table needs to have an index constructed from node_id, proc_id, casenum, and field_name.

The table must be created/owned by the iProcess database background user and the iProcess database foreground user must have select, insert, update and delete permissions.

Examples

TIBCO iProcess Modeler:

For a procedure with the following set of fields:

Currbalance, Retcode
Item01, Item02, Item03, Item04, Item05
Aaval1, Aaval2, Abval1, Abval2, Acval1, Acval2, Adval1, Adval2

The following expression:

Retcode := DBWRITEFIELDS ("CaseDataSnapshots", SW_USER:NAME "currbalance,itemval*,a?val*", "acval*", 2)

will result in all fields that have data (i.e. are not SW_NA), except for fields Adval1 and Adval2, being written to the table swpro.CaseDataSnapshots in the iProcess database. Each record will have associated the current step identifier and the user’s name. Any existing records for this case, step and user, and fields Adval1 or Adval2 would not be modified or deleted.

To remove all the records added by a number of instances of the previous expressions (perhaps for different users and steps within the procedure), the last step of the procedure could be an automatic step that executed the following expression:

Retcode := DBWRITEFIELDS ("CaseDataSnapshots", "", "", "", 12)

This would delete all records for this case, for any user name and for any step identifier.

TIBCO Business Studio:

The two database functions in the iProcess example can be replicated in TIBCO Business Studio as follows:

Retcode = IPEDatabaseUtil.DBWRITEFIELDS("CaseDataSnapshots",
IPEUserUtil.GETATTRIBUTE("NAME"), "currbalance,itemval*,a?val*",
"acval*", 2);
Retcode = IPEDatabaseUtil.DBWRITEFIELDS("CaseDataSnapshots", "",
"", "", 12);