Products | Versions |
---|---|
TIBCO MDM | - |
Not Applicable | - |
Resolution:
Currently, the duplicate function available in MDM does not support multivalued (MVT) attributes. When requiring new
records to not be created if a subset of attributes, including if some MVTs are among the attributes, matches with one or more existing records, the "duplicate" function cannot be used.
1). Provide a database function that provides the
missing functionality and then reference the function in an MDM Studio
tableSQL(...) call. A function with a signature of:
COMPAREMVSTRING(<EnterpriseName>,
<RepositoryName>,
<MultiValueAttributeName>,
<SourceRecord>.<MultiValueList>,
<SourceRecord>.PRODUCTID,
<SourceRecord>.PRODUCTIDEXT,
<TargetRecord>.PRODUCTID,
<TargetRecord>.PRODUCTIDEXT,
<LATESTorCONFIRMED>)
and returning :
*
1 when the values in <MultiValueList> for the Source Record match those in the
Target for either LATEST
or CONFIRMED versions.
* 0 otherwise.
for comparing MultiValue String values is used as an example.
Of particular note in the above signature, is the form taken by the
parameter <SourceRecord>.<MultiValueList> :
* when <SourceRecord>.<MultiValueList> = ('XNOVALUEX'), the LATEST or
CONFIRMED version of the <MultiValueAttributeName> attribute in the
database is used.
* when <SourceRecord>.<MultiValueList> =
T_STRTAB(...List of Values...), a database object of type T_STRTAB,
populated with the ...List of Values..., is used.
Note that in the second case, a database object of type T_STRTAB is being passed to the database function :
T_STRTAB(<SourceRecord>.<MultiValueList>)
It
is actually a type constructor, with a variable length set of values as
attributes that are being passed. The type T_STRTAB is defined as:
create or replace TYPE T_STRTAB AS TABLE OF VARCHAR2(256); -- T_STRTAB: String Table (for multivalues)
If a simple attempt
is made to pass the source record MultiValue attribute as in:
COMPAREMVSTRING(<EnterpriseName>,
<RepositoryName>,
<MultiValueAttributeName>,
<SourceRecord>.<MultiValueList>,
<SourceRecord>.PRODUCTID,
<SourceRecord>.PRODUCTIDEXT,
<TargetRecord>.PRODUCTID,
<TargetRecord>.PRODUCTIDEXT,
<LATESTorCONFIRMED>)
MDM
replaces <SourceRecord>.<MultiValueAttribute> with the list
of values in-line. As a result, MDM ends up creating the function
call:
COMPAREMVSTRING(<EnterpriseName>,
<RepositoryName>,
<MultiValueAttributeName>,
<MV1>,
<MV2>,
<MV3>,
...
<SourceRecord>.PRODUCTID,
<SourceRecord>.PRODUCTIDEXT,
<TargetRecord>.PRODUCTID,
<TargetRecord>.PRODUCTIDEXT,
<LATESTorCONFIRMED>)
This function call is then rejected as having the wrong number or type of arguments. By adding the T_STRTAB constructor, MDM creates the following function call instead:
COMPAREMVSTRING(<EnterpriseName>,
<RepositoryName>,
<MultiValueAttributeName>,
T_STRTAB(<MV1>,<MV2>,<MV3>,...),
<SourceRecord>.PRODUCTID,
<SourceRecord>.PRODUCTIDEXT,
<TargetRecord>.PRODUCTID,
<TargetRecord>.PRODUCTIDEXT,
<LATESTorCONFIRMED>)
This
function call is correct. Note that the example shown is for Oracle. SQL Server uses a slightly different syntax for type constructors. For the function signature given, it is assumed that for the function behind the signature:
* The <TargetRecord>.<MultiValueList> values are always taken from the database.
*
The final parameter, <LATESTorCONFIRMED> is used to determine
whether the LATEST or CONFIRMED version of <SourceRecord> or
<TargetRecord> <MultiValueList> values are to be taken
from the database where the <SourceRecord>
<MultiValueList> values are not provided in the
<SourceRecord>.<MultiValueList> parameter).
Why
is <SourceRecord>.<MultiValueList> provided in the
function call? Can't the LATEST values for the Source record just be
read from the database?
The short answer is no. The long
answer is because when a record is modified, the latest values are not
stored in the database. Instead, they are held directly by the code
processing the form, so it is necessary to pull the values directly from
the code. This is why the function call allows for
<SourceRecord>.<MultiValueList> to be provided in the
call.
The function behind the call does not assume that the
record identified by PRODUCTID/PRODUCTIDEXT actually exists in the
database at all. If it does, then the associated database
PRODUCTKEYID is used, otherwise a value of null is set for the key
(which is still correct even if <SourceRecord>.
<MultiValueList> = ('XNOVALUEX'). In this case, if no
corresponding database record exists for PRODUCTID/PRODUCTIDEXT, then
the <SourceRecord>. <MultiValueList> "taken from the
database" will also be null). The function behind
the function call correctly handles the following cases:
*
Comparing a Source MultiValue String Attribute when the parameter
<SourceRecord>.<MultiValueList> is set (that is, taken
from the Modify/Add Form) with Target records from the same repository.