Open topic with navigation

TIBCO® Patterns 6.1.2

# Updating Records in a Database (lkt_dbrecupdate)

The lkt_dbrecupdate command combines the functionality of lkt_dbrecadd, lkt_dbrecreplace and lkt_dbrecdelete. If a simple record is passed to the command, it adds the record if a record with the same key does not exist; if a record with the same key exists, the existing record is replaced with the record that was passed in. If it is passed in a record operation list, it performs the indicated action for the record: adding, deleting or replacing the record.

    dvkerr_t lkt_dbrecupdate(lpar_t host, lpar_t dbname, lpar_t reclist,
                              lpar_t params, lpar_t *dbstats );
    dvkerr_t lkt_dbrecupdateT(lpar_t host, lpar_t dbname, lpar_t tran,
                              lpar_t reclist, lpar_t params,
                              lpar_t *dbstats );

## Input

## host (optional)

This is used to identify the server. For more information, see Communicating with TIBCO Patterns Servers.

## dbname (required)

is the name of the database (LPAR_STR_DBDESCRIPTOR) in which records are added or replaced.

## reclist (required)

is a generic list of records or record operations. The list might contain a mix of these. If a list item is a record and a record with the same key exists in the table, the record in the table is replaced with the given record. If the list item is a record and a record with the same key does not exist in the table, the given record is added to the table.

A list item might also be a record operation. A record operation is an LPAR_LST_REC_OP list. This list must contain exactly two elements (in any order):

| • | LPAR_LST_RECORD An LPAR record.

| • | LPAR_STR_REC_OP This LPAR defines the record operation to be performed. It must be one of the following string values. Any other value results in a DVK_ERR_PARAMVAL error. The values are letter case sensitive.

| — | “ADD” The record is added to the table. If a record with the same key already exists in the table, the operation fails with a `DVK_ERR_RECEXISTS` error, unless the “Do Max Work” flag is set, in which case the error is quietly ignored.

| — | “DEL” The record is deleted from the table. If a record with the same key does not exist in the table, the operation fails with a `DVK_ERR_RECNOTFOUND` error, unless the “Do Max Work” flag is set, in which case the error is quietly ignored. For this operation the given record only needs to contain the key data. The field data might be left empty. It is not required it have the correct number of fields.

| — | “RPL” The record in the table is replaced in its entirety with the given record. If a record with the same key does not exist in the table, the operation fails with a `DVK_ERR_RECNOTFOUND` error, unless the “Do Max Work” flag is set, in which case the error is quietly ignored.

| — | “UPD” If a record with the same key does not exist in the table, the given record is added; otherwise the record in the table is replaced in its entirety with the given record. This is the same operation that is performed when a record instead of a record operation appears in the list.

Like the lkt_dbload command, a file specification might be used in place of the record or record operation list. The file contains records, not record operations. Therefore, the update operation is applied to all records in the file.

## params (optional)

is a list of updating parameters:

| • | LPAR_BOOL_DOMAXWORK: If this parameter is false, any error causes the complete failure of the command (For example, no records are replaced in database dbname).

If this parameter is true, maximum work is done. Records in reclist that can't be loaded due to errors such as character conversion errors, are quietly ignored and all other records are loaded.

Default value: false

| • | LPAR_INT_LOCKKEY allows this update to go through on a database containing a keyed lock if the key value matches the lock value.

Default value: N/A

| • | LPAR_INT_DBNUMRECORDS gives an estimate of the number of records in the record list. It is not necessary that this value be exact or even close. This is used by the TIBCO Patterns server to determine the most efficient means of loading records.

Default value: 0 (It assumes a small batch of records). The exception is if loading using an LPAR_LST_REMOTEFILE file specification, the assumption is that it is a large batch of records.

## tran (optional)

identifies the user transaction (LPAR_LONG_TRAN_ID) under which the update records operation is to be performed.

## Output

## dbstats (optional)

is a list of lpars that give statistics on the modified database similar to those returned by `lkt_dbload`.

If you do not care to have these statistics, just pass `lkt_dbrecreplace` a pointer value of NULL for dbstats.

Error codes and items returned by lkt_dbrecreplace

CHARCONV | record that contains improperly encoded characters
DBLOCKED | descriptor of locked database
EXPECTDBDESC | item that should have been a database name
EXPECTLIST | item that should have been a list lpar
EXPECTRECORD | item that should have been a name
INTERNAL | item that was being processed at time of error
NODBDESC | (none)
NOMEM | record being processed when memory cap was hit
NORECKEY | record that lacks a record key
NOSRCHTXT | record that lacks searchable text
NOSYSINIT | (none)
NUMFIELDS | record that contains the wrong number of fields
PARAMTYPE | lpar that has invalid id
TRAN_UNKNOWN | lpar that contains the unknown transaction id
TRAN_IN_USE | lpar that contains the transaction id
TRANCONFLICT | list that contains LPAR_LONGINT_TRAN_ID and LPAR_STR_ERRORDETAILS
UPDPARAM |

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO® Patterns

Copyright © 2010-2025. Cloud Software Group, Inc. All Rights Reserved.