ubldprm

ubldprm builds the concatenated primary key for a record.

void ubldprm(uc, mode)

struct uctrl *uc;

short mode;

Parameters

  • uc—address of the current control block.
  • mode—must have the value 0.

Description

ubldprm builds the concatenated primary key for a record. The result is stored in the SQL buffer starting at position uctrl->sqlbuf[1000]. The length of the result is equal to uctrl->uprimlen.

When ubldprm is called, the values of the primary key fields must be available in the general I/O buffer. With a field-level connector, the actual length of the primary key fields must be available in the uflen elements in the field list.

ubldprm can be called to prepare a uaddhit or uaddrec.

If the primary key has been defined as a ‘compound’ key in the Uniface Application Objects Repository (that is, there is more than one field in the key), Uniface uses the concatenated primary key in the hitlist to identify the record. The DBMS connector can use the ubldprm service function to construct the concatenated primary key, before it adds the primary key to the hitlist. The order of the fields in the concatenated primary key is described in the index list. Index number one is by definition the primary key.

This example returns records that are found during the Select connector request. When the mode of request is 0 or 3, the ubldprm service function is used to construct the primary key needed to call the uaddrec service function.

The example creates the DrvAdminType data structure. The structure of the DrvAdminType holds the PRA in its PRA field and the primary key in its PKBuffer field. Such a structure would usually be stored in the connector workspace (uctrl->udrv).

ReturnRecordsFoundInSelect ( struct uctrl *ControlBlock,
DrvAdminType *ConnectorAdministration )
{
unsigned char Dummy;
if ( ControlBlock->umode == 1 ||
ControlBlock->umode == 2 )
{
/* Ready: modes 1 and 2 do not require hit. */
}
else
{
if ( ControlBlock->umode == 4 )
{
usumhit ( ControlBlock );
}
else
{
/* For modes 0 and 3 */
ubldprm ( ControlBlock, DrvAdministration->PKBuffer );
uaddrec ( ControlBlock,
DrvAdministration->PRA,
ControlBlock->uralen,
DrvAdministration->PKBuffer,
ControlBlock->uprimlen,
(unsigned char*)Dummy, 0 );
}
}
}