Progress
External Program
Interfaces


Accessing Progress Data

This section describes how to use HLC library functions to access Progress data. For example, you can use the prordbi() function to read an integer field in a shared buffer. Use the following guidelines when accessing Progress data with HLC library functions.

CAUTION: If you do not follow these guidelines, you can permanently damage your Progress database.

The following example demonstrates these guidelines by defining shared buffer custbuf within a 4GL procedure:

DEFINE NEW SHARED BUFFER custbuf FOR customer.
FIND first custbuf.
CALL subfunc1. 

Later in your 4GL code, execute a CALL statement that calls a C function. Within the C function, you read the cust-num field. The cust-num field is an integer field in the customer table, for which shared buffer hlcbuff is defined, as follows:

#include "hlc.h"
subfunc1()
{
  int    ret, index, unknown;
  char    message[80];
  long    cnum;
  int    fhandle;

index = 0;
unknown = 0;

fhandle = profldix ("custbuf", "cust-num");
ret = prordbi ("custbuf", fhandle, index, &cnum, &unknown);
if (ret||unknown)
{
  sprintf (message, "prordbi fatal ret = %d unknown %d", ret, unknown);
  promsgd (message);
}
sprintf(message, "customer.cust-num was %ld", cnum);
promsgd(message);
return 0;
} 

The prordbi() function reads an integer field contained in a shared buffer. To determine the HLC library function to use, see the "Function Summary" section in "HLC Library Function Reference."

The prordbi() function has the following syntax:

SYNTAX
int prordbi ( pbufnam , fhandle , index , pvar , punknown )
  char *pbufname ;
  int   fhandle ;
  int   index ;
  long *pvar ;
  int  *punknown ; 

The pbufnam parameter points to the name of the specified shared buffer. You supply the name from your Progress application.

The fhandle input parameter is the field handle that profldix() returns for the specified field.

The index input parameter specifies an index value for an array field. If the field is a scalar, you must set the value of index to 0.

The pvar output parameter points to a long where prordbi() returns the value of the specified integer field.

The punknown output parameter points to an integer where prordbi() returns 1 if the field has the unknown value, and returns 0 otherwise.

Figure 2–4 shows a call being made to prordbi() that illustrates HLC programming guidelines:

Figure 2–4: Example HLC Library Function Call


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095