ugethit

Gets the concatenated primary key and the physical row address of the current hit corresponding to the specified uctrl structure into the hitlist.

short ugethit(uc, pra, primkey)

struct uctrl *uc;

unsigned char *pra;

unsigned char *primkey;

Parameters

  • uc—address of the current control block.
  • pra—pointer to a buffer in which to store the physical row address. The connector must define this buffer.
  • primkey—pointer to a buffer in which to store the concatenated primary key. The connector must define this buffer.

Return Values

The return values are:

  • 0—No hit was found in the hitlist
  • 1—Only the physical row address is available
  • 2—Only the primary key is available
  • 3—Both the physical row address and the primary key are available

Description

Gets the concatenated primary key and the physical row address of the current hit corresponding to the specified uctrl structure into the hitlist.

The length of the primary key is available in uctrl->uprimlen. The length of the physical row address is available in uctrl->uralen. When you call ugethit in a connector request, it is not capable of getting the hit that was added within the execution of the same connector request.

A connector for a hierarchical DBMS can use ugethit to gain access to the current occurrence of the parent table, when the connector is called for a child table. For this purpose, the connector must set uinfo->link to a nonzero value in the Info connector request.

Use the ugethit service function to get the primary key or the physical row address of the current occurrence in the parent table.

This example is a piece of sample code that can be used to update a record. The sample code determines which record to update by using the primary key or the PRA. A call is then made to the ugethit service function. The sample code is not complete.

UpdateRecord ( struct uctrl *ControlBlock )
{
OperationType Operation; /* Update by PK or physical address. */
unsigned char *PKBuffer;
unsigned char *PRABuffer;
short Status;
if ( ControlBlock->uwlist->ufnr == 0 )
{
operation = update_by_phys_add;
}
else
{
operation = update_by_pk;
}
PKBuffer = (unsigned char *) malloc ( ControlBlock->uprimlen );
PRABuffer = (unsigned char *) malloc ( ControlBlock->uralen );
Status = ugethit( ControlBlock, PKBuffer, PRABuffer );
if ( !(Status & 1) )
{
/* Error occurred. */
}
else
{
/* Do actual update. The way to identify the record to be updated */
/* is given by the values of ’Operation’ and ’Status’. */
}
...
}